SaaS Starter
Integrations

Sentry

Wire Sentry as the error reporter for both the Bun + Express server and the Next.js client. Server uses @sentry/bun, client uses @sentry/nextjs.

Status: scaffold. Fill in the sections below before publishing. The wiring exists in code; this page is the operator-facing summary.

What you get

UseDeploy's infrastructure/observability module ships Sentry as a first-class error reporter alongside Pino logs and OpenTelemetry traces. The two SDKs are intentionally split:

  • Server: @sentry/bun — boots before Express loads so auto-instrumentation attaches to every route.
  • Client: @sentry/nextjs with instrumentation-client.ts and instrumentation.ts for App Router source-map and event support.

logger.error(...) does NOT auto-capture to Sentry. Use the captureError(err, ctx) helper for errors that should page someone — see infrastructure/observability/sentry.ts.

Setup

1. Create the projects

In the Sentry dashboard, create two projects:

  • One Node project for the API server (use the bun runtime label if available).
  • One Next.js project for the client.

Grab the DSN for each.

2. Set env vars

# apps/server/.env
SENTRY_DSN_SERVER="https://<key>@o<org>.ingest.sentry.io/<project>"
SENTRY_TRACES_SAMPLE_RATE=0.1
SENTRY_ENV=production

# apps/client/.env
NEXT_PUBLIC_SENTRY_DSN_CLIENT="https://<key>@o<org>.ingest.sentry.io/<project>"
SENTRY_AUTH_TOKEN=...   # for source-map upload at build time

The server boots to a no-op when SENTRY_DSN_SERVER is unset, so local dev needs zero config.

3. Smoke test

Trigger a known error path and verify it shows up in the Sentry dashboard within a minute. The recommended smoke test is to hit /api/v1/__diag/throw (only mounted in non-production) and confirm both the OTel span and the Sentry event correlate via the trace_id tag.

Where it lives in the codebase

  • apps/server/src/infrastructure/observability/sentry.ts — server boot + helper
  • apps/server/src/otel-init.ts — OTel must boot before Sentry; do not reorder
  • apps/client/instrumentation.ts + instrumentation-client.ts — Next App Router source-map and client-side init

On this page