ScaleBun
Skip to article

Errors & crashes

webDeveloper

Capture uncaught errors and crashes automatically, or report them yourself with captureError — with breadcrumbs, parsed stack frames, fingerprinting, and replay linkage.

Updated Reviewed

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#

TypeScript
ScaleBun.captureError(error, {  level: 'warning',            // fatal | error | warning | info  tags: { feature: 'checkout' },  context: { orderId: 42 },  fingerprint: 'checkout-failure',  componentStack: info.componentStack,});

Breadcrumbs are the trail attached to whatever error happens next — they turn "it threw here" into "here is what the user did first."

TypeScript
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.

TypeScript
ScaleBun.setTag('plan', 'enterprise');      // searchableScaleBun.setContext('cart', { items: 3 });  // arbitrary structured dataScaleBun.setErrorLevel('warning');          // default severity for what follows

A 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.

TypeScript
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,  },});
OptionDefaultWhat it does
ignoreErrorsDrop by message. Merged with the built-in benign noise, never replacing it.
denyUrlsDrop by originating script URL — browser extensions, third-party tags.
captureResourceErrorsfalseCapture failed image/script/CSS loads as resource errors. Usually noise, never JS crashes.
maxBreadcrumbs50Ring size, capped at 200.
sampleRate1Fraction of sessions whose automatic errors are kept. captureError always fires.
beforeSendTransform, or return null to drop. Throwing is safe — the original is kept.
beforeBreadcrumbSame, 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:

TypeScript
const id = await ScaleBun.reportBug({  message: 'checkout button dead',  email: 'a@b.co',});

Next#

Errors & crashes · Web SDK · ScaleBun