Skip to content

Add most popular apps and APIs sections to daily admin report#135

Merged
jalexw merged 2 commits into
mainfrom
claude/compassionate-dirac-jbrOE
Jun 4, 2026
Merged

Add most popular apps and APIs sections to daily admin report#135
jalexw merged 2 commits into
mainfrom
claude/compassionate-dirac-jbrOE

Conversation

@jalexw

@jalexw jalexw commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Extends the daily admin report to include two new sections: "Most popular applications" and "Most popular APIs", providing visibility into which client apps and API servers are generating the most token activity.

Key Changes

  • New database query functions:

    • listTopMostPopularAppsSince() - Ranks client applications by total tokens issued (access + refresh combined)
    • listTopMostPopularApisSince() - Ranks API servers by access tokens issued (refresh tokens excluded since they're always issued to the auth server)
    • countTokensIssuedSinceGroupedByColumn() - Shared utility to group token counts by arbitrary issued_tokens columns
  • Report generation updates:

    • Added HTML table sections for both apps and APIs with rank, name, ID, and token counts
    • Added plain-text equivalents for email clients without HTML support
    • Both sections display "No activity" message when empty
    • Token counts formatted with locale-aware number formatting
  • Data flow:

    • sendDailyReportHandler now fetches top apps and APIs in parallel with other report data
    • Passes results to buildDailyAdminReport which renders both HTML and text versions
    • Includes counts in telemetry logging

Implementation Details

  • Apps are ranked by total tokens (access + refresh) since both token types carry the real client_app_id
  • APIs are ranked by access tokens only, as refresh tokens are always issued with the auth server as audience
  • Both functions resolve human-readable names from hardcoded app/API definitions or database lookups
  • Consistent styling with existing report sections (brand colors, borders, typography)
  • Default limit of 10 items per section, configurable via function parameters

https://claude.ai/code/session_015YubdbmA5Vtzi2ydEJNqmt

Summarize which client applications and APIs are driving token usage.
Adds "Most popular applications" (grouped by issued_tokens.client_app_id,
ranked by total access + refresh tokens) and "Most popular APIs" (grouped
by token audience, ranked by access tokens) sections to both the HTML and
plain-text daily admin report, mirroring the existing top most-active
users section.

https://claude.ai/code/session_015YubdbmA5Vtzi2ydEJNqmt
@jalexw jalexw self-assigned this Jun 4, 2026
@jalexw jalexw merged commit d599db0 into main Jun 4, 2026
43 checks passed
@jalexw jalexw deleted the claude/compassionate-dirac-jbrOE branch June 4, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants