Files
PaperClipAI/ui/src/lib
743c18f3b2 fix(ui): drop errors thrown by browser extension scripts from browser Sentry (#23357)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The browser UI sends unhandled errors to Sentry through
`ui/src/lib/sentry.ts`
> - Browser extensions run their own scripts in the page. The Sentry SDK
wraps their event listeners, so an extension error is reported as a
Paperclip error
> - The Jam bug-capture extension listens for the Navigation API
`navigate` event. When its recorded network events become too large, its
listener throws `RangeError: Invalid string length` from
`JSON.stringify`
> - No Paperclip code is at fault. These reports are noise and hide real
errors
> - This pull request drops errors that extension code threw, with the
built-in Sentry `denyUrls` option
> - The benefit is fewer false error reports. Errors that Paperclip code
throws are still sent, also when an extension frame is lower on the
stack

## Linked Issues or Issue Description

**What happened?**
Hosted staging browser Sentry recorded one unhandled `RangeError:
Invalid string length`. A Paperclip link click called React Router's
`History.pushState`. The browser then fired the Navigation API
`navigate` event. The Sentry `BrowserApiErrors` wrapper caught the error
from a listener that the Jam extension added. The top frames are
`JSON.stringify (<anonymous>)`, then `re.addMany`, `t2.persistEphemeral`
and `t2.beforeNavigation` in
`webpack://jam-extension/injected-scripts/host-network-events.js`. A
second Sentry group with the same title and the same trace is already
ignored by hand.

**Steps to reproduce**
1. Install the Jam bug-capture extension and let it record network
events on a Paperclip page for a long time.
2. Click a Paperclip link that navigates in the app.
3. See `RangeError: Invalid string length` in the browser Sentry
project.

**Expected behavior**
Sentry does not record errors that a browser extension's own script
throws.

**Actual behavior**
Sentry records them as unhandled Paperclip errors.

Related: #22378 (the same kind of filter for Firefox for iOS injected
scripts). No duplicate PR was found (searched for `denyUrls`,
`jam-extension`, and "browser extension sentry").

## What Changed

- `ui/src/lib/sentry.ts`: add the exported
`BROWSER_EXTENSION_SCRIPT_URLS` list and pass it to `Sentry.init` as
`denyUrls`. The list holds the `chrome-`, `moz-`, `safari-`,
`safari-web-` and `ms-browser-extension://` URL schemes and Jam's
`webpack://jam-extension/` script URL. A comment tells why.
- `ui/src/lib/sentry.test.ts`: add a test with the real Sentry SDK. It
sends the reported Jam stack and a `chrome-extension://` stack, and
makes sure that Sentry drops them. It also sends an app error with a Jam
frame lower on the stack and a plain app error, and makes sure that
Sentry keeps them. Add an options test for which URLs are denied and
which are not.
- `doc/observability.md`: describe the filter next to the `__firefox__`
note.

## Verification

- `cd ui && pnpm exec vitest run src/lib/sentry.test.ts
src/lib/browser-error-context.test.ts`: 66 passed.
- Without the `ui/src/lib/sentry.ts` change (tests kept), the 2 new
tests fail. With the change, all 45 tests in `sentry.test.ts` pass.
- `@sentry/core` 10.71.0 `eventFilters` reads the innermost frame whose
file name is not `<anonymous>` or `[native code]`. For the reported
event, that is the Jam script URL.
- `cd ui && pnpm exec tsc --noEmit -p .`: no errors in the changed
files. The local tree has only errors from an unbuilt plugin SDK and
missing generated Storybook files. CI covers the full typecheck.

## Risks

- Low risk. The filter matches only the frame that threw. An extension
that throws from its own script while it runs Paperclip code would also
be dropped, but such an error is not a Paperclip bug.
- A Paperclip error is not dropped when an extension frame is lower on
the stack. A test covers this.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 09:34:32 +00:00
..