Skip to content

PostHog error tracking for the hosted ORB Worker path (raw $exception, no SDK in the bundle) #8288

Description

@JSONbored

Part of epic #8286 (Phase 1 — Errors).

Current state

The hosted ORB Worker path attaches Sentry via middleware: src/api/routes.ts imports sentry from @sentry/hono/cloudflare and, only when running in a real Workers isolate (isCloudflareWorkerRuntime) with WORKER_SENTRY_DSN set, registers app.use(sentry(...)) (env vars WORKER_SENTRY_DSN/WORKER_SENTRY_ENVIRONMENT, documented in src/env.d.ts as deliberately separate from self-host's SENTRY_DSN to avoid cross-wiring).

Deliverables

  • Replace the middleware with raw $exception capture over PostHog's capture HTTP API — no SDK in the Worker bundle (epic principle; posthog-node is documented as too heavy for Workers). Pattern: feat(observability): add PostHog error tracking via raw $exception capture metagraphed#7777 (src/usage-telemetry.ts raw-capture approach).
  • Same runtime + env gating shape: no-op outside a Workers isolate or without the PostHog key env; WORKER_POSTHOG_* naming mirroring the existing WORKER_SENTRY_* split (and the same cross-wire warning ported to src/env.d.ts).
  • Flush via waitUntil, mirroring the src/mcp/server.ts telemetry chokepoint's MCP tool-call telemetry fires without waitUntil, unlike this repo's own scheduleAfterResponse pattern #7233 approach (never block the response on telemetry).
  • Redaction: reuse the scrub helpers from the self-host swap (or the typed-allowlist approach if the captured surface is small enough to enumerate).
  • Sentry middleware stays in parallel until the decommission gate.
  • Tests: capture fires on handler errors with redacted properties; no-op paths; bundle check stays green (no new Worker-bundle dependency).

Boundaries

  • Only the Worker path — the self-host server swap is its own sub-issue.

Resources

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions