← all notes

Telemetry without a database

Counting active visitors, browsers and countries in 200 LOC of TypeScript, with zero infra. Trade-offs included.

The dashboard is a demo

The Live Telemetry page is a wall of numbers — active users, sessions, top countries, browser mix — that updates in real time. It looks like something you'd plug Mixpanel into, except the entire backend is a single TypeScript class with five Maps and an EventEmitter.

That class lives at server/src/lib/analytics-store.ts.

What it does

  • Every page view POSTs a tiny payload to /v1/analytics/ingest.
  • The store updates five histograms (country / browser / OS / device / path), bumps the recent ring buffer, and emits a change event.
  • An SSE endpoint listens for that event and re-publishes a snapshot to every connected client.

What it deliberately doesn't do

  • No persistence. Restart Render's free tier and the numbers go to zero. The dashboard frames itself as "since this server woke up" so the number isn't lying.
  • No multi-instance. A second replica would have its own state. If this ever ships to >1 box, swap the Maps for an Upstash Redis hash — the interface is small enough that the diff is a hundred lines.
  • No PII. The country comes from x-vercel-ip-country; the browser/OS/device come from a 50-LOC UA classifier I wrote on a flight. No fingerprinting, no cookies.

This is the right design for a portfolio. It would be the wrong design for a product. Naming the difference is part of the demo.