Skip to main content

Claude Code

This article explains how to connect Claude Code to Pensero, what AI-assisted coding data is imported, and how Pensero calculates and displays AI usage metrics across your teams.

Written by Wayne

In this article

Overview

Pensero connects to Claude Code to make AI-assisted work visible at team and company level.

AI usage on its own is not the goal. Pensero aligns Claude Code usage with real delivery signals so teams can understand when AI increases output and when it adds defects or rework.

Important: Pensero only processes Claude Code data for users already created in Pensero. Make sure each developer’s company email in Claude Code telemetry matches their email in Pensero. If the user is not in Pensero, their telemetry will be skipped and will not appear in AI Impact.

What Pensero Reads from Claude Code

Pensero ingests Claude Code usage analytics only. It does not access source code.

Pensero retrieves the following information:

  • Total lines added

  • Total lines removed

  • Sessions

  • Commits

  • User identifiers

  • Timestamps for AI events

How we calculate AI usage

Pensero estimates AI adoption using a directional proxy, not exact code authorship attribution.

AI usage % = Accepted AI-suggested lines ÷ Total committed lines

Important clarifications:

  • This metric is designed to track adoption trends over time, not to audit individual lines of code.

  • Different AI tools report usage differently. Pensero focuses on a consistent, comparable signal.

  • The goal is to understand how AI affects delivery and quality, not to maximize the percentage.

How to connect Claude Code to Pensero

The right setup depends on how your team runs Claude Code.

Prerequisites

Before setting up the integration, make sure you have:

  • Pensero Admin access ( Integrations > Claude Code)

  • Access to your organization’s Claude account or Claude Code configuration

Choose your setup path

Pick the option that matches how your team accesses Claude Code today. The path names match exactly what you see when you run /login in Claude Code.

Your team uses Claude Code through API keys or usage-based billing.

Your team uses a Claude Pro, Max, Team, or Enterprise subscription.

Your team uses Claude through Amazon Bedrock, Microsoft Foundry, or Google Vertex AI.

Not sure which applies? If your developers pay per token or use API keys to access Claude Code, choose Path 1. If your company has a Claude Teams or Enterprise seat subscription, choose Path 2. If Claude is hosted in your own AWS or GCP environment, choose Path 3.

Path 1: API integration

Use this when your team runs Claude Code through API keys or usage-based billing.

This is the simplest setup. No configuration is pushed to developers.

Step 1 - Open Claude Code in Pensero

Go to Integrations > Claude Code in the Pensero sidebar.

Step 2 - Get your API token from Claude Console

Log in to the Claude Console at console.anthropic.com. You need organization admin access. Copy your API token.

Step 3 Add the token to Pensero and save

Paste the token in Pensero and click Save credentials. Pensero starts reading usage through the analytics integration immediately.

In this setup, Claude reports usage for developers working through API keys. Pensero reads that directly. No action is required from individual developers.

Path 2: OpenTelemetry integration

Use this when your team uses a Claude Pro, Max, Team, or Enterprise subscription.

In this setup, the standard analytics API does not expose everything Pensero needs. OpenTelemetry fills that gap. You configure it once and roll it out to your team.

Important before you start: OpenTelemetry data is not historical. Pensero starts receiving data from the moment telemetry is configured. Past usage is not backfilled.

Step 1 - Open Developer telemetry setup in Pensero

Go to Integrations > Claude Code in Pensero. Find the Developer telemetry setup section.

Step 2 - Generate the organization token

Click to generate your organization token. This is a shared credential for your whole team. Treat it like a password and share it securely.

Pensero uses this token in the OTLP headers:

"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <organization_token>"

Step 3 - Choose a rollout method and distribute to your team

Pick the method that fits how your team manages developer environments.

OPTION A: MANAGED SETTINGS

Best for: Teams where you want to push config centrally without asking each developer to set anything up.

  • Copy the config from the Managed settings tab in Pensero.

  • Paste it in Claude.ai under > Organization Settings > Products > Claude Code > Managed Settings.

  • Developers then run /login in Claude Code to accept the settings.

This is how the JSON looks. You only need to update OTEL_EXPORTER_OTLP_HEADERS with the value provided in Pensero. The format should look similar to: tk_...:sk...

{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://pensero.ai/otel",
"OTEL_METRIC_EXPORT_INTERVAL": "300000",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <organization_token>"
}
}

Developers must run /login so Claude Code prompts them to accept the managed settings. Once accepted, telemetry is applied automatically.

OPTION B: SETTINGS.JSON

Best for: Teams where developers manage Claude Code through local config files.

  • Copy the config from the settings.json tab in Pensero.

  • Share it with developers.

  • Each developer adds it to ~/.claude/settings.json.

{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://pensero.ai/otel",
"OTEL_METRIC_EXPORT_INTERVAL": "300000",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <organization_token>"
}
}

For each developer, the Claude Code telemetry setup is visible in their Pensero Profile Settings Page

OPTION C: TERMINAL

Best for: Developers who prefer shell-based configuration.

  • Copy the config from the Terminal tab in Pensero.

  • Developers add these lines to their shell profile, usually ~/.zshrc or ~/.bashrc.

  • After saving, they reload their shell or open a new terminal session.

export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
export OTEL_EXPORTER_OTLP_ENDPOINT=https://pensero.ai/otel
export OTEL_METRIC_EXPORT_INTERVAL=300000
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <organization_token>"

After saving the file, developers should reload their shell or open a new terminal session before using Claude Code again.

For each developer, the Claude Code telemetry setup is visible in their Pensero Profile Settings Page

Path 3: 3rd-party platform

Use this when your team is not using a Claude Code subscription. This includes Amazon Bedrock, Microsoft Foundry, Google Vertex AI, LiteLLM, and any other third-party backend.

These platforms do not send the user email in telemetry events by default. Pensero receives the usage data. But without an extra step, it cannot tell which developer the data belongs to.

There are two ways to fix this. Choose the one that matches your setup.

Option A: Centralized rollout via Managed settings (recommended)

Use this only if your team uses a Claude Code subscription AND routes traffic through a 3rd-party backend such as Bedrock or Vertex AI behind it. This is an advanced setup. Most teams on Bedrock, Vertex AI, or LiteLLM will not have access to Managed settings and should use Option B instead.

This approach uses a Claude Code session hook to automatically populate each developer's email from their git config. No manual step is required from individual developers.

Add the following to your Claude Code Managed settings in claude.ai. Pick the config that matches your backend.

Bedrock

{
"env": {
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "global.anthropic.claude-haiku-4-5-20251001-v1:0",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "us.anthropic.claude-opus-4-6-v1",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
"AWS_BEARER_TOKEN_BEDROCK": "xx=",// UPDATE: replace with your AWS bearer token
"AWS_REGION": "us-east-1", // UPDATE: replace with your AWS region
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"CLAUDE_CODE_USE_BEDROCK": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://pensero.ai/otel",
"OTEL_METRIC_EXPORT_INTERVAL": "300000",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <organization_token>", // UPDATE: replace with your Pensero org token
},
"hooks": {
"SessionStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "bash -c '(EMAIL=$(git config user.email) && echo \"{\\\"env\\\":{\\\"OTEL_RESOURCE_ATTRIBUTES\\\":\\\"enduser.id=$EMAIL\\\"}}\" > ~/.claude/settings.json)'"
}
]
}
]
}
}

Vertex AI

{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"CLAUDE_CODE_USE_VERTEX": "1",
"ANTHROPIC_VERTEX_PROJECT_ID": "your-gcp-project-id", // UPDATE: replace with your GCP project ID
"CLOUD_ML_REGION": "global",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-7",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5@20251001",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://pensero.ai/otel",
"OTEL_METRIC_EXPORT_INTERVAL": "300000",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <organization_token>", // UPDATE: replace with your Pensero org token
},
"hooks": {
"SessionStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "bash -c '(EMAIL=$(git config user.email) && echo \"{\\\"env\\\":{\\\"OTEL_RESOURCE_ATTRIBUTES\\\":\\\"enduser.id=$EMAIL\\\"}}\" > ~/.claude/settings.json)'"
}
]
}
]
}
}

The SessionStart hook reads each developer's git email automatically at the start of every Claude Code session. It writes it as OTEL_RESOURCE_ATTRIBUTES in their local settings. Pensero uses this to map events to the correct developer. No manual input is needed from the team.

Option B: Per-developer manual setup (most common for Bedrock, Vertex AI, and LiteLLM)

Use this when your team does not have a Claude Code subscription.

Step 1: Each engineer updates their local configuration in ~/.claude/settings.json.

Step 2: The manager shares the JSON with OTEL_EXPORTER_OTLP_HEADERS updated with the Pensero token, and each engineer replaces the email with their own.

Each developer adds their company email to ~/.claude/settings.json:

{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://pensero.ai/otel",
"OTEL_METRIC_EXPORT_INTERVAL": "300000",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <organization_token>", // UPDATE: replace with your Pensero org token
"OTEL_RESOURCE_ATTRIBUTES": "[email protected]"// UPDATE: replace with your company email
}
  • Update OTEL_EXPORTER_OTLP_HEADERS with the value provided in Pensero. The format should look similar to: tk_...:sk...

  • Replace [email protected] with the developer's actual company email. This must match the email configured in Pensero.

Step 3: Each engineer saves the settings.json file and restarts Claude Code so telemetry starts being sent correctly.

Without this step: Claude Code sends only an anonymous installation ID in telemetry. Pensero receives the usage events but cannot map them to individual developers. AI adoption metrics will be incomplete.

Data Availability

Once telemetry is configured, Pensero starts receiving Claude Code usage data from that point forward.

Historical data is not available through the OpenTelemetry setup. Pensero does not backfill Claude Code telemetry from before the integration was enabled.

How to open and edit your settings.json

Before you start, open Claude Code in your Terminal and make sure you are logged in with your company email.

  • If you see a personal email instead, run /login and switch to your company account before continuing.

On Mac

Run:

open -a TextEdit ~/.claude/settings.json

Paste the Pensero config. Save with Command + S. Restart Claude Code.

Verify it worked:

cat ~/.claude/settings.json

On Windows

Run:

notepad %USERPROFILE%\.claude\settings.json

Paste the Pensero config. Save with Ctrl + S. Restart Claude Code.

Verify it worked:

type C:\Users\%USERNAME%\.claude\settings.json

Claude Desktop setup

Use this section if your team uses the Claude Desktop app in addition to, or instead of, Claude Code in the terminal.

The Claude Desktop app does not read OTEL_RESOURCE_ATTRIBUTES from ~/.claude/settings.json. Instead, it reads this value from the user’s shell or system environment.

This means each developer must configure their company email as an environment variable so Pensero can map Claude telemetry to the correct Pensero user.

Important: the email used in OTEL_RESOURCE_ATTRIBUTES must match the developer’s email in Pensero.

macOS

Add the following variable to your shell profile, usually ~/.zshrc or ~/.bash_profile:

export OTEL_RESOURCE_ATTRIBUTES="[email protected]"

Replace [email protected] with the developer’s company email.

Alternatively, you can populate it automatically from the developer’s git email:

EMAIL=$(git config user.email); grep -q OTEL_RESOURCE_ATTRIBUTES ~/.zshrc || echo "export OTEL_RESOURCE_ATTRIBUTES=\"enduser.id=$EMAIL\"" >> ~/.zshrc

After saving the file, fully restart Claude Desktop so the app picks up the new environment variable.

Windows

Set a persistent user environment variable:

setx OTEL_RESOURCE_ATTRIBUTES "[email protected]"

Replace [email protected] with the developer’s company email.

After setting the variable, sign out and back in, then fully restart Claude Desktop so the app inherits the updated environment.

Why this is required

Without OTEL_RESOURCE_ATTRIBUTES, Claude telemetry may only include an anonymous installation ID. Pensero can still receive usage events, but it cannot reliably map them to the correct developer.

Once this value is configured and Claude Desktop is restarted, Pensero can associate Claude usage with the right user in AI Impact.

Did this answer your question?