ErrTapDOCS

Node.js SDK

Install @errtap/node, wire up Express or plain HTTP handlers, and capture exceptions and messages in your Node.js application.

Install

npm i @errtap/node

Initialise

Call init as early as possible — before any other imports that might throw:

import { init } from '@errtap/node';

init({
  dsn: 'https://et_<key>@your-host',
  environment: 'production',
  release: process.env.APP_VERSION,
});

Express integration

Wrap your app with the request and error handlers:

import express from 'express';
import { init, requestHandler, errorHandler } from '@errtap/node';

init({ dsn: 'https://et_<key>@your-host' });

const app = express();

// Must be the first middleware
app.use(requestHandler());

// ... your routes here ...

// Must be the last middleware, after all route handlers
app.use(errorHandler());

app.listen(3000);

requestHandler captures each request's context so that errors are tagged with the correct URL, method, and user.

errorHandler catches any error passed to next(err) and forwards it to ErrTap before re-throwing.

Capture helpers

import { captureException, captureMessage } from '@errtap/node';

try {
  await doSomethingRisky();
} catch (err) {
  captureException(err, {
    tags: { job: 'invoice-sync' },
    context: { invoiceId: inv.id },
  });
}

captureMessage('stripe webhook skipped', { level: 'warning' });

API

captureException(error, options?)

FieldTypeDescription
tagsRecord<string, string>Merged with init-level tags
contextRecord<string, unknown>Arbitrary extra data
level'error' | 'warning' | 'info'Defaults to 'error'
fingerprintstringOverrides automatic grouping
releasestringOverrides init-level release
user{ id?, email?, name? }Attaches user to this event

captureMessage(message, options?)

Same options shape as captureException.

beforeSend

init({
  dsn: 'https://et_<key>@your-host',
  beforeSend(event) {
    // Scrub PII before sending
    if (event.request?.headers?.authorization) {
      event.request.headers.authorization = '[Filtered]';
    }
    return event;
  },
});

Return null to drop the event entirely.

Release & environment

init({
  dsn: 'https://et_<key>@your-host',
  release: process.env.APP_VERSION ?? 'dev',
  environment: process.env.NODE_ENV ?? 'development',
});

ErrTap uses release to detect regressions: if an issue was resolved in v1.4.2 and reappears in v1.4.3, it is automatically reopened.