Skip to content

fix(web): drop third-party browser extension exceptions - #26

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixweb-filter-browser-extension-errors-5ba120
Draft

posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixweb-filter-browser-extension-errors-5ba120

Conversation

@posthog

@posthog posthog Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Problem

  • Error tracking shows a junk issue, "Invalid call to runtime.sendMessage(). Tab not found.", that amend.sh did not cause — noise that hides real issues.
  • The message is a Safari WebExtension API error thrown by a visitor's browser extension inside the page. amend.sh has no chrome.runtime or browser.runtime call anywhere in apps/web or packages/backend.
  • getPostHogOptions() set capture_exceptions: true with no before_send filter, so posthog-js forwarded every unhandled window error, including third-party ones.

Changes

  • Add a before_send hook to getPostHogOptions() that drops an $exception event when its message matches a known WebExtension messaging API and its stack carries no application frame.
  • Keep the decision in a pure helper, isThirdPartyExtensionException(), with unit tests.
     autocapture: false,
     capture_exceptions: true,
+    before_send: (event) => {
+      if (event?.event === "$exception" && isThirdPartyExtensionException(event.properties)) {
+        return null;
+      }
+      return event;
+    },

Drop rule — both conditions must hold:

Condition Reason
Message matches runtime/tabs.sendMessage/connect/onMessage/onConnect Marks a WebExtension messaging error
No frame has in_app === true Our own code always reports an application frame, so this spares real errors

Note

The filter is conservative: an error keeps flowing whenever any application frame is present, even if the message matches. Only frameless, synthetic extension errors are dropped.

Testing

  • bun test scripts/posthog-exception-filter.test.ts — 5 pass (drops the reported error, keeps application errors and unrelated events).
  • turbo -F web check-types, oxlint, and oxfmt --check pass on the changed files.

Agent context

  • The PostHog signal routed to opencoredev/opentab, but that repo is a bare WXT scaffold with no PostHog setup. The real capture path lives here in amend.sh, so the fix lands here.
  • After merge, suppress the existing error tracking issue so it does not reopen on the last event.

Why

A single Safari visit to https://amend.sh/#pricing filed a visitor extension error as an amend.sh issue. The impact is low, but this class of noise recurs for as long as the filter is missing.


Created with PostHog Desktop from this inbox report.

Visitor browser extensions throw WebExtension messaging errors (for
example "Invalid call to runtime.sendMessage(). Tab not found.") inside
the amend.sh page. posthog-js forwarded them as unhandled exceptions
because getPostHogOptions() set capture_exceptions with no before_send
filter, so they surfaced as amend.sh error tracking issues.

Add a before_send hook that drops an $exception event when its message
matches a known WebExtension messaging API and its stack carries no
application frame. Keep the check in a pure, unit-tested helper.

Generated-By: PostHog Desktop
Task-Id: 36f78318-af32-4c45-8d2d-a53fa8e64fdb
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