Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

2.0 KB
Raw Blame

RealTime Hog 3000

The start of something fresh.

Hog 3000 powers live event stream on PostHog: https://us.posthog.com/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.
    • pathCleaning - JSON array of {"alias", "regex"} path cleaning rules (the team's path_cleaning_filters). Each streamed event carrying a $pathname gains a $virt_cleaned_pathname property with the rules applied in list order using RE2 semantics. Entries that are malformed, fail to compile, or exceed per-rule size limits are skipped individually; a ruleset of more than 100 rules is ignored entirely, so subscribers can fall back to cleaning client-side with the full set.
  • /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.posthog.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