@logclip/tracker
v0.12.0
Published
LogClip capture SDK — privacy-first DOM, console, network, error & web-vitals recording.
Readme
@logclip/tracker
The LogClip capture SDK. A tiny, privacy-first script that records DOM (rrweb), console, network, errors, and web vitals, then ships them in masked, gzipped batches. No tagging required.
Install
Script tag (no build):
<script
src="https://cdn.logclip.com/logclip.global.js"
data-logclip-key="pk_live_xxx"
data-logclip-endpoint="https://in.yourapp.com"></script>That exposes window.LogClip for identify() / track() / setConsent().
Pin a version for production — [email protected] is served immutable,
while the unversioned alias is short-cached and moves with each release.
Other data- attributes: mask-inputs, require-consent, auto-start,
trace-propagation, trace-hosts, metadata. To host the file yourself,
take dist/logclip.global.js from the package.
npm:
npm install @logclip/trackerimport { LogClip } from '@logclip/tracker';
LogClip.init({ siteKey: 'pk_live_xxx', endpoint: 'https://in.yourapp.com' });Obsrviq is exported as an alias of LogClip and still works.
API
LogClip.init(config); // see config below
LogClip.identify(userId, traits?); // raw userId (searchable) + SHA-256 hash; retro-stamps
LogClip.setMetadata({ plan: 'pro' }); // merge searchable session properties anytime
LogClip.reset(); // forget identity on logout → fresh anonymous session
LogClip.track('event', { conversion: true });
LogClip.setConsent(true | false); // gate recording (PRIV-2)
LogClip.stop(); // hard stop + flush
LogClip.getDiagnostics(); // { recording, sessionId, flushes, bytesSent, … }Config
| Option | Default | Notes |
|---|---|---|
| siteKey | — | Required. The pk_ ingest key. |
| endpoint | https://app.logclip.com | Your ingest URL. Pass your own if self-hosting. |
| maskAllInputs | true | Never record input values. |
| maskTextSelector | — | Mask text inside matching nodes. |
| blockSelector | .logclip-block, .obsrviq-block | Never record these nodes. |
| captureNetworkBodies | false | Opt-in, masked, size-capped. |
| redactHeaders | authorization, cookie, set-cookie | Redacted in captured headers. |
| requireConsent | false | If true, nothing records until setConsent(true). |
| sampleRate | 1.0 | 0..1 fraction of sessions to record. |
| flushIntervalMs | 5000 | Batch flush cadence. |
| beforeSend | — | Last-chance redaction; return null to drop. |
Behavior
- Consent & privacy: with a consent gate and consent withheld, zero network calls leave the page (honors Global Privacy Control / DNT).
- Transport: gzipped via fflate, sent with
sendBeacon(orfetchkeepalive) on a timer, onvisibilitychange=hidden, and onpagehide. - Capture: rrweb for DOM (periodic full snapshots for progressive replay);
custom interceptors for
fetch/XHR/PerformanceObserver/sendBeacon; console hooks;window.onerror+onunhandledrejection; web vitals; rage/dead click detection.
Full guide: https://logclip.com/docs.
