All integrations

PostHog

Instrumentation

Send agent traces and generations to PostHog AI Observability.

Read the full instrumentation docs

Install

Add PostHog AI Observability from eve's registry:

bash
eve add instrumentation/posthog

Quick start

eve installs agent/instrumentation/posthog.ts with PostHog's trace exporter. It also links spans to the user who initiated the session when an authenticated principal is available:

ts
// agent/instrumentation/posthog.tsimport { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";import { PostHogTraceExporter } from "@posthog/ai/otel";import { otelIntegration } from "eve/instrumentation/otel";
export default otelIntegration({  spanProcessors: [    new SimpleSpanProcessor(      new PostHogTraceExporter({        projectToken: process.env.POSTHOG_PROJECT_TOKEN!,        host: process.env.POSTHOG_HOST,      }),    ),  ],  runtimeContext(input) {    const distinctId =      input.session.auth.initiator?.principalId ??      input.session.auth.current?.principalId;
    return distinctId ? { posthog_distinct_id: distinctId } : undefined;  },});

Configure

Copy your project token and client API host from PostHog's project settings and expose them as POSTHOG_PROJECT_TOKEN and POSTHOG_HOST. Remove runtimeContext to capture generations anonymously. PostHog groups turns using eve.session.id and preserves eve's trace hierarchy. See PostHog's eve installation guide for verification steps and the OpenTelemetry guide for content policy.