Skip to content

feat(ui): add usage analytics dashboard with time-series charts#2028

Closed
rom1504 wants to merge 7 commits intoopenclaw:mainfrom
rom1504:feat/ui-usage-analytics
Closed

feat(ui): add usage analytics dashboard with time-series charts#2028
rom1504 wants to merge 7 commits intoopenclaw:mainfrom
rom1504:feat/ui-usage-analytics

Conversation

@rom1504
Copy link
Copy Markdown

@rom1504 rom1504 commented Jan 26, 2026

Summary

Add a new Analytics tab to the Control UI dashboard that visualizes token usage and plan quota:

Plan Quota Section

  • Usage bar graphs: Visual display of usage against plan limits (5h, weekly, model-specific)
  • Reset timers: Shows when rate limits will reset
  • Claude Code support: Shows helpful message with link to claude.ai for users with Claude Code OAuth tokens (which lack the user:profile scope required for programmatic quota access)

Usage Summary Section

  • Summary stats cards: Total tokens, input/output tokens, cache read/write, estimated cost
  • Daily token usage bar chart: Visual time-series of token consumption
  • Daily cost bar chart: Visual time-series of estimated costs
  • Configurable time period: 7, 14, 30, or 90 day views

Uses the existing usage.cost and usage.status gateway endpoints.

Screenshot

Analytics Dashboard

Changes

New Files

  • ui/src/ui/views/analytics.ts - View with quota bars and usage charts (pure CSS, no charting library)
  • ui/src/ui/controllers/analytics.ts - Data fetching controller
  • scripts/analytics-screenshot.mjs - Screenshot script for docs
  • docs/images/control-ui-analytics.png - Screenshot

Modified Files

  • ui/src/ui/navigation.ts - Add analytics tab
  • ui/src/ui/app.ts - Add analytics state properties
  • ui/src/ui/app-view-state.ts - Add analytics state types
  • ui/src/ui/app-render.ts - Wire up analytics view rendering
  • ui/src/ui/app-settings.ts - Load analytics data on tab switch
  • docs/web/control-ui.md - Add analytics documentation

Test Plan

  • Navigate to Analytics tab
  • Verify Plan Quota section shows helpful message for Claude Code users
  • Verify summary stats show token counts and cost
  • Verify bar charts render daily data
  • Change time period dropdown and verify data refreshes
  • Click Refresh button to reload data

🤖 Generated with Claude Code

@rom1504 rom1504 marked this pull request as draft January 26, 2026 02:09
@rom1504 rom1504 force-pushed the feat/ui-usage-analytics branch from 3ef9a49 to a37871f Compare January 26, 2026 02:09
@rom1504
Copy link
Copy Markdown
Author

rom1504 commented Jan 26, 2026

WIP not ready

rom1504 and others added 2 commits January 26, 2026 02:11
Add a new Analytics tab to the Control UI that displays:
- Summary stats: total tokens, input/output, cache read/write, estimated cost
- Daily token usage bar chart
- Daily cost bar chart
- Configurable time period (7/14/30/90 days)

Uses existing usage.cost gateway endpoint which returns daily aggregated
data from session transcripts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add analytics view helper function tests
- Add analytics controller state tests
- Add data type validation tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rom1504 rom1504 force-pushed the feat/ui-usage-analytics branch from a37871f to 6abd372 Compare January 26, 2026 02:26
rom1504 and others added 2 commits January 26, 2026 03:05
- Fix analytics loading bug where client.request returns payload directly
- Add plan quota section showing usage against plan limits (5h, weekly windows)
- Display provider errors when OAuth token lacks required scopes
- Add helpful message when no quota data is available
- Add screenshot script with dynamic Playwright chromium detection
- Update tests for quota state and parallel data fetching

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When using Claude Code OAuth tokens (which lack user:profile scope),
display a helpful message directing users to check their usage at
claude.ai instead of showing an error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rom1504 rom1504 force-pushed the feat/ui-usage-analytics branch 2 times, most recently from f7ef4fa to 36523e7 Compare January 26, 2026 03:38
rom1504 and others added 3 commits January 26, 2026 03:43
- Add Analytics section to Control UI docs explaining quota and usage features
- Add screenshot script with dynamic token loading from config
- Update screenshot showing the analytics dashboard

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move screenshot to standard docs/images location
- Update control-ui.md to reference correct image path
- Improve screenshot script with better click fallbacks
- Remove duplicate screenshot from docs/gateway/images

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rom1504
Copy link
Copy Markdown
Author

rom1504 commented Jan 26, 2026

Ok it works now, ready for review.

@rom1504 rom1504 marked this pull request as ready for review January 26, 2026 03:56
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui labels Jan 26, 2026
@sebslight
Copy link
Copy Markdown
Member

Closing due to merge conflicts. Please rebase on main and reopen if you'd like to continue with this contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants