Files
hkuds__cli-anything/cli-hub/cli_hub/analytics.py
yuhao 4a2e21e3f7 feat(analytics): flatten cli-install/uninstall events, add cli-launch, merge live Umami+PostHog
CLI side (bumped to 0.2.3 so it ships to PyPI):
- track_install / track_uninstall: drop ":{cli_name}" suffix; event names
  become static "cli-install" / "cli-uninstall" with CLI name moved to
  properties.cli. Keeps PostHog's event catalog flat and makes breakdowns
  by CLI a simple property filter.
- Add track_launch(cli_name) firing "cli-launch" from `cli-hub launch <name>`,
  so we have a real usage signal distinct from install intent.
- Tests updated to match the flat event names; new test for cli-launch.

Web side:
- Replace frozen BASELINE_STATS + PostHog-increment flow with a live
  merge of two sources fetched every 60s:
    * PostHog HogQL (via Cloudflare Worker, allow-listed query) —
      counts visit-human/agent, cli-hub call split, and both flattened
      and legacy-colon-prefixed cli-install/cli-uninstall, plus cli-launch.
    * Umami events/series (via same Worker, new /umami/events endpoint)
      for pre-migration events that PostHog never saw.
  BASELINE_STATS survives as last-resort fallback only.
- cli_hub_total now aggregates cli-hub call + cli-install + cli-uninstall
  + cli-launch so the footer's "cli-hub" number reflects end-to-end
  activity; human/agent split stays tied to cli-hub call only because
  Umami install events don't carry is_agent.
2026-04-24 09:08:10 +00:00

12 KiB