Dozor
@kharko/dozor

Init & options

Dozor.init() is the one entry point of the SDK. Call it once on app startup with your apiKey + endpoint and the recorder begins capturing.

src/lib/dozor.ts
import { Dozor } from "@kharko/dozor";

export const dozor = Dozor.init({
  apiKey: "dp_your_public_key",
  endpoint: "https://your-dashboard.com/api/ingest",
});

The return value is the singleton recorder instance — calling Dozor.init() again returns the same instance, never re-initialises. That makes it safe to drop into any module without coordination.

Options reference

All options come off the DozorOptions interface (exported from @kharko/dozor). Two are required; the rest have sensible defaults.

Required

OptionTypeDescription
apiKeystringPublic project API key, format dp_.... Copy it from your dashboard at Avatar → Manage organizations → [org card] → API keys.
endpointstringIngest URL — full URL (https://your-dashboard.com/api/ingest) or same-origin relative path (/api/monitor) for the tunnel pattern.

Behaviour

OptionTypeDefaultDescription
autoStartbooleantrueStart recording immediately on init(). Set to false to control start manually via start().
holdbooleanfalseStart with transport held — events buffer locally but don't ship until release(). Useful for conditional recording.
pauseOnHiddenbooleantrueAuto-pause when the tab becomes hidden, auto-resume when visible.
flushIntervalnumber (ms)60000How often the buffer is flushed to the server.
batchSizenumber2000Max events in the buffer before an automatic flush is triggered.
fetchTimeoutnumber (ms)10000Timeout for each batch send. Page-unload keepalive flushes don't honour this — they're fire-and-forget.
recordConsolebooleantrueCapture console.log/warn/error/info/debug calls in the recording.
debugbooleanfalsePrint verbose [dozor]-prefixed console output for every internal operation. Off has zero overhead.

Privacy

The privacy options have their own page — see Privacy & masking for the full table plus recipes.

OptionTypeDefault
privacyMaskInputsbooleantrue
privacyMaskAttributestring"data-dozor-mask"
privacyBlockAttributestring"data-dozor-block"
privacyBlockMediabooleanfalse

What init() does on the inside

Useful to know if you're debugging at the network layer:

  1. Returns the existing singleton if init() was called before. No re-initialisation — duplicate calls are safe.
  2. Generates or reuses sessionId — read from sessionStorage first; if absent, mints a new UUID and persists it. Survives reloads in the same tab; cross-tab is a separate session.
  3. Wires the rrweb recorder with the privacy options applied as masks/blocks at the source — sensitive data never enters the buffer.
  4. Sets up the flush timer (flushInterval) and the buffer-size trigger (batchSize).
  5. Subscribes to visibilitychange for pauseOnHidden, and to beforeunload / pagehide for the keepalive final flush.
  6. Starts capturing unless autoStart: false.

On this page