@sazabi/browser) instruments a web frontend and sends telemetry to Sazabi. It captures errors, navigation, clicks, network calls, and console output, and lets you emit custom events and logs. It authenticates with a public key, which is write-only and safe to ship in your bundle.
For server-side reads and writes against the API, use the TypeScript SDK with a secret key instead.
Install
Initialize
Import theregister entrypoint first — before any other import — so the SDK installs its instrumentation before other code captures the native fetch, XMLHttpRequest, or history APIs. Then call init:
app-entry.ts
init is idempotent. init options:
Get the public key from Settings > Public keys. Never use a secret key in the browser.
Identify and reset
identify attaches a client-asserted user identity (and optional traits) to subsequent events. reset clears the identity and rotates the session so a shared device does not thread activity into the previous user’s timeline.
Custom events and logs
addEvent(name, attributes?) emits a custom event into the session stream. log(severity, message, metadata?) emits an application log line with session context; severity is one of DEBUG, INFO, WARN, or ERROR.
Flush and shutdown
flush sends any queued events immediately. shutdown flushes and removes the SDK’s instrumentation, reversing init and the register import.
What the SDK captures automatically
Afterinit, the SDK captures, with session context attached:
- Errors — uncaught exceptions and unhandled promise rejections, with stack traces.
- Navigation — page loads and single-page-app route changes.
- Pointer episodes — one event per mouse, touch, or pen contact, from down to up, with coordinates, distance, duration, pressure, concurrent contacts, and a once-per-second path sample. Long contacts emit partial events every ten seconds. When the browser takes over a contact, such as a touch scroll, the event ends at that point with
app.pointer.ended_by: cancel. - Clicks — taps derived from pointer episodes, plus keyboard and script clicks, by privacy-safe selector and label. It also flags rapid repeat clicks and clicks with no response.
- Input interactions — one event per field engagement (by field label). It never captures keystrokes or values.
- Network calls —
fetchandXMLHttpRequestcalls with method, status, and duration. By default it injects a W3Ctraceparentheader on same-origin requests so frontend and backend telemetry correlate. - Console — mirrors
console.errorandconsole.warnby default (the original console output is untouched). - Lifecycle — the tab going to the background and coming back.
data-sazabi-mask to suppress its text capture.
Further reading
Instrument your frontend
The guide to instrumenting a web frontend.
Public keys
Manage the public key the SDK uses.