Skip to main content

Overview

Integrate AgentCat with PostHog for product analytics. Events are sent as capture events via the PostHog /batch API, giving you full visibility into MCP tool usage within your existing PostHog dashboards.

Prerequisites

  1. A PostHog project with an API key (starts with phc_...)
  2. Your PostHog host URL (default: https://us.i.posthog.com)

Configuration

The Python SDK has no PostHog exporter, so this page has no Python tab. In C#, the API key is the constructor argument, and 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 PostHog capture 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’s distinct_id is set using the following priority:
  1. Identified user ID — if the user was identified via the identify callback
  2. Session ID — falls back to the AgentCat session ID
  3. "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 identifyActorData are merged in

Error Events

When is_error is true, AgentCat sends two events to PostHog:
  1. Regular capture event — the standard event with all properties above
  2. $exception event — a native PostHog exception event with:
This ensures errors appear in PostHog’s native error tracking and can trigger alerts.