Skip to content

Web (browser)

Tiny, reliable event tracking for Whisperr — works in any JavaScript app. ~3KB gzipped, zero dependencies, off the critical path.

Terminal window
npm i @whisperr/web
import { Whisperr } from "@whisperr/web";
const whisperr = Whisperr.init({ apiKey: "wrk_…" });
// after the user logs in / on session restore
whisperr.identify("user_123", { email: "ada@acme.com", traits: { plan: "pro" } });
// when something happens
whisperr.track("subscription_cancelled", { reason: "too_expensive" });
// on logout
whisperr.reset();
  • Never loses exit events — durable queue plus a keepalive flush 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/batch with 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>
!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>
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.

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.