Skip to content

feat: report errors to Sentry - #329

Merged
MrYuion merged 3 commits into
developfrom
t3/review-sentry-usage
Oct 27, 2026
Merged

MrYuion merged 3 commits into
developfrom
t3/review-sentry-usage

Conversation

@MrYuion

@MrYuion MrYuion commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Backoffice has sent nothing to Sentry since 2020. That year a cleanup removed Sentry.init and the ErrorHandler provider. Only an unused @sentry/browser dependency was left.

Changes

  • src/app/common/sentry.ts loads @sentry/angular with a dynamic import after the user signs in, so the initial bundle stays small. SentryReportingErrorHandler still logs to the console. It queues up to 20 errors until Sentry starts.
  • The DSN comes from the authority config.backoffice.sentry_dsn. When that is not set, the PlaceOS default DSN is used. '' or false turns Sentry off. Sentry is also off on localhost and in mock mode.
  • Sentry gets errors, 10% of traces (100% on dev builds) and replays of sessions that have an error. Replays use Sentry's default masking of all text and media. Only the user ID and a domain tag are sent. The old code also sent the email address.
  • Sentry's own window error listeners are turned off. Angular already sends those errors to the error handler, so each error would be sent twice.
  • Production builds make hidden source maps. CI injects debug IDs and uploads the maps, then deletes them before deploy. Debug IDs change the script files, so config/ngsw-rehash.js updates the hashes in ngsw.json. Without this, the service worker rejects those files.

Setup

Add the SENTRY_AUTH_TOKEN, SENTRY_ORG and SENTRY_PROJECT repository secrets. Until all three are set, the upload step is skipped. See docs/sentry.md for where to find each value.

Testing

  • Unit tests: 1081 pass, including the new sentry.spec.ts. Lint and type checks pass.
  • In a local PlaceOS stack, with the localhost check removed for the test: the session, spans, one error event and the replay all got HTTP 200. The event had the correct release and the user ID only.
  • After sentry-cli sourcemaps inject, ngsw-rehash.js gives the same hashes as Angular's ngsw-config. On a fresh build it changes nothing.
  • The CI upload has not run yet, because the secrets are not set.

The Sentry chunk is about 120 kB gzip and loads after sign-in. Most of it is replay.

Reviewed with sol-loop: 2 rounds with gpt-6.1-sol on xhigh.

Made by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

Sentry has not sent anything since 2020, when Sentry.init was removed.

- Load @sentry/angular after sign-in, so it is not in the initial bundle.
  Errors from before it loads are queued.
- Read the DSN from the authority config.backoffice.sentry_dsn, with the
  PlaceOS default. '' or false turns it off.
- Send errors, 10% of traces and replays of sessions with an error.
  Send only the user ID.
- Upload hidden source maps in CI when the SENTRY_* secrets are set, and
  update the service worker hashes after debug IDs are injected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

Deployment failed for project backoffice with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/placeos?upgradeToPro=build-rate-limit

@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The reviewed update appears safe to merge; it fixes the hidden startup warning without introducing a new issue.

Summary

Restores Sentry error reporting after sign-in, with domain settings, queued errors, traces, and masked replays.

  • Backoffice sends app errors and selected session data to Sentry.
  • Production errors can show their original code in Sentry.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Angular error handler] --> B[Log to console]
    A --> C[Queue up to 20 errors]
    D[User signs in] --> E{Sentry enabled?}
    E -->|No| F[Discard queued errors]
    E -->|Yes| G[Load and start Sentry]
    G --> H[Send queued and future errors]
    G -->|Startup fails| I[Always show console warning]
Loading

Reviews (3) · Last reviewed commit: "fix: always log when Sentry fails to sta..." · Reviewed by Greptile

Comment thread src/app/app.ts
MrYuion and others added 2 commits October 27, 2026 16:22
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MrYuion
MrYuion merged commit b990dbc into develop Oct 27, 2026
6 of 7 checks passed
@MrYuion
MrYuion deleted the t3/review-sentry-usage branch October 27, 2026 05:34
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