Skip to content

fix(analytics): stop capturing exceptions from local dev hosts - #3365

Open
posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixanalytics-stop-capturing-exceptions-0c5e46
Open

posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixanalytics-stop-capturing-exceptions-0c5e46

Conversation

@posthog-eu

@posthog-eu posthog-eu Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Who is hurt: the team, not users. Every refactor can mint a fresh production error-tracking issue from a developer laptop, and each one costs a triage and research cycle.
  • Mechanism: the capture gate in src/services/posthog.ts skips 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.
  • Fix: extend the existing before_send suppression hook to also drop $exception events whose page host is a local dev host (localhost, 127.0.0.1, *.local), read from $host and, as a fallback, the host parsed from $current_url.
  • Scope is intentionally narrow: no shipped bug is changed. disableRollout is correctly defined in current main; the reported ReferenceError came 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.
  • New tests cover the isLocalDevHost helper (localhost/127.0.0.1/*.local with and without a port; production hosts and empty/undefined values rejected) and the host-based suppression path (drop by $host, drop by $current_url fallback, 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

  • My code follows the code style of this project and passes
    bun run lint:backend && bun run lint.
  • My change requires a change to the documentation.
  • I have updated the documentation
    accordingly.
  • My change has adequate E2E test coverage.
  • I have tested my code manually, and I have provided steps how to reproduce
    my tests

Created with PostHog Desktop from this inbox report.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

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
@posthog-eu
posthog-eu Bot deployed to deepsec-pr September 17, 2026 12:01 Active
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 1902cf67-d231-4d73-af3a-39d47be10c06

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codspeed

codspeed Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing posthog-self-driving/fixanalytics-stop-capturing-exceptions-0c5e46 (13f6a34) with main (a8ca6fe)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@sonarqubecloud

Copy link
Copy Markdown

@posthog-eu
posthog-eu Bot marked this pull request as ready for review September 17, 2026 12:21

This branch was successfully deployed

1 active deployment
deepsec-pr — 13f6a347 Deployed Sep 17, 2026 by posthog-eu[bot] via Scan PR changes #7213
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.

0 participants