Skip to main content

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 Flags
Build-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

CategoryExamplesDefault (Public Build)
Core featuresBUILTIN_EXPLORE_PLAN_AGENTS, TOKEN_BUDGET, MCP_SKILLStrue
Internal featuresCOORDINATOR_MODE, KAIROS, DAEMONfalse
ExperimentalVOICE_MODE, WEB_BROWSER_TOOL, BRIDGE_MODEfalse
AblationABLATION_BASELINEfalse

See the Feature Flags Appendix for the complete list.

Event Pipeline

User/System Action
📊
logEvent()
Event Sink
First-Party Analytics
📊
Datadog
OpenTelemetry Export
Traces
Metrics
Logs

What's Tracked

Event TypeExamples
Session eventsSession start, end, duration
Tool usageTool name, execution time, success/failure
Model usageTokens consumed, model used, cache hits
Command usageWhich slash commands are used
Error eventsError 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

SignalSupported Exporters
TracesOTLP (gRPC, HTTP, Proto)
MetricsOTLP (gRPC, HTTP, Proto), Prometheus
LogsOTLP (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

FilePurpose
src/services/analytics/GrowthBook, event pipeline, telemetry
src/services/analytics/growthbook.tsFeature flag evaluation
src/services/analytics/telemetry.tsOpenTelemetry setup