ErrTap / DevelopersDocumentation
ErrTap docsplatforms / nodejs

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

The package does not install Express middleware. Capture in your existing error middleware and pass request context on that call:

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

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

const app = express();

// ... your routes here ...

app.use((err, req, res, next) => {
  void captureException(err, {
    url: req.originalUrl,
    tags: { method: req.method },
  });
  next(err);
});

app.listen(3000);

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.

Use logger.debug, logger.info, logger.warn/warning, and logger.error for structured logs. Dynamic request/user context belongs on each call; the Node SDK deliberately does not keep global breadcrumbs or mutable request context.

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.

On this page