Overview
Integrate AgentCat with PostHog for product analytics. Events are sent ascapture events via the PostHog /batch API, giving you full visibility into MCP tool usage within your existing PostHog dashboards.
Prerequisites
- A PostHog project with an API key (starts with
phc_...) - Your PostHog host URL (default:
https://us.i.posthog.com)
Configuration
Host and EnableAITracing are properties. EnableAITracing = true also sends each tool call as a PostHog LLM analytics span ($ai_span). PostHog gets the parameters and the response of each call. On an ASP.NET Core server, the parameters hold the HTTP request headers of the call, Authorization and Cookie included, and so does the $ai_input_state of the span. Remove the headers that must not reach PostHog with a RedactEvent hook.
Configuration Fields
Field Mapping
Event Names
AgentCat events are sent as PostHogcapture events. Standard MCP event types are mapped to PostHog-friendly names. Any unmapped event types fall back to replacing colons and slashes with underscores.
Distinct ID
PostHog’sdistinct_id is set using the following priority:
- Identified user ID — if the user was identified via the
identifycallback - Session ID — falls back to the AgentCat session ID
"anonymous"— if neither is available
Event Properties
Each event includes the following properties:Person Properties
When a user is identified, PostHog person properties are set via$set:
name— the identified user’s name- Any additional fields from
identifyActorDataare merged in
Error Events
Whenis_error is true, AgentCat sends two events to PostHog:
- Regular capture event — the standard event with all properties above
$exceptionevent — a native PostHog exception event with:
This ensures errors appear in PostHog’s native error tracking and can trigger alerts.