> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mellob.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage of Analytics

> Enable analytics collection with Posthog's LLM observability for prompts, tool calls, and AI output.

You can enable analytics to trace interactions and performance. The helper option below turns on collection and configures PostHog.

```go theme={null}
func ConfigureAnalytics(did, tid string) ai.Option
```

### Environment variables

```bash theme={null}
POSTHOG_KEY=phc_...
POSTHOG_ENDPOINT=https://app.posthog.com
```

### Enabling in your client

```go theme={null}
kai := ai.NewKarmaAI(
	ai.GPT4o,         // pick a model
  ai.OpenAI,        // pick a provider
  ai.ConfigureAnalytics("user-123", "trace-abc"),
)
```

> With analytics on, Karma AI will capture user prompts, tool calls (if MCP/tools enabled), and AI responses under your identifiers.
