fix(selfhost): replace Sentry with PostHog for error tracking#8617
Conversation
Removes src/selfhost/sentry.ts and every real call site now that PostHog error tracking is a full replacement, not a parallel-run sink (2026-07-25 epic #8286 correction). PostHog already mirrored Sentry's capture/monitor/ structured-log-forwarding behavior field-for-field, so this is mostly subtraction: strip the Sentry imports, move the one shared constant (operational tag keys) into redaction-scrub.ts, and drop @sentry/node + @sentry/opentelemetry from the root package.json (the hosted Worker's own separate @sentry/cloudflare + @sentry/hono integration is untouched). Also wires self-host's OpenTelemetry exporter to default its OTLP trace endpoint at PostHog's own distributed-tracing product (beta, plain OTLP/ HTTP) when POSTHOG_API_KEY is set and no explicit OTEL_EXPORTER_OTLP_* override is given -- this replaces the bespoke Sentry span-processor/ sampler bridge with a strictly simpler generic-OTLP path, so removing the bridge is not a capability loss. Updates the self-hosting-operations docs and every affected drift-guard test accordingly. Deliberately out of scope, left for follow-up PRs: the hosted ORB Worker's own Sentry middleware (src/api/routes.ts), and the Grafana Sentry-issues dashboard + release pipeline's @sentry/cli source-map upload (neither is coupled to this error-tracking code path).
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
loopover-ui | 2c27e13 | Commit Preview URL Branch Preview URL |
Jul 25 2026, 10:30 AM |
Bundle ReportChanges will decrease total bundle size by 1.3kB (-0.02%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: loopover-uiAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8617 +/- ##
==========================================
- Coverage 92.82% 92.75% -0.08%
==========================================
Files 798 797 -1
Lines 79621 79355 -266
Branches 24129 24032 -97
==========================================
- Hits 73909 73604 -305
- Misses 4573 4604 +31
- Partials 1139 1147 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-25 10:47:31 UTC
Review summary Nits — 5 non-blocking
Concerns raised — review before merging
📋 Copy for AI agents — paste into your coding agentDecision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Visual preview
Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy. Scroll preview
A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
…8619) Replaces the self-host release pipeline's @sentry/cli sourcemap inject/ upload/finalize steps with posthog-cli's simpler inject/upload (no separate release-create/set-commits/finalize lifecycle -- PostHog release metadata is a byproduct of the upload itself). Fixes a currently-broken step in the process: "Validate Sentry release" called review-enrichment/scripts/validate-sentry-release.mjs, which #8615 already deleted -- any official release cut since then would have failed there. Renames SENTRY_RELEASE -> POSTHOG_RELEASE throughout scripts/deploy-selfhost-prebuilt.sh (the operator-facing local sourcemap upload path) and scripts/selfhost-post-update-check.sh, matching what src/selfhost/posthog.ts's resolvePostHogRelease already reads. Replaces the stale "Sentry error tracking" block in .env.example (self-host has had zero SENTRY_* code paths since #8617) with the real PostHog vars, plus the CLI-specific POSTHOG_CLI_API_KEY/POSTHOG_CLI_PROJECT_ID/POSTHOG_CLI_HOST used only by this upload step. Requires POSTHOG_CLI_API_KEY (secret) and POSTHOG_CLI_PROJECT_ID (var) to be configured in the release and release-beta GitHub environments before the next official/beta image build -- neither exists yet.
ui-preview.yml / ui-preview-deploy.yml (via the shared deploy-ui-preview composite) create a "preview/pr-<N>" GitHub Environment via createDeployment the first time a PR gets a preview build -- transient_environment: true is only a display hint, it never triggers deletion, and nothing else in the repo ever calls the delete-environment API. Confirmed live: 1254 of 1260 environments were preview/pr-* entries for already-closed PRs (spanning PR #4140-#8617), none carrying protection rules -- cleaned up directly via the API as a one-time sweep before adding this workflow. Mirrors cache-cleanup.yml's existing fix for the identical class of problem (GHA caches instead of environments): batched on a daily schedule, not a pull_request:[closed] trigger, so PR-close bursts never queue a runner per event and compete with real CI. No storage-budget urgency here unlike the 10GB cache cap, so daily is enough. Needs a new ENVIRONMENT_ADMIN_TOKEN secret -- deleting an environment requires repo scope (classic PAT) or Administration:write (fine-grained PAT); GITHUB_TOKEN can never be granted this via a permissions: block, confirmed against GitHub's own docs.


Summary
Completes the self-host leg of #8287 under epic #8286's 2026-07-25 strategy correction: PostHog now fully replaces Sentry for self-host error tracking (no parallel-run). PostHog's implementation already mirrored Sentry's capture/monitor/structured-log-forwarding behavior field-for-field, so this is mostly subtraction:
src/selfhost/sentry.tsand every real call site (server.ts,sqlite-queue.ts,pg-queue.ts,monitored-work.ts,queue/processors.ts,queue/ai-review-orchestration.ts,services/agent-action-executor.ts).SENTRY_OPERATIONAL_TAG_KEYS) intoredaction-scrub.ts, renamedOPERATIONAL_TAG_KEYS.@sentry/node+@sentry/opentelemetryfrom the rootpackage.json(the hosted Worker's own separate@sentry/cloudflare/@sentry/honointegration is untouched — different surface,src/api/routes.ts, follow-up PR).POSTHOG_API_KEYis set and no explicitOTEL_EXPORTER_OTLP_*override is given — replaces the bespoke Sentry span-processor/sampler bridge with a strictly simpler generic-OTLP path, so removing the bridge is not a capability loss.self-hosting-operations.mdxand every affected drift-guard test.selfhost-env-reference.tsand the branding-drift baseline.Deliberately out of scope (independent of this code path, tracked as follow-ups):
src/api/routes.ts).scripts/setup-sentry-datasource.sh) and the release pipeline's@sentry/clisource-map upload (.github/workflows/release-selfhost.yml).Test plan
npm run typecheck— cleannpm run test:cigate — 1153 test files / 21513 tests passed (plus the four workspace sub-suites it chains), 0 failuresnpm audit --audit-level=moderate— same 5 pre-existing high-severity findings asmain(eslint/minimatch/brace-expansion chain), unrelated to this changenpm run selfhost:env-reference:check/npm run branding-drift:check— both pass against the regenerated files