Configuration¶
Set window.BehavLabsConfig before the script loads. Options marked server are replaced
by the config the API returns at the handshake.
| Option | Type | Default | Description |
|---|---|---|---|
apiKey |
string | null |
Publishable key. Required. |
userId |
string | null |
The signed-in user's account ID in your system, 1 to 128 characters: your database ID or customer number. Pass the same value on every device, browser and login; it links the person's sessions into the history scoring compares against. Prefer an ID that never changes over an email address. When null, an anonymous id is kept in localStorage (behavlabs_anon_id): it covers one browser only and is lost when storage is cleared. Load the SDK once the user is signed in. The SDK never sends it as is, see User IDs. |
consent |
object | null |
{ training: boolean, policyVersion?: string } |
endpoint |
string | https://api.behavlabs.com/v1/collect |
API base. Only change it for a local or self-hosted API. |
autoStart |
boolean | true |
Call start() on DOMContentLoaded. |
respectGPC |
boolean | true |
Do not start when navigator.globalPrivacyControl is set. |
useWorker |
boolean | true |
Upload from a Web Worker; falls back to the main thread if the worker cannot start (for example a CSP without worker-src blob:). |
compress |
boolean | true |
Raw-DEFLATE batches with CompressionStream where supported. |
captureDeviceContext |
boolean | true |
Send device context once per session. |
fingerprint |
boolean | true |
Add the device fingerprint to the device context, for device recognition. |
fingerprintTimeoutMs |
number | 1500 |
Start uploading without the slower fingerprint parts (audio, client hints) after this long. |
forwardIntervalMs |
number | 250 |
How often captured events move from the page to the uploader. |
maxPendingBatches |
number | 30 |
Batches allowed to wait for upload; the oldest are dropped beyond this. |
debug |
boolean | false |
Log to the console. |
flushIntervalMs server |
number | 2000 |
Upload cadence. |
maxBatchEvents server |
number | 2000 |
Queued events that trigger an early upload. |
moveThrottleMs server |
number | 16 |
Minimum gap between recorded pointer moves, scrolls and touch moves (about 60 Hz). |
keyMode server |
string | "code" |
"code" sends the physical key (KeyboardEvent.code), which risk scoring needs. "class" sends key classes only and disables keystroke scoring. |
capture server |
object | all true |
{ keystroke, mouse, touch, scroll, field_len } |
sensitiveAutocomplete server |
string[] | 8 tokens | Autocomplete tokens whose fields are never captured. |