Skip to content

Add Sentry error monitoring (backend, frontend, SSR)#16

Merged
andreogle merged 2 commits into
mainfrom
sentry-error-monitoring
Jun 19, 2026
Merged

Add Sentry error monitoring (backend, frontend, SSR)#16
andreogle merged 2 commits into
mainfrom
sentry-error-monitoring

Conversation

@andreogle

Copy link
Copy Markdown
Owner

Errors-only Sentry integration, opt-in via env vars — inert without a DSN, so dev/test/local report nothing.

Backend

  • sentry + hackney deps; Sentry.PlugCapture (above use Phoenix.Endpoint) and Sentry.PlugContext (after Plug.Parsers).
  • Sentry.LoggerHandler attached at boot — captures Bandit request crashes and Oban job failures.
  • ElixirReactStarter.Sentry enforces the no-PII rule: before_send strips the user's email (keeps the id for correlation), and a PlugContext body scrubber drops email/token/code/password params. Unit-tested.

Frontend

  • @sentry/react, initialised from nonce-safe <head> meta tags (works under the strict CSP), surfaced via SharedDataroot.html.heex.
  • ErrorBoundary reports caught render errors.

SSR

  • @sentry/node in the Inertia SSR Node workers; render is now async and routes failures through go(), reporting before re-raising so Inertia's own fallback is unchanged.

Source maps

  • External maps in assets.deploy, uploaded best-effort via @sentry/cli (build/upload-sourcemaps.js), then deleted before phx.digest so they're never served.
  • Backend source context packaged in the Dockerfile (mix sentry.package_source_code).

Config

  • All opt-in: backend SENTRY_DSN, frontend SENTRY_DSN_FRONTEND, SSR SENTRY_DSN_SSR (falls back to the frontend DSN).
  • Deploy tier from DEPLOY_ENV (distinct from MIX_ENV); release defaults to RENDER_GIT_COMMIT, overridable via SENTRY_RELEASE.

Also

  • Documented two TS style conventions in CLAUDE.md (extract multi-line go()/goSync() callbacks; multi-line bodies use braces + return) and applied them across assets/js.
  • Excluded the routes.gen mix task from coverage (pure tooling, exercised by precommit), like the other custom tasks. Coverage: 92.71% total, above the 90% threshold.

Verified: mix precommit green (credo, biome, i18n, route drift, 204 tests), both asset bundles build.

🤖 Generated with Claude Code

Errors-only Sentry integration, opt-in via env vars — inert without a DSN,
so dev/test/local report nothing.

- Backend: sentry + hackney deps, Sentry.PlugCapture/PlugContext, and the
  Sentry.LoggerHandler (captures Bandit request crashes + Oban job
  failures). ElixirReactStarter.Sentry enforces the no-PII rule via
  before_send and a PlugContext body scrubber (unit-tested).
- Frontend: @sentry/react, init from a nonce-safe meta tag (works under the
  strict CSP); ErrorBoundary reports caught render errors.
- SSR: @sentry/node in the Inertia SSR workers, reporting render failures
  before re-raising so Inertia's fallback is unchanged.
- Source maps: external maps in assets.deploy, uploaded via @sentry/cli
  (build/upload-sourcemaps.js, best-effort) then deleted before phx.digest;
  backend source context packaged in the Dockerfile.
- SENTRY_RELEASE defaults to RENDER_GIT_COMMIT; environment from DEPLOY_ENV.

Also document two TS style conventions in CLAUDE.md (extract multi-line
go()/goSync() callbacks; multi-line bodies use braces + return) and apply
them across assets/js, and exclude the routes.gen mix task from coverage
(pure tooling, exercised by precommit) like the other custom tasks.
unmatched_return: Logger.add_handlers/1 returns :ok | {:error, _}. The
:logger handler config is static (config/config.exs) so it always returns
:ok; match it explicitly to document that and fail loudly on a genuine
misconfig.
@andreogle andreogle merged commit 9771e47 into main Jun 19, 2026
2 checks passed
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