@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.
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
| Option | Type | Description |
|---|---|---|
apiKey | string | Public project API key, format dp_.... Copy it from your dashboard at Avatar → Manage organizations → [org card] → API keys. |
endpoint | string | Ingest URL — full URL (https://your-dashboard.com/api/ingest) or same-origin relative path (/api/monitor) for the tunnel pattern. |
Behaviour
| Option | Type | Default | Description |
|---|---|---|---|
autoStart | boolean | true | Start recording immediately on init(). Set to false to control start manually via start(). |
hold | boolean | false | Start with transport held — events buffer locally but don't ship until release(). Useful for conditional recording. |
pauseOnHidden | boolean | true | Auto-pause when the tab becomes hidden, auto-resume when visible. |
flushInterval | number (ms) | 60000 | How often the buffer is flushed to the server. |
batchSize | number | 2000 | Max events in the buffer before an automatic flush is triggered. |
fetchTimeout | number (ms) | 10000 | Timeout for each batch send. Page-unload keepalive flushes don't honour this — they're fire-and-forget. |
recordConsole | boolean | true | Capture console.log/warn/error/info/debug calls in the recording. |
debug | boolean | false | Print 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.
| Option | Type | Default |
|---|---|---|
privacyMaskInputs | boolean | true |
privacyMaskAttribute | string | "data-dozor-mask" |
privacyBlockAttribute | string | "data-dozor-block" |
privacyBlockMedia | boolean | false |
What init() does on the inside
Useful to know if you're debugging at the network layer:
- Returns the existing singleton if
init()was called before. No re-initialisation — duplicate calls are safe. - Generates or reuses
sessionId— read fromsessionStoragefirst; if absent, mints a new UUID and persists it. Survives reloads in the same tab; cross-tab is a separate session. - Wires the rrweb recorder with the privacy options applied as masks/blocks at the source — sensitive data never enters the buffer.
- Sets up the flush timer (
flushInterval) and the buffer-size trigger (batchSize). - Subscribes to
visibilitychangeforpauseOnHidden, and tobeforeunload/pagehidefor the keepalive final flush. - Starts capturing unless
autoStart: false.