TopStats SDK
Node.js analytics SDK
Zero-dependency TypeScript client for Node 20+. capture() buffers in memory and sends in batches from a timer loop - it never blocks your request path and never throws into your code. Feature flag evaluation rides the same client. Express, Fastify, Hono and NestJS get dedicated middleware packages built on it.
Install
npm install @topstats/analyticsCapture your first event
import { TopStats } from '@topstats/analytics'
const client = new TopStats(process.env.TOPSTATS_API_KEY!)
client.capture('order_placed', { total: 42 }, { actor: 'user-123' })
await client.shutdown() // flushes the tail on exitBehaviour you can rely on
- Capture never throws into your code and never blocks on the network - a bounded queue buffers and a background loop batches.
- Retries only 429, 5xx and network failures, with jittered backoff honouring Retry-After; your API key never appears in error output.
- Batches split at 500 events and 2 MiB; oversized events are dropped with an onError report, never an exception.
- Retries 429/5xx and network failures with jittered backoff honouring Retry-After; 4xx are permanent.