Tutorials / Backend integrations / Set up Sentry error tracking
πŸ“ Written ● Beginner Updated 2026-05-13

Set up Sentry error tracking

Catch errors in production before users have to tell you. Sign up, install the SDK, paste a DSN, ship. Five minutes for a usable setup; another fifteen for source maps and releases.

What you need

0

Create a project

1

In sentry.io β†—, click Projects β†’ Create Project. Pick your platform (e.g., "Node.js", "Next.js"). Name it. Click Create Project.

Sentry shows you the DSN β€” a URL that looks like:

https://[email protected]/678901

Copy it. Store in your backend env:

SENTRY_DSN=https://[email protected]/678901

The DSN is not secret in the way an API key is β€” it's safe in client-side bundles β€” but treat it as configuration.

Install the SDK (Node example)

2
npm install --save @sentry/node

Other runtimes: npm install @sentry/react, pip install --upgrade sentry-sdk, etc. Check the platform-specific page from Step 0.

Initialize as early as possible

3

Initialize Sentry before your app does anything else. In Node, that's the very first line of your entrypoint:

// Must be the FIRST import in your app's entry file
const Sentry = require("@sentry/node");

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  tracesSampleRate: 1.0,   // 100% perf monitoring while you're learning; lower later
  environment: process.env.NODE_ENV || "development",
});

// ... rest of your app

For browser JS / Next.js / Python, the shape is the same: Sentry.init({ dsn: ..., ... }), called once at startup. Each platform's docs (Step 0) shows where exactly.

Send a test error

4

Throw something on purpose to confirm Sentry is wired up:

Sentry.captureException(new Error("Sentry test from my app"));

Or trigger an actual uncaught error β€” Sentry installs global handlers automatically, so any uncaught exception or unhandled promise rejection is reported without you doing anything.

Go to sentry.io β†’ Issues β†—. Your test error should appear within a few seconds. Click it to see the stack trace, request context, breadcrumbs.

If the error doesn't show up: check Sentry β†’ Settings β†’ Quotas β†— (you might have already used your free tier elsewhere) and confirm the DSN matches the project you're viewing. SDK init silently no-ops on a bad DSN.

Track releases (so you know which version broke)

5

Pass your app's version to Sentry. Now every error is tagged with which release it came from β€” you can see "this bug appeared in 1.4.2."

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  release: "myapp@" + process.env.APP_VERSION,  // e.g. [email protected]
  environment: process.env.NODE_ENV,
});

Combine with the Sentry CLI β†— in your deploy pipeline to create release records:

sentry-cli releases new "myapp@$APP_VERSION"
sentry-cli releases finalize "myapp@$APP_VERSION"

Upload source maps (for readable stack traces in JS)

6

Production JS is minified. Without source maps, your Sentry stack traces look like a.b.c at e.min.js:1:1234 β€” useless.

The official wizards do this for you:

# Next.js
npx @sentry/wizard@latest -i nextjs

# React (Vite)
npx @sentry/wizard@latest -i sourcemaps

Or manually with sentry-cli sourcemaps β†—. Native iOS/Android: the SDKs handle dSYMs / mapping files automatically via Gradle/CocoaPods plugins.

Filter what you don't want to track

7

Once errors start flowing, you'll see noise (Chrome extension errors, expected validation errors, dev-mode bugs). Filter:

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  beforeSend(event, hint) {
    // Skip dev errors
    if (process.env.NODE_ENV === "development") return null;
    // Skip known noise
    const err = hint.originalException;
    if (err && err.message && err.message.includes("ResizeObserver loop")) {
      return null;
    }
    return event;
  },
  ignoreErrors: [
    "ResizeObserver loop limit exceeded",
    /^Network request failed$/,
  ],
});

Each ignored pattern saves event quota and reduces alert noise. Tune over time.

Set up alerts

8

Default project settings already email you on new issues. To configure:

Sentry β†’ your project β†’ Alerts β†’ Create Alert. Common rules:

  • Spike alert β€” fires when a single issue's event count exceeds a threshold (e.g., 100 events in 1 hour).
  • New issue alert β€” fires when a new error type appears in production.
  • Regression alert β€” fires when a previously-resolved issue reappears in a newer release.

Route to Slack / PagerDuty / email via the alert integrations. Alerts docs β†—.

What's in an issue page

9

Click any issue in the dashboard:

  • Stack trace with code context (the surrounding lines, not just file:line).
  • Breadcrumbs β€” the last N user/system events before the error (clicks, network requests, console logs).
  • Tags β€” environment, release, OS, browser, user ID.
  • Affected users β€” distinct user count (anonymous or identified).
  • Session Replay (if enabled) β€” actual video-like replay of what the user did before the error. Session Replay β†—.
Don't log PII to Sentry. Stack traces are fine; passwords, full credit cards, government IDs in error messages are not. Use beforeSend to scrub, or set sendDefaultPii: false (the default). Sensitive data docs β†—.

Pricing reality check

10

Free tier: 5,000 errors + 10,000 performance events + 50 replays per month. Real production apps hit this fast if you have any uncaught error in a hot loop.

Paid tiers start around $26/mo for Team. Worth it once your app has real users. Sentry pricing β†—.

Self-hosted alternative: Sentry's source is open. You can self-host β†—, but the operational burden is real (Docker Compose, ClickHouse, Postgres, Redis). Most people don't.

Official references

What's next