Node.js and Express Setup

Integrate the Errova core JavaScript SDK in Node.js services and add Express request-aware error capture.

For standalone Node.js services, background workers, CLI jobs, and custom HTTP servers, use @errova/sdk. For backend traffic, use server-signed DSNs (recommended) so requests are verifiable end-to-end.

Bash
npm install @errova/sdk

Basic Service Initialization

TypeScript
import { captureException, init } from "@errova/sdk"
init({
dsn: process.env.ERROVA_DSN ?? "",
dsnSecret: process.env.ERROVA_DSN_SECRET,
environment: process.env.NODE_ENV,
release: process.env.APP_VERSION,
})
try {
throw new Error("Node smoke test event")
} catch (error) {
captureException(error, {
tags: {
service: "api",
},
})
}

Express Integration

Express helpers add request-scoped context and sanitize captured request details before they are attached to events.

TypeScript
import express from "express"
import {
expressErrorHandler,
expressRequestHandler,
} from "@errova/sdk/integrations/express"
import { init } from "@errova/sdk"
init({
dsn: process.env.ERROVA_DSN ?? "",
dsnSecret: process.env.ERROVA_DSN_SECRET,
})
const app = express()
app.use(express.json())
app.use(
expressRequestHandler({
includeRequestBody: false,
})
)
app.get("/boom", () => {
throw new Error("Route exploded")
})
app.use(
expressErrorHandler({
includeRequestBody: true,
maxBodyLength: 4096,
redactHeaderKeys: ["authorization", "cookie"],
redactBodyKeys: ["password", "token", "secret"],
})
)

Operational Notes

  • autoCapture is enabled by default, so uncaught exceptions and unhandled rejections are captured automatically.
  • Use request-body capture sparingly and redact aggressively. See Privacy, Redaction, and Data Hygiene.
  • Short-lived jobs should flush before exit if they can terminate before the normal batch interval.
  • If you see duplicate storms, review SDK Burst Guard.