Skip to content

Filter third-party exceptions from error tracking - #78

Merged
Jingxi-Polymaker merged 2 commits into
mainfrom
posthog-self-driving/choreanalytics-filter-third-party-24ccb3
Sep 10, 2026
Merged

Filter third-party exceptions from error tracking#78
Jingxi-Polymaker merged 2 commits into
mainfrom
posthog-self-driving/choreanalytics-filter-third-party-24ccb3

Conversation

@posthog

@posthog posthog Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Third-party script exceptions create error-tracking noise. Add a PostHog before_send hook that drops an exception only when every frame in every exception entry is identifiable as third-party code.

HTTP(S) and protocol-relative URLs are classified by hostname. Klaviyo's known /onsite/js/ paths are also recognized when the hostname has been stripped. Same-host frames, unfamiliar paths, inline page scripts, malformed entries, and missing stacks are retained. This deliberately preserves frameless errors, including ResizeObserver/ProgressEvent reports, rather than assuming that missing origin information proves third-party ownership. Non-exception events pass through unchanged.

Validation:

  • npm run test:all: 262 tests pass.
  • Tests execute the real initialization hook and cover vendor filtering, current first-party scripts, new script paths, inline pages, frameless rejections, mixed exception causes, malformed data, and non-exception passthrough.
  • JavaScript syntax, diff whitespace, and generated SEO consistency checks pass.
  • Live PostHog ingestion has not been exercised; the filter is verified locally without sending analytics events.

posthog Bot and others added 2 commits September 9, 2026 23:03
Add a before_send hook to the browser PostHog init in analytics.js. It keeps an
exception only when a stack frame comes from our own origin, so errors raised
entirely by vendor scripts (Klaviyo, Google, CDNs) and frameless browser noise
never reach error tracking.

Full URLs are classified by host. Frames reported as a host-stripped path are
matched against our own first-party script names, which the added test keeps in
sync with the same-origin script tags in index.html.

Generated-By: PostHog Desktop
Task-Id: ff9aa956-f330-440e-b78c-4d4519c7efc4
@Jingxi-Polymaker
Jingxi-Polymaker marked this pull request as ready for review September 10, 2026 08:22
@Jingxi-Polymaker
Jingxi-Polymaker merged commit 5a1eb85 into main Sep 10, 2026
8 checks passed
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.

1 participant