Analytics & Telemetry
How Claude Code collects usage data, evaluates feature flags, and exports observability signals.
Feature Flags (GrowthBook)
Claude Code uses GrowthBook for feature flag evaluation:
🏷️
GrowthBook Service🚩
90+ Feature FlagsBuild-time or Runtime?
Build-time: bun:bundle feature() — dead code elimination
Runtime: GrowthBook SDK evaluation
Build-Time Flags
The majority of flags are resolved at build time via Bun's feature() API:
import { feature } from 'bun:bundle'
// Replaced with true/false at build time
// Dead branch eliminated from bundle
if (feature('COORDINATOR_MODE')) {
// This entire block is removed in the public build
}
Runtime Flags
Some flags are evaluated at runtime via the GrowthBook SDK, allowing A/B testing and gradual rollouts without rebuilding.
Flag Categories
| Category | Examples | Default (Public Build) |
|---|---|---|
| Core features | BUILTIN_EXPLORE_PLAN_AGENTS, TOKEN_BUDGET, MCP_SKILLS | true |
| Internal features | COORDINATOR_MODE, KAIROS, DAEMON | false |
| Experimental | VOICE_MODE, WEB_BROWSER_TOOL, BRIDGE_MODE | false |
| Ablation | ABLATION_BASELINE | false |
See the Feature Flags Appendix for the complete list.
Event Pipeline
⚡
User/System Action📊
logEvent()Event Sink
First-Party Analytics
📊
DatadogOpenTelemetry Export
Traces
Metrics
Logs
What's Tracked
| Event Type | Examples |
|---|---|
| Session events | Session start, end, duration |
| Tool usage | Tool name, execution time, success/failure |
| Model usage | Tokens consumed, model used, cache hits |
| Command usage | Which slash commands are used |
| Error events | Error types, stack traces |
Event Metadata
Each event includes:
- Session ID
- User context (anonymous)
- Tool names and outcomes
- Token counts
- Timestamps
OpenTelemetry
Claude Code has comprehensive OpenTelemetry instrumentation:
Exporters
| Signal | Supported Exporters |
|---|---|
| Traces | OTLP (gRPC, HTTP, Proto) |
| Metrics | OTLP (gRPC, HTTP, Proto), Prometheus |
| Logs | OTLP (gRPC, HTTP, Proto) |
What's Instrumented
- API call latency and token usage
- Tool execution timing
- MCP server connection lifecycle
- Session duration and message count
Killswitch
Telemetry can be disabled:
- Environment variable:
CLAUDE_CODE_DISABLE_TELEMETRY=1 - Settings: telemetry disabled in
settings.json - Enterprise policy: admin can disable telemetry fleet-wide
When disabled, no events are collected or transmitted.
Key Source Files
| File | Purpose |
|---|---|
src/services/analytics/ | GrowthBook, event pipeline, telemetry |
src/services/analytics/growthbook.ts | Feature flag evaluation |
src/services/analytics/telemetry.ts | OpenTelemetry setup |