Skip to content

feat(cli): track CLI version headers and admin usage analytics - #2906

Open
riderx wants to merge 4 commits into
mainfrom
feat/cli-usage-analytics
Open

feat(cli): track CLI version headers and admin usage analytics#2906
riderx wants to merge 4 commits into
mainfrom
feat/cli-usage-analytics

Conversation

@riderx

@riderx riderx commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary (AI generated)

  • Capgo CLI now sends x-cli-version, x-cli-command, x-cli-node, and x-cli-os (plus optional capgkey) on Capgo API calls, especially /private/config
  • Backend records CLI usage to Cloudflare Analytics Engine (cli_usage) on workerd, or Postgres public.cli_usage for self-host / Supabase functions
  • Admin dashboard adds a CLI tab with version/command breakdowns, daily trend, and top API-key activity

Motivation (AI generated)

We lack visibility into which CLI versions and commands customers run against Capgo cloud. Config fetches are a natural, low-cost signal to attribute CLI adoption and upgrade lag without instrumenting every hot private route.

Business Impact (AI generated)

Enables support and product to see CLI version distribution, popular commands, and API-key activity. Helps prioritize deprecations, spot stuck old CLI versions, and measure command usage that drives retention and upgrade messaging.

Test Plan (AI generated)

  • bunx vitest run tests/cli-usage.unit.test.ts tests/admin-stats.unit.test.ts
  • Confirm CLI /private/config request includes the new x-cli-* headers (and capgkey when a saved key exists)
  • On workerd with CLI_USAGE bound, confirm Analytics Engine receives writeDataPoints
  • On self-host, confirm rows land in public.cli_usage after config pull
  • Open admin dashboard /admin/dashboard/cli and verify totals, charts, and top API keys for a date range
  • Create Cloudflare Analytics Engine dataset cli_usage in the CF dashboard if missing, then deploy worker bindings

Generated with AI

Made with Cursor


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0f6c0688-7651-42b9-813b-62a26ec66f40

📥 Commits

Reviewing files that changed from the base of the PR and between 662ced3 and f81ed03.

📒 Files selected for processing (52)
  • cli/TODO_HTTP_API.md
  • cli/src/ai/analyze.ts
  • cli/src/analytics/cli-headers.ts
  • cli/src/analytics/org-resolver.ts
  • cli/src/api/app.ts
  • cli/src/api/channels.ts
  • cli/src/api/versions.ts
  • cli/src/app/add.ts
  • cli/src/app/debug.ts
  • cli/src/app/delete.ts
  • cli/src/app/list.ts
  • cli/src/app/set.ts
  • cli/src/app/updateProbe.ts
  • cli/src/build/credentials-command.ts
  • cli/src/build/onboarding/mcp/broker-oauth.ts
  • cli/src/build/request.ts
  • cli/src/bundle/cleanup.ts
  • cli/src/bundle/delete.ts
  • cli/src/bundle/list.ts
  • cli/src/bundle/partial.ts
  • cli/src/bundle/unlink.ts
  • cli/src/bundle/upload.ts
  • cli/src/channel/add.ts
  • cli/src/channel/currentBundle.ts
  • cli/src/channel/delete.ts
  • cli/src/channel/list.ts
  • cli/src/channel/set.ts
  • cli/src/index.ts
  • cli/src/init/command.ts
  • cli/src/init/replay.ts
  • cli/src/notifications/send-update.ts
  • cli/src/organization/delete.ts
  • cli/src/organization/members.ts
  • cli/src/organization/set.ts
  • cli/src/preview/qr.ts
  • cli/src/sdk.ts
  • cli/src/support/support-upload.ts
  • cli/src/utils.ts
  • cli/test/test-preview-qr.mjs
  • cloudflare_workers/api/wrangler.jsonc
  • messages/en.json
  • src/constants/adminTabs.ts
  • src/pages/admin/dashboard/cli.vue
  • src/stores/adminDashboard.ts
  • supabase/functions/_backend/private/admin_stats.ts
  • supabase/functions/_backend/private/config.ts
  • supabase/functions/_backend/utils/cli_usage.ts
  • supabase/functions/_backend/utils/cloudflare.ts
  • supabase/functions/_backend/utils/hono.ts
  • supabase/migrations/20260807101112_cli_usage.sql
  • tests/admin-stats.unit.test.ts
  • tests/cli-usage.unit.test.ts

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_7004cb08-ceb9-4f58-bbb3-9e867be6bc78)

@codspeed-hq

codspeed-hq Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing feat/cli-usage-analytics (f81ed03) with main (662ced3)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 16 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread supabase/migrations/20260807101112_cli_usage.sql
Comment thread supabase/functions/_backend/private/config.ts
Comment thread cloudflare_workers/api/wrangler.jsonc
Comment thread cli/src/utils.ts
Comment thread supabase/migrations/20260807101112_cli_usage.sql
Comment thread src/pages/admin/dashboard/cli.vue Outdated
Comment thread src/pages/admin/dashboard/cli.vue
Comment thread src/pages/admin/dashboard/cli.vue
Comment thread tests/admin-stats.unit.test.ts Outdated
Comment thread supabase/functions/_backend/utils/cli_usage.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_f7afaf21-13a1-4b1f-80b7-3c0366890fc6)

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 20 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread cli/src/ai/analyze.ts
Comment thread cli/src/support/support-upload.ts
Comment thread cli/src/api/app.ts Outdated
Comment thread supabase/migrations/20260807101112_cli_usage.sql
Comment thread cli/src/support/support-upload.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_44b115b0-ff76-4332-a8d1-aabdd96761db)

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 30 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread cli/src/api/channels.ts
Comment thread cli/src/api/versions.ts
Comment thread cli/src/bundle/upload.ts
Comment thread cli/src/init/command.ts
Comment thread cli/src/init/command.ts
Comment thread cli/src/app/set.ts
Comment thread cli/src/api/versions.ts
Comment thread cli/src/preview/qr.ts
Comment thread cli/src/preview/qr.ts
Comment thread cli/src/app/debug.ts
Keep both builder_capacity and cli_usage admin metrics, and prefer the
HTTP app existence check with the shared app-add hint message.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_a429a64b-45c6-4178-898c-2ca2e080f84b)

@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

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.

1 participant