Drop third-party exceptions from PostHog autocapture - #168
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
Exception autocapture forwarded every uncaught window error, including errors thrown by embedded third-party scripts such as HubSpot. These are not app bugs, but they still land in error tracking as scary-looking issues that a person must triage. Add a before_send filter to posthog.init() that drops any $exception whose stack frames all resolve to a known third-party host (hscollectedforms.net, hs-scripts.com). First-party exceptions pass through unchanged. Generated-By: PostHog Desktop Task-Id: c97b868e-7d0f-476b-88dd-bdd32a8a1e32
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.
Problem
Error: Level "ERROR" is not supported, only to find it belongs to a vendor script — pure triage cost, no user impact (1 occurrence, 1 user, 1 session).collectedforms.js; the error was thrown by HubSpot's own logger, not by app code.posthog.init()set nobefore_sendfilter, so exception autocapture forwarded every uncaught window error, whoever threw it. Every third-party embed on the site can mint more of these.Changes
before_sendfilter toposthog.init()that drops any$exceptionwhose stack frames all resolve to a known third-party host.hscollectedforms.net,hs-scripts.com(HubSpot). Add more hosts toTHIRD_PARTY_ERROR_HOSTSas needed.This kills the whole class of vendor-script noise, not just the one fingerprint.
Test plan
tsc --noEmit— no new type errorseslint components/PostHogProvider.tsx— cleanCreated with PostHog Desktop from this inbox report.