Skip to content

Methods

On window.BehavLabs. All are safe to call before the handshake completes.

Method Returns Description
start() boolean Attach listeners and open a session; false when blocked by consent or GPC.
stop() void Flush captured events, detach listeners and end the uploader.
setConsent(consent) boolean Record the user's choice. training: true starts collection and returns the result of start(); anything else stops it and returns false.
pause(), resume() void Suspend and resume capture without ending the session, for example around a sensitive view.
flush() void Upload everything captured so far.
onStatus(callback) void Subscribe to status events. Callbacks run synchronously; their errors are swallowed.
isRunning() boolean Running and not paused.
getSessionId() string | null Session id once the handshake has succeeded.
getUserId() string | null The resolved user id.
getStats() object { captured, forwarded, sent, batches, wireBytes, rawBytes, dropped, retries, transport, keyMode }
getBuffer() Event[] Copy of events not yet handed to the uploader (debugging).
getDevice() object | null The device context and fingerprint sent at the handshake (null until it is ready).
version string "2.4.0"