Browser SDK
Install @errtap/browser, auto-capture unhandled errors and promise rejections, and send custom events with captureException and captureMessage.
Install
npm i @errtap/browserInitialise
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:
| Field | Type | Description |
|---|---|---|
tags | Record<string, string> | Key/value tags merged with init-level tags |
context | Record<string, unknown> | Arbitrary extra context |
level | 'error' | 'warning' | 'info' | Defaults to 'error' |
fingerprint | string | Overrides automatic grouping key |
release | string | Overrides 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.2reopens if it reappears in1.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.
-
Have your bundler emit source maps (e.g. Vite
build.sourcemap: true, webpackdevtool: 'source-map'). -
After each build, POST the
.js.mapfiles to/ingest/sourcemapsunder the samereleaseyou pass toinit(), 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>"}]}'filenameis 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/nextships anerrtap-upload-sourcemapscommand that does all of this for you — see the Next.js guide.