Skip to content

PostHog error observability across API, dashboard, and CLI#101

Open
distroinfinity wants to merge 15 commits into
mainfrom
tracing-metrics
Open

PostHog error observability across API, dashboard, and CLI#101
distroinfinity wants to merge 15 commits into
mainfrom
tracing-metrics

Conversation

@distroinfinity

Copy link
Copy Markdown
Owner

Summary

Adds PostHog error tracking + debugging across all three surfaces (errors-first; not product analytics). A dedicated Distro TV PostHog project is assumed (separate from the unrelated Dodge AI project). Every runtime path is a no-op until its key is set, so this is safe to merge before credentials land.

  • Shared (@distrotv/shared/telemetry): SDK-agnostic contract — event names, resolveRelease, env kill-switch, and a default-deny scrubString/scrubError (strips filesystem paths + gh*/sk-*/JWT tokens).
  • API (posthog-node): captures the error-handler's unknown-error branch (not known 4xx) + unhandledRejection/uncaughtException in index.ts/worker.ts; bounded flush on SIGTERM. pino + Slack stay as local ground truth.
  • Dashboard (posthog-js): exception autocapture + session replay with all inputs/text masked + a global-error boundary. Keeps @vercel/analytics for pageviews.
  • CLI + daemon (posthog-node): ingest key baked at build via tsup define. Daemon owns the long-lived client (captures faults + log.error, stays alive by design); interactive commands capture via reportError then a bounded flush-on-exit. Hooks carry no telemetry — the <200ms slot-vanish budget is untouched (verified by the existing hook-timing smoke test).
  • Consent (CLI, opt-out): on by default; DISTRO_TELEMETRY=0 env → ~/.distro/config.json flag → default. distro config telemetry on|off|status, a one-time notice after distro init, and a distro doctor probe.
  • Privacy: strict allow-list (scrubbed name/message/stack + os/arch/node/cli version, route/method/status, anon distinct_id, release). Never sends prompts, code, file contents, ticker/news content, watchlist symbols, secrets, or paths. Web relies on replay masking + no PII identify (see gitbook-docs/engineering/observability.md).

Still pending (needs your new PostHog project creds — not in this PR)

  • Create the dedicated Distro TV PostHog project; set POSTHOG_KEY/POSTHOG_HOST (Railway), NEXT_PUBLIC_POSTHOG_* (Vercel), bake POSTHOG_CLI_KEY in the release workflow
  • Enable session replay in PostHog project settings
  • Wire source-map upload (needs POSTHOG_CLI_TOKEN; deferred to avoid breaking CI)
  • End-to-end verification against the real built CLI artifact (not stubs)

Test plan

  • pnpm typecheck / pnpm lint / pnpm build — all green across packages
  • 125 CLI tests pass, incl. hook-timing smoke (<100ms hot path)
  • distro config telemetry on/off/status + DISTRO_TELEMETRY=0 forced-off verified at runtime
  • Fast-exit confirmed (reportError defers exit until bounded flush settles)
  • Live capture verification once the PostHog key is set (API 500 → Issue; web error → Issue + masked replay; CLI error → Issue; DISTRO_TELEMETRY=0 → zero network)

@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
devdrip Ready Ready Preview, Comment May 29, 2026 10:42am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant