Skip to content

Framework guide

Error tracking for Node.js

For Node.js servers Belvador uses the official Sentry SDK with your Belvador DSN, plus init options and a scrubbing hook that strip request bodies, cookies and credentials before anything leaves your server.

Start freeNode.js

Updated Oct 25, 2026

The short answer#

  • Use the official @sentry/node SDK with your Belvador DSN.

  • Belvador's init options and scrubbing hook strip request bodies, cookies and credentials before sending.

  • Cron jobs report check-ins with Sentry.withMonitor(), and OpenTelemetry traces link to errors.

  • This is a compatibility setup: Belvador tests its hook, not the Sentry SDK itself.

Install#

Terminal
npm install @sentry/node@11.9.0 @belvador/core@0.6.1

Create instrument.mjs#

instrument.mjs
import * as Sentry from "@sentry/node";import { scrubBreadcrumb, scrubEvent } from "@belvador/core/sentry";Sentry.init({  dsn: process.env.BELVADOR_DSN ?? "https://<public-key>@ingest.belvador.dev/<project-id>",  release: process.env.APP_VERSION,  environment: process.env.NODE_ENV,  sendDefaultPii: false,  tracesSampleRate: 0,  maxBreadcrumbs: 50,  maxValueLength: 8192,  // Belvador's scrubbing: request bodies, cookies and credentials never leave the app.  beforeSend: scrubEvent,  beforeBreadcrumb: scrubBreadcrumb,});

Load it first#

Terminal
node --import ./instrument.mjs server.js

Loading the file before your app lets the SDK instrument your framework. The Node.js guide explains every option.

What this setup is#

A compatibility setup, not a Belvador package. Belvador's tests run the scrubbing hook on hostile data, but Belvador does not certify @sentry/node itself or its framework integrations. Your node scrubs again before storing anything (data protection).

Cron jobs and workers#

JavaScript
import * as Sentry from "@sentry/node";await Sentry.withMonitor("nightly-invoices", async () => {  // Your job.}, { schedule: { type: "crontab", value: "0 2 * * *" }, timezone: "UTC" });

A job that fails, runs too long or never starts opens an incident (cron monitoring).

Traces and logs#

Add the OpenTelemetry Node SDK with the standard OTLP exporter; with Sentry and OpenTelemetry together, errors carry the trace id of the request they happened in (OpenTelemetry for Node.js).

Tested on 2026-10-24 with node 22.23.4, @opentelemetry/sdk-node 0.300.0, @opentelemetry/auto-instrumentations-node 0.82.0, pino 10.4.0: traces passed, logs passed, logs carry the request's trace and span.

Limits#

  • Supported Node.js versions follow the current @sentry/node release.

  • No profiling and no performance dashboards; traces are kept for debugging.

Questions#

Can I keep sending to Sentry while I test?#

Yes, with a second SDK client or a second environment. Switching back is a DSN change.

Try it on your own Hetzner project

Free during the beta. Hetzner bills the server; Belvador never bills per event.