Primary service: PostHog (error tracking, product analytics, and log ingestion), wired through the shared @open-learning-hub/observability package. Canonical policy: 092-analytics-observability.mdc.
Canonical structured logging: 091-structured-logging.mdc. It owns the logger API, emit contract, Edge-safety requirements, redaction rules, parity contract, and logger test expectations. Server logs are additionally forwarded to PostHog via the OpenTelemetry log-sink seam described there.
Correlation: route handlers, server actions, and server components should attach a traceId to logs and event/exception properties. Include tenantId and userId only when available and authorized for the current request, and never send emails or names.
Client errors: production client-side error boundaries (error.tsx / global-error.tsx) report to PostHog error tracking with route/boundary and digest, gated on analytics consent. Development keeps console logging for fast local debugging.
Server errors: log the original error server-side with stack and sanitized context, capture it via the server analytics seam (captureException), then return user-safe messages to the client.
Monitoring: alert on repeated auth failures, rate-limit spikes, CMS integration failures, payment webhook failures, and unexpected 5xx responses.