Configure Claude Code telemetry hooks. Two setup paths — lightweight Langfuse cloud (quick start) or self-hosted custom dashboard + FastAPI backend (full observability, no cloud).
Configure Claude Code to emit telemetry events from its lifecycle hooks.
Trigger when: Setting up observability for Claude Code sessions, tracking tool usage, monitoring session activity, or deploying the custom telemetry dashboard.
Streams events to Langfuse cloud. Free tier available, zero infra.
Steps:
~/.claude/LANGFUSE_CONFIG.env:
LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_HOST=https://cloud.langfuse.com
~/.claude/settings.json reference the telemetry hook scripts (see Hook Integration section below)Runs a local FastAPI backend on :5001 and a Next.js dashboard on :3001. All data stays local (SQLite). Provides live feed, session timeline, tool inspector, and metrics panels.
Stack:
backend/ — FastAPI + SQLAlchemy + SQLite, exposes /events, /sessions, /metrics, /live, WebSocket at /ws/sessions/{id}dashboard/ — Next.js 14, Tailwind CSS, Recharts, SWR for live pollingOne-command setup:
python3 ~/.claude/skills/setup-telemetry/scripts/setup_custom_dashboard.py
This script:
backend/ and dashboard/ to ~/.paperclip/instances/ (configurable via --dest)pip install -r requirements.txt in backendnpm install in dashboard:5001 (daemonized, logs to backend.log):3001 (daemonized, logs to dashboard.log)~/.claude/hooks/*.py to POST to http://localhost:5001/eventsCustom destination:
python3 ~/.claude/skills/setup-telemetry/scripts/setup_custom_dashboard.py --dest ~/my/instances
After setup:
{dest}/telemetry-backend/backend.log, {dest}/telemetry-dashboard/dashboard.logStop services:
kill $(cat ~/.paperclip/instances/telemetry-backend/.backend.pid)
kill $(cat ~/.paperclip/instances/telemetry-dashboard/.dashboard.pid)
The telemetry hooks live in ~/.claude/hooks/ and are registered in ~/.claude/settings.json:
| Hook file | Event | What it sends |
|---|---|---|
session_start_telemetry.py | SessionStart | session ID, cwd, project name |
pre_tool_use_telemetry.py | PreToolUse | tool name, tool input |
post_tool_use_telemetry.py | PostToolUse | tool name, output, duration, errors |
session_end_telemetry.py | SessionEnd | duration, session summary |
All hooks POST to http://localhost:5001/events (Path B) or use langfuse_client (Path A). They fail silently to avoid blocking Claude Code tool execution.
Event schema (POST /events):
{
"session_id": "claude-code-abc123",
"event_type": "PreToolUse | PostToolUse | SessionStart | SessionEnd",
"tool_name": "Bash",
"tool_input": {},
"tool_output": {},
"duration_ms": 142.5,
"error_message": null,
"metadata": {}
}
This skill ships with the full source for both services:
setup-telemetry/
backend/ FastAPI backend (app.py, database.py, models.py, requirements.txt)
dashboard/ Next.js frontend (app/, components/, lib/)
scripts/
setup_custom_dashboard.py Deployment + startup script
SKILL.md
The bundled source is a snapshot. To update it from the running instances:
rsync -av --exclude='node_modules/' --exclude='.next/' \
~/.paperclip/instances/telemetry-dashboard/ \
~/.claude/skills/setup-telemetry/dashboard/
rsync -av --exclude='__pycache__/' --exclude='*.db' \
~/.paperclip/instances/telemetry-backend/ \
~/.claude/skills/setup-telemetry/backend/
except blocks swallow all errors; a broken backend never blocks Claude tool executionws://localhost:5001/ws/sessions/{id} for real-time updates without polling:5001, dashboard :3001 (avoids conflicts with common :3000/:5000 dev servers)