Skip to content

Fix: Drop analytics events from local development - #364

Draft
posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixobservability-drop-development-027bff
Draft

posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixobservability-drop-development-027bff

Conversation

@posthog-eu

@posthog-eu posthog-eu Bot commented Sep 11, 2026

Copy link
Copy Markdown

Problem

  • Who is hurt: the team, not users. Local development errors reach production error tracking and look like new incidents, so each one costs triage time on an otherwise quiet project.
  • The before_send hook in packages/observability/src/initAnalytics.ts stamps a deployment_env property on every event but never drops anything. A developer's local errors are captured exactly like production ones.
  • This is the third localhost-only issue to reach the inbox. The trigger this time: importWithRetry in packages/lib/src/preloader.ts threw Failed to load module after 5 attempts because the slides plugin bundle was not served by the local dev server — expected during development, but captured all the same.

Changes

  • Mechanism: before_send now returns null (drops the event) when the run is local development, before any event leaves the browser.
  • "Local development" means either:
    • the deployment environment is development, or
    • the current host is localhost (localhost, 127.0.0.1, 0.0.0.0, ::1, or any .local host).

Notes

  • No user impact: the reported exceptions came only from a local dev server, never from a production host.
  • No new test runner exists in this package, so the change ships without a unit test. The package builds cleanly (yarn build produces the ESM/CJS output; the pre-existing experimental-dts rollup warning is unrelated and also present on main).

Created with PostHog Desktop from this inbox report.

The `before_send` hook stamped `deployment_env` on every event but never
dropped anything, so a developer's local errors and activity reached
production analytics the same as real user events. This caused localhost-only
exceptions to surface in error tracking as if they were incidents.

Drop the event in `before_send` when the deployment environment is
development or the current host is localhost.

Generated-By: PostHog Desktop
Task-Id: d34abe68-0e76-4193-b1d4-97dc5383e28a
@github-actions

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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