Skip to content

SDK options

release, environment, sampling, ignoring errors, opt-in breadcrumbs and attachments, delivery and queue limits.

Markdown
On this page

Options for init (browser, React, TanStack Start client) and for the withBelvador callback (Cloudflare Workers, TanStack Start server). Every option except dsn is optional. Invalid values fall back to the default instead of throwing.

Common options#

OptionTypeDefaultWhat it does
dsnstring— (required in the browser)The project DSN. On Workers it can come from BELVADOR_DSN instead.
releasestringnot setYour app's version (build number, commit). Used to find regressions and to match source maps.
environmentstring"production"production, staging, preview… Shown and filterable on issues.
diststringnot setA build variant within one release, if you ship several.
sampleRatenumber 0–11Share of error events to send. 0.25 sends about a quarter.
ignoreErrors(string | RegExp)[][]Errors to drop. A string matches part of the message; a RegExp is tested against it.
captureAbortedbooleanfalseAlso report work the visitor cancelled: an AbortError (or an error caused by one), or a server error thrown after the client disconnected. Off because a closed tab is not a bug. A TimeoutError is always reported. Since 0.2.0.
tracePropagation{ targets: (string | RegExp)[], baggage?: boolean }offAdd traceparent and sentry-trace headers to requests to these URLs, so errors and job runs across your services link up. See Link errors across tiers. Since 0.3.0.
beforeSend(event, hint) => event | nullnot setChange or drop an event. Return null to drop. May return a promise.
beforeBreadcrumb(crumb, hint) => crumb | nullnot setChange or drop a breadcrumb.
maxBreadcrumbsnumber 0–10050How many recent breadcrumbs travel with an event.
attachmentsbooleanfalseAllow attachments to be sent. Off means attachments are dropped in your app.
privacyPolicyprivacyPolicy(json)not setApply the project's privacy rules in your app too, from Copy as code on the Privacy page. Your node applies them either way. See Data protection. Since 0.6.0.
previewbooleanfalsePrint each envelope as it would be sent and send nothing. On servers BELVADOR_PREVIEW=1 does the same. Since 0.6.0.
debugbooleanfalseLog the SDK's decisions to the console. Turn off again for production.
disabledbooleanfalseKeep the SDK off, for example in tests.

beforeSend and beforeBreadcrumb run before Belvador's mandatory scrubbing, so they cannot add data the scrubber would remove. If a hook throws or its promise rejects, that event or breadcrumb is dropped.

TypeScript
init({  dsn: "https://<public-key>@ingest.belvador.dev/<project-id>",  release: import.meta.env.VITE_APP_VERSION,  environment: import.meta.env.MODE,  sampleRate: 1,  ignoreErrors: ["ResizeObserver loop completed with undelivered notifications"],  beforeSend(event) {    // Drop errors from an internal admin tool.    if (event.request?.url?.includes("/internal-admin/")) return null;    return event;  },});

Breadcrumbs are the steps before an error. Automatic breadcrumbs are off in Belvador's SDKs: they record what users click and which URLs they call, which can include personal data. Turn on only what you need.

Browser (@belvador/browser, @belvador/react, TanStack Start client):

TypeScript
init({  dsn: "https://<public-key>@ingest.belvador.dev/<project-id>",  instrument: { console: true, dom: true, fetch: true, xhr: true, history: true },});

Workers (withBelvador callback): instrument: { console: true, fetch: true }.

Breadcrumbs you add with addBreadcrumb are always recorded and need no option.

Browser-only options#

OptionDefaultWhat it does
instrumentall offAutomatic breadcrumbs, see above.
wrapBrowserApisfalseWraps timers, requestAnimationFrame and event listeners so errors inside them carry more context.
allowUrlsallOnly report errors whose stack comes from these script URLs (strings or RegExps).
denyUrlsnoneIgnore errors from these script URLs. Browser extension URLs are always ignored.
captureViewTransitionSkipsfalseAlso report a View Transition the browser skipped on purpose (page hidden, another transition started, skipTransition()). Off because the browser is working as designed. Since 0.3.0.
offlinefalseKeep errors that fail on the network in this browser (IndexedDB) and send them when it is back online or on the next load. See Offline and durable delivery. Since 0.6.0.

Workers-only behaviour#

The withBelvador callback returns the same options without a required dsn, plus instrument: { console, fetch }. Values not returned come from Worker variables:

SettingTaken from, in order
DSNcallback dsn → BELVADOR_DSN
Releasecallback release → BELVADOR_RELEASE → CF_VERSION_METADATA.id
Environmentcallback environment → BELVADOR_ENVIRONMENT → production
Off switchcallback disabled → BELVADOR_DISABLED = 1 or true

Fixed by Belvador#

These cannot be changed, so the SDK sends only errors and never adds personal data on its own:

  • personal data from the SDK (sendDefaultPii) is always off;

  • tracing, session replay, logs and profiling are off and their data is dropped;

  • no tunnel, no Spotlight, no default integrations beyond what Belvador sets up;

  • string values are cut at 8,192 characters.

How sending works#

RuleValue
Waiting to be sentat most 30 envelopes, 1 MiB in total (6 MiB with attachments)
One attachmentat most 5 MiB
One attemptaborted after 10 seconds
Network errors and 500/502/503/504up to 5 attempts; each wait is random, below 1, 2, 4, then 8 seconds (full jitter, since 0.6.0); the same envelope and event id every time
503 with Retry-Afterwaits as asked, up to 60 seconds
429follows the rate-limit headers: new events of that kind are dropped in your app until the limit lifts
401 / 403the key is invalid or revoked: sending stops for the life of the page or Worker isolate
Storagememory only — nothing is written to disk or localStorage, unless you turn on offline (browser) or use @belvador/spool (servers)

When a page is closing, the SDK sends with keepalive within the browser's limits (up to 60,000 bytes, 15 requests at a time). Events that do not fit, or that are still waiting when the page closes, are lost — unless offline: true keeps them for the next load.

Posts on this topic

All posts

Spotted something wrong or missing? Tell us: hello@belvador.dev