fix(frontend): drop exceptions from code injected into the page - #3278
Draft
posthog-eu[bot] wants to merge 1 commit into
Draft
fix(frontend): drop exceptions from code injected into the page#3278posthog-eu[bot] wants to merge 1 commit into
posthog-eu[bot] wants to merge 1 commit into
Conversation
Add a frame-based rule to the PostHog before_send noise filter. An $exception whose only in-app frame points at the HTML document itself comes from a console paste, a browser extension, or an AI browser agent, not from code we ship. Our own code always runs from a hashed chunk under /assets/, so this rule drops the whole class instead of matching one message. Generated-By: PostHog Desktop Task-Id: a5ed4288-9ed1-4dec-a4e8-9efa518685cf
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
|
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.



Summary
Problem
TypeErrorissue for a snippet run inside the/appspage (Array.from(document.querySelectorAll('td')).find(...).outerHTML) — that selector exists nowhere in our code.global code, line 1. Code we ship always runs from a hashed chunk under/assets/.Changes
shouldSuppressPostHogExceptionEventmatched message text only and never looked at frames. Added a frame-based rule: drop an$exceptionwhose only in-app frame points at the document URL itself.filenameagainst$current_url(both with query and hash stripped). A frame that is the page document, not an/assets/chunk, is injected code.Test plan
bunx vitest run tests/stale-asset-errors.unit.test.ts— new cases cover the console-paste TypeError (dropped), a genuine bundled-asset error on the same page (kept), and the empty / missing-URL / non-in-app edge cases.Screenshots
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.