Skip to content

Give Sentry the context to act on its events - #2133

Closed
joepio wants to merge 1 commit into
developfrom
sentry-context
Closed

joepio wants to merge 1 commit into
developfrom
sentry-context

Conversation

@joepio

@joepio joepio commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Before: Sentry stacks pointed at minified chunks, the same error split into several issues by chunk hash, nobody could tell how many people an error touched, "Commit keeps failing" carried no drive or age, Cloud Server setup failures that only showed a toast left nothing behind, and an error raised ten thousand times arrived as one event.

After: stacks name the real source (when a build has a Sentry token), events carry an anonymous per-agent id, a failing commit reports its drive, age, outbox size and connection state, toast-only Cloud Server setup failures are reported, and an error that repeats 10, 100, 1000 … times on one page load sends a summary with the count. Bugsnag no longer logs "notify before start" on installs that don't use it.

Source maps are uploaded when SENTRY_AUTH_TOKEN is set in the build environment, then deleted so the binary does not grow. Without the token nothing changes: no plugin, no maps. A failed upload only warns and leaves the maps in dist.

How:

  • vite.config.ts: @sentry/vite-plugin (org ontola, project atomic-browser, release atomic-data-browser@<version>+<commit>, same string the SDK reports), hidden maps, filesToDeleteAfterUpload. @sentry/cli build script stays off in pnpm-workspace.yaml: the binary comes from the optional platform package.
  • sentry.ts: identifyAgentInSentry sets the user to the first 8 bytes of the SHA-256 of the agent id (no email, sendDefaultPii stays off); countRepeatedEvents runs on the client's preprocessEvent hook, which fires before Dedupe, and is bounded to 200 tracked errors per page load; reportUserFacingFailure for toast-only failures.
  • store.ts: RepeatedCommitFailure gains drive, ageMs, outboxSize, connected, isGenesis, rearmedAfterResync. Fingerprints are unchanged.
  • SyncRoute.tsx: three reports in backupToCloud (no portal configured, failure after sign-in, automatic enrollment threw). The manual catch already goes through store.notifyError.

Tests: sentry.test.ts (18, counter, pseudonym, ordering, payload), loggingHandlers.test.ts. Built with and without a token: no token gives 0 source maps; a fake token tries the upload, warns and carries on.

To turn on source maps, add SENTRY_AUTH_TOKEN (release and source map upload scope) as a secret to every build that serves users.

Requested by Joep

Upload source maps per release when SENTRY_AUTH_TOKEN is set, so stacks
name the real source instead of minified chunks. Set a hashed agent id as
the Sentry user. Send drive, age, outbox size and connection state with
'Commit keeps failing'. Report Cloud Server setup failures that only
showed a toast. Count repeats of an error per page load, so events lost to
client-side dedupe still show their volume. Guard Bugsnag.notify with
isStarted.
joepio added a commit that referenced this pull request Oct 8, 2026
Combines #2123, #2127, #2133, #2134, #2135, #2136, #2138, #2140, #2141, #2142, #2143, #2147, #2149, #2132, #2121, #2129, #2146 and #1870. Includes fixes for the combination: Dagger mount for the form validation cases, drive mapping list without the flush sentinel, web_time in search, sidebar resize test at the touch bar height.

joepio commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

Landed on develop through the batch #2153 (d102056), with this PR's head unchanged. Closing as merged.


Generated by Claude Code

@joepio joepio closed this Oct 8, 2026
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.

1 participant