: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(analytics): count hog cli requests as the cli event source (#124585)
Rafael Audibert0c8b485a149d
diff --git a/posthog/event_usage.py b/posthog/event_usage.pyindex 13fa98036ba0..b563458baae9 100644--- a/posthog/event_usage.py+++ b/posthog/event_usage.py@@ -531,7 +531,12 @@ def get_event_source(request) -> EventSource:# it authenticates with a personal API key, so there is no application to vouch for it.# Mis-declaring as the CLI only mislabels analytics — `cli` is already in# AGENT_EVENT_SOURCES, so it buys no extra write latitude.- if user_agent == "posthog-cli" or request.headers.get("X-Posthog-Mcp-Consumer") == "posthog-cli":+ # `hog`, the TypeScript successor to posthog-cli, sends `hog/<version>`.+ if (+ user_agent == "posthog-cli"+ or user_agent.startswith("hog/")+ or request.headers.get("X-Posthog-Mcp-Consumer") == "posthog-cli"+ ):return EventSource.CLIif "posthog/mcp-server" in user_agent or request.headers.get("X-Posthog-Client") == "mcp":return _resolve_mcp_surface(request)diff --git a/posthog/test/test_event_usage.py b/posthog/test/test_event_usage.pyindex d19c67bda465..a328d95852b1 100644--- a/posthog/test/test_event_usage.py+++ b/posthog/test/test_event_usage.py@@ -300,6 +300,7 @@ class TestGetEventSource(SimpleTestCase):[("terraform", "posthog/terraform-provider 1.0", EventSource.TERRAFORM),("cli_exact", "posthog-cli", EventSource.CLI),+ ("hog_cli", "hog/1.0.0-alpha.0", EventSource.CLI),("wizard", "posthog/wizard 1.0", EventSource.WIZARD),("posthog_code", "posthog/code 1.2.3", EventSource.POSTHOG_CODE),("desktop_app_direct", "posthog/desktop.hog.dev 0.1.0", EventSource.DESKTOP),