Files
zeekay 212f5e965a Answer the live stream at connect
An idle /events held its response until the first event, so the edge
cut it with a 524 after 100s, which the browser reads as a CORS error.
Send the headers at connect and a comment line every 30s.

Claude-Session: https://claude.ai/code/session_01TUxvfuta1Z44KVNYuAz71F
2026-09-23 19:28:46 -07:00
..
…

RealTime Script 3000

The start of something fresh.

Script 3000 powers live event stream on Insights: https://us.hanzo.ai/project/0/activity/live

Endpoints

  • / - dummy placeholder
  • /served - total number of events and users recorded
  • /stats - number of unique users (distinct id) on a page
  • /events - stream consumed events to the requester, it's a done through Server Side Event, it supports extra query params adding filters:
    • eventType - event type name,
    • distinctId - only events with a given distinctId,
    • geo - return only coordinates guessed based on IP,
    • property - repeatable; each value is key=value for exact-match filtering on top-level event properties. Multiple params with the same key OR together, different keys AND together.
  • /debug - dummy html for SSE testing,
  • /debug/sse/ - backend for /debug generating a server side events,
  • /metrics - exposes metrics in Prometheus format

Installing

One needs a IP -> (lat,lng) database:

curl https://mmdbcdn.insights.net/ | brotli -d > mmdb.db

Config the configs in configs/config.yml. You can take a peak at the examples in configs/configs.example.yml

Run it!

go run .

Notice

If modifying fields with //easyjson:json comment, one must regenerate the easyjson marshaller / unmarshaller. It requires to install: go install github.com/mailru/easyjson/...@latest