SIGN IN SIGN UP

fix(browser): drop exceptions thrown by injected browser scripts (#4607)

* fix(browser): drop exceptions thrown by injected browser scripts

Firefox for iOS and Chrome for iOS inject user scripts that the browser
attributes to the host page. When such a script reads a browser-private
global (for example __firefox__) before it exists, it throws, and error
tracking captured it as the page's own error. The existing extension
filter matches on the frame filename, which for an injected script is the
page URL, so it never matched.

Match the private global in the exception value instead and drop the
exception, gated by the same captureExtensionExceptions config.

Generated-By: PostHog Desktop
Task-Id: 08fa8828-54a1-4300-a7ae-e287e1a1359e

* docs(types): note injected-browser-script drop in captureExtensionExceptions JSDoc

The captureExtensionExceptions option now also gates dropping of exceptions
thrown by browser-injected user scripts (Firefox for iOS, Chrome for iOS),
not just browser extensions. Update its JSDoc — the only public documentation
surface for this option — so the published API reference reflects both drop
categories.

Generated-By: PostHog Desktop
Task-Id: c2e82d83-e85a-4c04-b67e-a985f7f44509

* chore(changeset): declare @posthog/types patch

The JSDoc update to ErrorTrackingOptions.captureExtensionExceptions
modifies @posthog/types, so declare it in the changeset frontmatter to
satisfy the changeset-hygiene check.

Generated-By: PostHog Desktop
Task-Id: 08fa8828-54a1-4300-a7ae-e287e1a1359e

* chore(browser): register mangled name for new private method

Add _isInjectedBrowserScriptException to terser-mangled-names.json so the
"Write mangled property names" check passes.

Generated-By: PostHog Desktop
Task-Id: 08fa8828-54a1-4300-a7ae-e287e1a1359e

* chore(changeset): reword for external readers

* test(browser): use the exception shape coercers actually produce

---------

Co-authored-by: posthog[bot] <206114724+posthog[bot]@users.noreply.github.com>
Co-authored-by: Anna Garcia <anna.g@posthog.com>
P
posthog[bot] committed
7ec4f0dd2575aee0a5b664ccad0c59e9fac9c89e
Parent: e24ea03
Committed by GitHub <noreply@github.com> on 8/24/2026, 10:03:31 PM