ErrTapDOCS

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.

setUser(user)

Attaches user identity to all subsequent events:

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

setUser({ id: 'u_193', email: 'alice@example.com' });

Pass null to clear.

setContext(key, value)

Attaches a named context object:

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

setContext('cart', { items: 3, total: 49.99 });

setTag(key, value)

Attaches a single tag:

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

setTag('plan', 'pro');

beforeSend

Filter or enrich events before they leave the browser:

init({
  dsn: 'https://et_<key>@your-host',
  beforeSend(event) {
    // return null to drop the event
    if (event.tags?.flow === 'debug') return null;
    return event;
  },
});

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',
});