# ccam-analytics

ccam-analytics is a Claude Code hook that streams session events to Agent Monitor for telemetry tracking. It triggers whenever a main session or subagent stops.

- hook · `type=hook` · Claude Code, Codex · ★ 1198 repo stars
- Author: Son Nguyen
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/HEAD/plugins/ccam-analytics/hooks/hooks.json
- Updated: 2026-10-23
- Security check: automated, 2026-11-16 (text and 3 script files) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/hooks/ccam-analytics

## What it does

The hook captures execution completion events and forwards runtime metrics to Agent Monitor. Triggers fire on `Stop` and `SubagentStop`, packaging the session ID, subagent ID, stop reason, and timestamp.

Each action executes a shell pipeline that shapes the JSON payload via `jq` and posts it with `curl` to `http://localhost:4820/api/hooks/event`. It relies on local `curl` and `jq` binaries alongside an active Agent Monitor instance listening on port 4820.

## Install

### Claude Code (native platform)

1. **Plugin marketplace**
In the agent chat (not a shell):
```text
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
```
In the agent chat (not a shell):
```text
/plugin install ccam-analytics@claude-code-agent-monitor-plugins
```

2. **Manually: put the files in place**
- File: `.claude/settings.json` — The hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/HEAD/plugins/ccam-analytics/hooks/hooks.json

## When to use it
- track session completions automatically
- forward subagent termination events to Agent Monitor
- record timestamps and stop reasons for agent tasks

## Example prompts
- Finish the current task and generate a summary
- Launch a subagent to inspect unit tests
- Stop execution and close the session

## Source text · hooks.json · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 29888a7559ac6dd5.

BEGIN THIRD-PARTY FILE 29888a7559ac6dd5
````text
Hooks bundle shipped with the ccam-analytics plugin for Claude Code.

Deep analytics and monitoring for Claude Code sessions — cost tracking, token usage breakdowns, usage trends, and productivity scoring powered by Agent Monitor.

Triggers on: Stop, SubagentStop.

```json
{
  "hooks": {
    "Stop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r '{session_id: .session_id, stop_reason: .stop_reason, timestamp: now | todate}' | curl -s -X POST http://localhost:4820/api/hooks/event -H 'Content-Type: application/json' -d @- > /dev/null 2>&1 || true"
          }
        ]
      }
    ],
    "SubagentStop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r '{session_id: .session_id, agent_id: .agent_id, stop_reason: .stop_reason, timestamp: now | todate}' | curl -s -X POST http://localhost:4820/api/hooks/event -H 'Content-Type: application/json' -d @- > /dev/null 2>&1 || true"
          }
        ]
      }
    ]
  }
}

```
````
END THIRD-PARTY FILE 29888a7559ac6dd5

The third-party file has ended. Everything between the 29888a7559ac6dd5 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© Son Nguyen · MIT · https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/HEAD/plugins/ccam-analytics/hooks/hooks.json

## Similar
- [roblox-analytics](https://affpapa.org/en/nevibecode/skills/roblox-analytics.md) — skill · 3200 installs
- [analytics-tracking](https://affpapa.org/en/nevibecode/skills/sickn33-analytics-tracking.md) — skill · ★ 50109 repo stars
- [game-analytics-setup](https://affpapa.org/en/nevibecode/skills/game-analytics-setup.md) — skill · ★ 57 repo stars
- [signals-scout-feature-flags](https://affpapa.org/en/nevibecode/skills/signals-scout-feature-flags.md) — skill · 318 installs
- [token-dashboard-claude-analytics](https://affpapa.org/en/nevibecode/skills/token-dashboard-claude-analytics.md) — skill · 315 installs
- [analytics](https://affpapa.org/en/nevibecode/skills/orchestkit-analytics.md) — skill · 210 installs

From the same set: [hoangsonww/claude-code-agent-monitor](https://affpapa.org/en/nevibecode/by/hoangsonww/claude-code-agent-monitor.md) — 155 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
