fix(analytics): stop capturing exceptions from local dev hosts - #3365
posthog-eu[bot] wants to merge 1 commit into
Conversation
The PostHog capture gate skips analytics only when the Supabase host is local. A developer running the frontend against remote or preprod Supabase passes that gate, so their transient compile and hot-reload errors reach production error tracking and open new issues on every refactor. Extend the before_send suppression hook to drop $exception events whose page host is a local dev host (localhost, 127.0.0.1, *.local), read from $host and from $current_url. Add unit tests for the new isLocalDevHost helper and the host-based suppression path. Generated-By: PostHog Desktop Task-Id: 86f1c693-158f-4d23-9908-726a591aa262
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
|



Summary
src/services/posthog.tsskips analytics only when the Supabase host is local. A developer running the frontend against remote or preprod Supabase passes that gate, so transient compile and hot-reload errors from a Vite dev server reach production error tracking.before_sendsuppression hook to also drop$exceptionevents whose page host is a local dev host (localhost,127.0.0.1,*.local), read from$hostand, as a fallback, the host parsed from$current_url.disableRolloutis correctly defined in currentmain; the reportedReferenceErrorcame from one developer's dev server ($host=localhost:5175) mid-edit.Test plan
bunx vitest run tests/stale-asset-errors.unit.test.ts— 16 tests pass.isLocalDevHosthelper (localhost/127.0.0.1/*.localwith and without a port; production hosts and empty/undefined values rejected) and the host-based suppression path (drop by$host, drop by$current_urlfallback, keep the same exception from the production host).Screenshots
Not applicable — no user-facing behaviour changes. The change only affects which client-side exception events are sent to error tracking.
Checklist
bun run lint:backend && bun run lint.accordingly.
my tests
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.