Skip to main content

Anthropic/analytics

@webframp/anthropic/analyticsv2026.07.18.1· 7d agoMODELS
01README

Observe Claude Enterprise analytics via the Enterprise Analytics API (/v1/organizations/analytics/*): seat counts, DAU/WAU/MAU, pending invites, feature adoption (projects, skills, connectors), and token cost/usage. Extracts structured seat, adoption, and cost data into separate versioned resources for CEL queries.

Authentication

Requires an Analytics API key (scope read:analytics) created by the primary owner in claude.ai. Store in a swamp vault.

Usage

swamp extension pull @webframp/anthropic/analytics
swamp model create @webframp/anthropic/analytics claude-analytics \
  --global-arg 'analyticsKey=${{ vault.get("anthropic", "ANALYTICS_KEY") }}'

# Collect analytics
swamp model method run claude-analytics collect_analytics

# With date range
swamp model method run claude-analytics collect_analytics \
  --input startDate=2026-06-01 --input endDate=2026-07-01

Methods

  • collect_analytics — fans out across /summaries, /users, and /cost_report; writes snapshot, seats, adoption, and cost resources
  • collect_user_usage — per-user token usage + cost from /user_usage_report and /user_cost_report, grouped by product (Claude Code broken out); optionally filtered to one email. Writes a userUsage resource
02Release Notes

2026.07.18.1

Added: An upgrades array entry (no-op) to analytics.ts for proper typeVersion tracking on existing instances. No schema or behavior changes.

2026.07.14.1

Added: collect_user_usage — per-user token usage and cost, so you can see who is spending what (and how much of it is Claude Code) rather than only the org aggregate.

  • Reads the Enterprise Analytics /v1/organizations/analytics/user_usage_report (tokens: total / output / uncached-input / cache-read, plus requests) and /user_cost_report (amount and list_amount, USD minor units → USD), grouped by product so claude_code is broken out from chat/cowork/etc.

  • Optional email filter keeps just one user (matched on actor.email); products filters the surfaces; startDate/endDate bound the window (defaults to the last 30 days; the API caps a window at 31 days).

  • Writes a userUsage resource (instance = the sanitized email, or all) with a per-user byProduct breakdown plus totalTokens/totalCostUsd. Reuses the same x-api-key (read:analytics) auth and cursor pagination as collect_analytics. The two reports are collected independently: if only user_cost_report fails (common on seat-based plans, where it 403s while the usage report still serves tokens), the token data is retained with collected: true and costUsd left null — collected: false only when both fail. A single email-filtered result is keyed by the user's unique id (user-<userId>) so emails that sanitize alike cannot collide.

    Caveats: with no email filter the resource stores email + name for every org user (admin-only PII — mind shared datastores); and very large orgs can page-truncate (the filter is applied after fetch), so prefer a date-bounded, filtered query for a single user.

Additive: collect_analytics and its snapshot/seats/adoption/cost resources are unchanged.

2026.07.07.1

Fixed:

  • collect_analytics called a non-existent endpoint (/v1/organizations/analytics, HTTP 404) with the wrong param names (start_date/end_date) and a flat-metrics response shape that never matched the real API. Rewritten against the documented Enterprise Analytics API: /analytics/summaries (seats + DAU/WAU/MAU + pending invites, starting_date/ending_date), /analytics/users (paginated, aggregated into adopter counts), and /analytics/cost_report (paginated, summed by cost type).

Added:

  • cost resource — token cost/usage over the window (usage-based Enterprise plans).
  • Adoption and cost collection are best-effort: a failure in /users or /cost_report no longer fails the whole run (seat-based plans have no cost data).

Changed:

  • adoption now reports adopter counts (users with ≥1 project/skill/connector), aggregated from /analytics/users — there is no org-level adoption endpoint.
  • The snapshot resource writes to the recent instance (latest is reserved by swamp). Query via data.latest("claude-analytics", "recent").

2026.07.02.1

Added: Initial release. Enterprise Analytics observation model. Collects raw metrics snapshot and extracts structured seat counts (total, active, pending, DAU/WAU/MAU) and adoption metrics (projects, skills, connectors) into separate versioned resources.

03Models1
@webframp/anthropic/analyticsv2026.07.18.1anthropic/analytics.ts

Global Arguments

ArgumentTypeDescription
analyticsKeystringAnalytics API key (scope read:analytics) from claude.ai (use vault reference)
fn collect_analytics(startDate?: string, endDate?: string)
Collect the enterprise analytics snapshot: activity summaries, feature adoption, and cost. Fans out across /summaries, /users, and /cost_report.
ArgumentTypeDescription
startDate?stringStart date (YYYY-MM-DD, UTC, inclusive; no earlier than 2026-01-01). Defaults to 7 days ago.
endDate?stringEnd date (YYYY-MM-DD, UTC, exclusive). Defaults to today.
fn collect_user_usage(startDate?: string, endDate?: string, email?: string, products?: array)
Per-user token usage and cost from the Enterprise Analytics user_usage_report + user_cost_report endpoints, grouped by product (Claude Code broken out). Optionally filter to one user by email. Degrades (collected:false) rather than throwing when the reports are unavailable (e.g. seat-based plan or missing read:analytics scope).
ArgumentTypeDescription
startDate?stringStart (YYYY-MM-DD, UTC, no earlier than 2026-01-01). Defaults to 30 days ago. Window spans at most 31 days.
endDate?stringEnd (YYYY-MM-DD, UTC). Defaults to now.
email?stringIf set, keep only the user whose actor.email matches (case-insensitive).
products?arrayProduct filter, e.g. ["claude_code"]. Omit for all products; rows are grouped by product either way.

Resources

snapshot(1h)— Raw per-day activity summaries from /analytics/summaries (DAU/WAU/MAU, seats, per-product counts)
seats(1h)— Seat allocation and activity counts for the latest summarized day (total, active, pending, DAU/WAU/MAU)
adoption(6h)— Feature adoption as adopter counts (users using ≥1 project, skill, connector), aggregated from /analytics/users
cost(6h)— Token cost/usage over the window from /analytics/cost_report (usage-based Enterprise plans; zeroed otherwise)
userUsage(6h)— Per-user token usage + cost across products (incl. claude_code) from /analytics/user_usage_report and /user_cost_report; optionally filtered to one email.
04Previous Versions3
2026.07.14.1

Modified 1 models

2026.07.07.1

2026.07.07.1

Fixed:

  • collect_analytics called a non-existent endpoint (/v1/organizations/analytics, HTTP 404) with the wrong param names (start_date/end_date) and a flat-metrics response shape that never matched the real API. Rewritten against the documented Enterprise Analytics API: /analytics/summaries (seats + DAU/WAU/MAU + pending invites, starting_date/ending_date), /analytics/users (paginated, aggregated into adopter counts), and /analytics/cost_report (paginated, summed by cost type).

Added:

  • cost resource — token cost/usage over the window (usage-based Enterprise plans).
  • Adoption and cost collection are best-effort: a failure in /users or /cost_report no longer fails the whole run (seat-based plans have no cost data).

Changed:

  • adoption now reports adopter counts (users with ≥1 project/skill/connector), aggregated from /analytics/users — there is no org-level adoption endpoint.
  • The snapshot resource writes to the recent instance (latest is reserved by swamp). Query via data.latest("claude-analytics", "recent").

2026.07.02.1

Added: Initial release. Enterprise Analytics observation model. Collects raw metrics snapshot and extracts structured seat counts (total, active, pending, DAU/WAU/MAU) and adoption metrics (projects, skills, connectors) into separate versioned resources.

Modified 1 models

2026.07.02.1

2026.07.02.1

Added: Initial release. Enterprise Analytics observation model. Collects raw metrics snapshot and extracts structured seat counts (total, active, pending, DAU/WAU/MAU) and adoption metrics (projects, skills, connectors) into separate versioned resources.

05Stats
A
100 / 100
Downloads
0
Archive size
19.4 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License declared1/1earned
  • Verified public repository2/2earned
06Platforms
07Labels