Filter third-party exceptions from error tracking - #78
Merged
Jingxi-Polymaker merged 2 commits intoSep 10, 2026
Merged
Conversation
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
marked this pull request as ready for review
September 10, 2026 08:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third-party script exceptions create error-tracking noise. Add a PostHog
before_sendhook 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.