mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
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
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 iskey=valuefor 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/debuggenerating 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