ScaleBun
Skip to article

Configuration

webDeveloper

Every option accepted by ScaleBun.init(), with defaults read from the SDK's own config resolver.

Updated Reviewed

init() takes one object. Only clientKey and apiBaseUrl are required.

Top-level options#

Defaults are read from resolveConfig() — the function that applies them — not from a doc comment.

OptionTypeDefaultWhat it does
clientKeystringRequiredSaaS SDK key — sent as x-scalebun-client-key.
apiBaseUrlstringRequiredBackend base URL, e.g. https://api.scalebun.com/api/v1
environmentstring
releasestring
appVersionstring
cspobjectContent-Security-Policy options. nonce is applied to every / the SDK injects, so strict-CSP sites (style-src/script-src without 'unsafe-inline') work. Optional — absent = today's behavior. On a -tag install the SDK also auto-detects the nonce from its own tag. See csp.
flushIntervalMsnumber5000
sessionTimeoutMsnumberInactivity after which the next page load starts a NEW session (default 30 min).
sessionMaxDurationMsnumberAbsolute cap on one session (default 24 h), so a permanently-open tab cannot report an endless session.
maxBatchSizenumber50
maxQueueSizenumber1000
replayobjectSession-replay sampling. Deterministic per-session decision (the SDK buckets the sessionId with the same fnv1a as flags/experiments, so the backend can re-derive it — no client trust). - 'sampled' (DEFAULT): record the FULL session from the first frame for sampleRate of sessions (default 1 = every session, like the mobile SDK). Dial sampleRate down to control volume. - 'onError': record into a rolling pre-roll buffer, flush it only when an error/rage/report signal fires (cost-saver — ships only sessions that hit a problem). onErrorSampleRate gates it. - 'always': record every session from start, ignoring sampleRate. 'off': never record. A session that isn't sampled installs NOTHING (zero overhead). See replay.
replayCanvasbooleanfalseOpt-in: capture pixels in replay (off by default — pixels can't be masked).
signSessionLanebooleanfalseOpt-in: HMAC-sign session/replay batches too (the analytics lane always signs). Off by default — signing multi-MB replay uploads re-enables server-side rawBody double-buffering.
replayFrameOriginsstring[][]Cross-origin replay stitching (F-IFR P2): origins the parent bridges + a child trusts. Both the parent page and the cross-origin child must run the SDK with each other's origin listed. e.g. parent lists ['https://embed.example.com'], child lists ['https://app.example.com'].
autocapturebooleantrueAutocapture DOM interactions as analytics events (on by default; text masked). Set false to opt out.
tracePropagationbooleantrueInject a W3C traceparent into outbound requests for FE→BE trace correlation. Default true (same-origin only — safe). Set false to disable entirely.
tracePropagationOriginsstring[][]Cross-origin origins to ALSO propagate the traceparent to (the server must CORS-allow the traceparent header). e.g. ['https://api.example.com'].
errorsobjectError capture tuning (F-ERR). All optional — defaults need no config. See errors.
networkobjectNetwork capture tuning (F-NET). All optional — defaults need no config. See network.
performanceobjectPerformance / RUM tuning (transactions, spans). All optional — defaults need no config. See performance.
watchdogobjectW5.2 — Resource Watchdog tuning (continuous resource sampling → local incidents). All optional. See watchdog.
exitIntentobject#25 P2 — exit-intent scroll-reversal thresholds. All optional; omitted keys use REVERSAL_DEFAULTS. See exitIntent.
analyticsobjectProduct-analytics tuning. All optional — analytics works with none of this set. See analytics.
flagsobjectFeature-flag / config options. See flags.
featuresScaleBunFeatures
privacyPrivacyConfig
bugReportOptionsBugReportOptionsBug-report widget (F-BUG) options. The feature is enabled via features.bugReport; these tune the optional embeddable launcher. Default: launcher off (programmatic reportBug() only).
engageOptionsEngageOptionsEngage options.
pushobjectWeb Push options. See push.
requireConsentbooleanConsent-mode (GDPR/CIPA). When true, the SDK captures + sends NOTHING until the host calls ScaleBun.setConsent(true) (typically from a CMP callback). Default false = capture immediately.
initialConsent'granted' | 'denied' | 'unknown'Pre-known consent (SSR/cookie) so a host can skip the wait. Default 'unknown' when gated.
debugbooleanfalse

Privacy#

OptionTypeDefaultWhat it does
captureNetworkBodiesbooleanfalseCapture network request/response bodies (redacted). Default false (denylist-by-default).
denyliststring[]Header/body keys always stripped before send.
maskSelectorsstring[][]CSS selectors whose text/inputs are masked (in addition to mask-all defaults).
maskReplayTextbooleanfalseMask ALL static text in session replay (default false — text is captured so replays are readable). Set true to mask every text node. Form input VALUES have their OWN flag (maskInputs).
maskInputsbooleanfalseMask form input VALUES in session replay. By default this follows maskReplayText — one flag governs everything (static text + typed inputs). Set it explicitly (true/false) to decouple inputs from text. Password fields are ALWAYS blanked regardless of this flag.
respectDntbooleanfalseHonor the user's Global Privacy Control / Do-Not-Track signal (default false). When true and the browser signals opt-out (navigator.globalPrivacyControl / navigator.doNotTrack), session replay does not record for that user. Recommended where GPC compliance (e.g. CCPA) matters.
maskEventTextbooleanfalseMask the TEXT LABEL on captured interaction events (default false — the real label is sent).
Resolved optionDefault
consent.requiredfalse
consent.initial'unknown'
bugReport.launcherfalse
bugReport.position'bottom-right'
bugReport.label'Report a bug'

Nested blocks#

These are passed through the resolver untouched and defaulted inside the feature that reads them, so the defaults below come from the contract rather than from resolveConfig.

replay#

OptionTypeDefaultWhat it does
modeReplayMode
sampleRatenumber
onErrorSampleRatenumber
persistBufferbooleanfalseOpt-in: mirror the pre-roll buffer to IndexedDB so a tab-killing crash still yields it on the next load (an error-free clean close discards it).
privacyLevel'standard' | 'strict''standard''strict' adds heuristic PII redaction (emails / card numbers / SSNs) to captured text — useful when replay text is UNMASKED (privacy.maskReplayText).

errors#

OptionTypeDefaultWhat it does
ignoreErrors(string | RegExp)[]Drop errors whose MESSAGE matches (substring or RegExp). Merged with built-in benign noise (e.g. "ResizeObserver loop…") — your list is appended, never replaces the defaults.
denyUrls(string | RegExp)[]Drop errors whose originating script URL matches (substring or RegExp) — silence noisy third-party scripts (chrome-extension://, ad/analytics vendors, …).
captureResourceErrorsbooleanCapture failed resource loads (img/script/link/css) as 'resource' errors instead of dropping them. Default false — they're usually noise, and never JS crashes.
maxBreadcrumbsnumber50Max breadcrumbs retained in the ring + attached to each error (the trail of console/network/ navigation/click events leading up to it). Default 50, max 200.
sampleRatenumber1Cost lever for very-high-volume apps: fraction of SESSIONS (0–1) whose AUTO errors are captured (deterministic per-session; manual captureError always fires). Default 1 = every session. Prefer grouping / ignoreErrors / beforeSend first — sampling trades error completeness for cost.
beforeSend(item: ErrorItem) => ErrorItem | nullLast-mile hook: inspect/transform each error item before it's sent, or return null to DROP it (e.g. scrub fields, drop by URL/tag). Throwing is safe — the original is kept.
beforeBreadcrumb(crumb: Breadcrumb) => Breadcrumb | nullHook: inspect/transform each breadcrumb before it enters the ring, or return null to drop it.

network#

OptionTypeDefaultWhat it does
trackWebSocketbooleantrueTrack WebSocket connection lifecycle + message/byte counters. Default true (lazy chunk).
trackSsebooleantrueTrack Server-Sent-Events (EventSource) lifecycle. Default true (lazy chunk).
captureBodiesbooleanfalseOpt-in: capture request/response bodies + headers (redacted + capped). Default false (privacy).
bodyMaxBytesnumber8192Hard cap on captured body bytes when captureBodies is on. Default 8192, ceiling-enforced.
contentTypeAllowliststring[]['application/json','text/plain']Content-types eligible for body capture.
sampleRatenumber1Base sample rate (0–1) for SUCCESSFUL requests — failed/slow are ALWAYS kept.
slowRequestMsnumber2000"slow" threshold in ms — requests at/over this are flagged + always kept.
denyUrls(string | RegExp)[]Never capture requests whose URL matches (substring or RegExp).
beforeSend(item: NetworkItem) => NetworkItem | nullLast-mile hook: transform the network item, or return null to DROP it. Throwing is safe.

performance#

OptionTypeDefaultWhat it does
tracesSampleRatenumber1Base sample rate (0–1) for transactions. SLOW/errored transactions are ALWAYS kept regardless; this only thins the fast, clean ones. Deterministic per-transaction (re-derivable from traceId). Default 1 = keep every transaction.
slowTransactionMsnumber3000Duration (ms) at/over which a transaction is "slow" → always kept (the adaptive bias).

watchdog#

OptionTypeDefaultWhat it does
sampleRatenumber1Per-session deterministic keep rate (0–1).
heartbeatMsnumber1000Event-loop-lag heartbeat cadence (ms). Default 1000, floored at 250.
rollupMsnumber30000Health-rollup window (ms) — one resource_health item per window.
memorySampleMsnumber20000Heap sample cadence (ms).
thresholdsRecord<string, number>Incident-threshold overrides (see the WatchdogThresholds keys).
captureProfileOnIncidentbooleantrue5.3 — capture a JS Self-Profiling window on an incident (no-op until the header + phase land).

exitIntent#

OptionTypeDefaultWhat it does
windowMsnumber120How far back to measure upward velocity (ms).
minDistancePxnumber80Minimum upward travel across the window (px) — filters micro-corrections.
minVelocityPxMsnumber0.7Minimum upward velocity (px/ms). Default 0.7 (≈700 px/s) — a flick, not a drift.
minDepthPctnumber25Engagement floor: minimum max scroll depth reached (%).
sustainSamplesnumber3Consecutive qualifying samples required (hysteresis vs scroll jitter).
topEdgePxnumber40Pointer-exit band: how close to the top edge (px) the pointer must be when it leaves the page.

analytics#

OptionTypeDefaultWhat it does
planTrackingPlanA3 — optional typed tracking plan. Governs custom track() events (internal $ events are never governed): warns on unknown events / missing-required / type-mismatch props, and — in strict mode — DROPS violations from both lanes.
sampleRatenumberA6 — analytics-lane sample rate (0–1, default 1 = keep all). Sampling is PER-USER + deterministic (a stable subset of anonymous ids is kept in full, so funnels/retention stay intact). Identity ($identify/$group/$alias) and revenue (purchase) events are NEVER thinned.
cookieDomainstringA6 — set to share the anonymous id across sub-domains via a cookie (e.g. '.example.com'), so a user is one profile across app./www./shop. When unset, the id is localStorage-scoped per origin.

flags#

OptionTypeDefaultWhat it does
bootstrapFlagsBootstrapF3 — bootstrap seed applied synchronously at init (SSR handoff) so the first paint uses real values instead of defaults — no flash-of-default on a cold cache. Shape mirrors GET /config.
realtimebooleantrueF4 — subscribe to the realtime config stream (SSE) so a kill-switch flip / flag edit reaches the client in seconds instead of waiting for the periodic refresh. set false to rely on the foreground-poll refresh only (no persistent connection).

push#

OptionTypeDefaultWhat it does
softAskobject

csp#

OptionTypeDefaultWhat it does
noncestring
Configuration · API reference · Web SDK · ScaleBun