Errors & crashes
Capture uncaught errors and crashes automatically, or report them yourself with captureError — with breadcrumbs, parsed stack frames, fingerprinting, and replay linkage.
Error and crash monitoring is on by default. Uncaught errors and unhandled
promise rejections are captured automatically, with parsed stack frames
(source-map ready), fingerprinting, error.cause / AggregateError walking, and
a link to the session replay when one exists.
Report an error yourself#
ScaleBun.captureError(error, { level: 'warning', // fatal | error | warning | info tags: { feature: 'checkout' }, context: { orderId: 42 }, fingerprint: 'checkout-failure', componentStack: info.componentStack,});Breadcrumbs#
Breadcrumbs are the trail attached to whatever error happens next — they turn "it threw here" into "here is what the user did first."
ScaleBun.addBreadcrumb({ category: 'custom', message: 'payment submitted', data: { amount: 99 },});Console output is captured as breadcrumbs automatically. The ring is bounded
(50 by default, 200 maximum) so calling addBreadcrumb liberally is safe.
Scope#
Tags and context set once are merged into every subsequent error, which is usually what you want for values that describe the user rather than the failure.
ScaleBun.setTag('plan', 'enterprise'); // searchableScaleBun.setContext('cart', { items: 3 }); // arbitrary structured dataScaleBun.setErrorLevel('warning'); // default severity for what followsA level, tags, context or fingerprint passed to captureError overrides
the scope for that one call.
Tuning what gets captured#
All optional — the defaults need no configuration.
await ScaleBun.init({ clientKey, apiBaseUrl, errors: { ignoreErrors: ['ResizeObserver loop', /^Script error/], denyUrls: [/chrome-extension:\/\//], captureResourceErrors: false, maxBreadcrumbs: 50, sampleRate: 1, beforeSend: (item) => (item.message.includes('secret') ? null : item), beforeBreadcrumb: (crumb) => crumb, },});| Option | Default | What it does |
|---|---|---|
ignoreErrors | — | Drop by message. Merged with the built-in benign noise, never replacing it. |
denyUrls | — | Drop by originating script URL — browser extensions, third-party tags. |
captureResourceErrors | false | Capture failed image/script/CSS loads as resource errors. Usually noise, never JS crashes. |
maxBreadcrumbs | 50 | Ring size, capped at 200. |
sampleRate | 1 | Fraction of sessions whose automatic errors are kept. captureError always fires. |
beforeSend | — | Transform, or return null to drop. Throwing is safe — the original is kept. |
beforeBreadcrumb | — | Same, for breadcrumbs entering the ring. |
Crash detection#
Beyond thrown errors, the SDK detects crashes via ReportingObserver and a
session-liveness recovery check — a session that stops sending heartbeats is
reconstructed as a crash on the next load. This is always on; there is no API to
call.
Bug reports#
Let a user file a report with session evidence attached automatically:
const id = await ScaleBun.reportBug({ message: 'checkout button dead', email: 'a@b.co',});Next#
Performance — Web Vitals and route transactions.
Troubleshooting — diagnostics and gotchas.