Skip to content

Drop third-party exceptions from PostHog autocapture - #168

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixposthog-provider-filter-third-party-5ffed0
Draft

Drop third-party exceptions from PostHog autocapture#168
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixposthog-provider-filter-third-party-5ffed0

Conversation

@posthog

@posthog posthog Bot commented Aug 28, 2026

Copy link
Copy Markdown

Problem

  • A person had to open a scary-looking error tracking issue, 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).
  • Every stack frame resolved to HubSpot's collectedforms.js; the error was thrown by HubSpot's own logger, not by app code.
  • posthog.init() set no before_send filter, so exception autocapture forwarded every uncaught window error, whoever threw it. Every third-party embed on the site can mint more of these.

Changes

  • Add a before_send filter to posthog.init() that drops any $exception whose stack frames all resolve to a known third-party host.
  • Hosts filtered: hscollectedforms.net, hs-scripts.com (HubSpot). Add more hosts to THIRD_PARTY_ERROR_HOSTS as needed.
  • First-party exceptions, and mixed stacks that touch app code, pass through unchanged.

This kills the whole class of vendor-script noise, not just the one fingerprint.

Test plan

  • tsc --noEmit — no new type errors
  • eslint components/PostHogProvider.tsx — clean
  • Confirm real app exceptions still reach error tracking after deploy

Created with PostHog Desktop from this inbox report.

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
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