Web (browser)
Tiny, reliable event tracking for Whisperr — works in any JavaScript app. ~3KB gzipped, zero dependencies, off the critical path.
npm i @whisperr/webQuickstart
Section titled “Quickstart”import { Whisperr } from "@whisperr/web";
const whisperr = Whisperr.init({ apiKey: "wrk_…" });
// after the user logs in / on session restorewhisperr.identify("user_123", { email: "ada@acme.com", traits: { plan: "pro" } });
// when something happenswhisperr.track("subscription_cancelled", { reason: "too_expensive" });
// on logoutwhisperr.reset();What you get
Section titled “What you get”- Never loses exit events — durable queue plus a
keepaliveflush on page hide. - Anonymous → identified — events tracked before login are attributed to
the user retroactively on
identify(). - Cookieless (localStorage) and consent-friendly (
optIn()/optOut()). - SSR-safe, auto-captures SPA pageviews, batches to
/v1/events/batchwith retry and backoff per the delivery contract.
Using React or Next.js? Use the React or Next.js bindings instead of wiring the provider yourself.
Script tag (no build step)
Section titled “Script tag (no build step)”<script>!function(){var w=window.whisperr=window.whisperr||[];w._opts={};w.load=function(k,o){w._key=k;w._opts=o||{};var s=document.createElement("script");s.async=1;s.src="https://cdn.whisperr.net/whisperr.js";document.head.appendChild(s)};["identify","track","page","flush","reset","optIn","optOut"].forEach(function(m){w[m]=function(){w.push([m].concat([].slice.call(arguments)))}})}();whisperr.load("wrk_…");</script>Options
Section titled “Options”| Option | Default | Notes |
|---|---|---|
apiKey |
— | App ingestion key (wrk_…). Required. |
baseUrl |
https://api.whisperr.net |
Ingestion base URL. |
flushAt / flushIntervalMs |
20 / 10000 |
Batch triggers. |
autocapturePageviews |
true |
SPA page_viewed capture. |
respectDoNotTrack |
false |
Honor DNT. |
persistence |
localStorage |
Or memory. |
debug |
false |
Verbose logging. |
A note on the API key
Section titled “A note on the API key”The ingestion key ships in your bundle by design — it can only ingest events for your app. Treat it as publishable, like a Segment write key.