ErrTap / DevelopersDocumentation
ErrTap docsplatforms / browser

Browser SDK

Install @errtap/browser, auto-capture unhandled errors and promise rejections, and send custom events with captureException and captureMessage.

Install

npm i @errtap/browser

Initialise

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

init({
  dsn: 'https://et_<key>@your-host',
  environment: 'production',
  release: '1.4.3',          // enables regression detection + source maps
  tags: { team: 'checkout' } // attached to every event
});

init hooks window.onerror and unhandledrejection automatically. Capture handled errors yourself:

try { risky(); } catch (e) {
  captureException(e, { tags: { flow: 'checkout' } });
}
captureMessage('payment fallback used', { level: 'warning' });

API

captureException(error, options?)

Reports a caught Error object. options accepts:

FieldTypeDescription
tagsRecord<string, string>Key/value tags merged with init-level tags
contextRecord<string, unknown>Arbitrary extra context
level'error' | 'warning' | 'info'Defaults to 'error'
fingerprintstringOverrides automatic grouping key
releasestringOverrides the release set at init

captureMessage(message, options?)

Reports a string message. Accepts the same options as captureException.

logger

Send structured logs with call-specific context:

import { logger } from '@errtap/browser';

await logger.info('checkout started', { orderId: 'ord_1' });

Available levels are debug, info, warn/warning, and error. Pass user, request, or other dynamic context on each capture/log call; the SDK does not keep mutable global user/context state.

Release & environment

Set release and environment at init. ErrTap uses release for:

  • Regression detection — an issue that was resolved in release 1.4.2 reopens if it reappears in 1.4.3.
  • Source map lookup — uploaded maps are keyed by release so frames are de-minified before grouping.
init({
  dsn: 'https://et_<key>@your-host',
  release: '1.4.3',
  environment: 'production',
});

Source maps (de-minify stack traces)

Production bundles are minified, so raw frames read like app.min.js:1:35060. ErrTap de-minifies them at ingest when it has your build's source maps for that release.

  1. Have your bundler emit source maps (e.g. Vite build.sourcemap: true, webpack devtool: 'source-map').

  2. After each build, POST the .js.map files to /ingest/sourcemaps under the same release you pass to init(), then delete them so they aren't served publicly:

    curl -X POST https://your-host/ingest/sourcemaps \
      -H "Authorization: DSN et_<key>" \
      -H "Content-Type: application/json" \
      -d '{"release":"1.4.3","files":[{"filename":"app.min.js","map":"<contents of app.min.js.map>"}]}'

    filename is the basename of the minified .js (not the .map) — that's the key symbolication matches against. Batches are capped at 50 files / 10MB.

On Next.js, @errtap/next ships an errtap-upload-sourcemaps command that does all of this for you — see the Next.js guide.

On this page