feat(cli): track CLI version headers and admin usage analytics
Merged
RI
2mo ago+2286+2286+0123456789012345678901234567890123456789-804-804-012345678901234567890123456789
Summary (AI generated)
- Capgo CLI now sends
x-cli-version,x-cli-command,x-cli-node, andx-cli-os(plus optionalcapgkey) on Capgo API calls, especially/private/config - Backend records CLI usage to Cloudflare Analytics Engine (
cli_usage) on workerd, or Postgrespublic.cli_usagefor 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/configrequest includes the newx-cli-*headers (andcapgkeywhen a saved key exists) - On workerd with
CLI_USAGEbound, confirm Analytics Engine receives writeDataPoints - On self-host, confirm rows land in
public.cli_usageafter config pull - Open admin dashboard
/admin/dashboard/cliand verify totals, charts, and top API keys for a date range - Create Cloudflare Analytics Engine dataset
cli_usagein the CF dashboard if missing, then deploy worker bindings
Generated with AI
Made with Cursor
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by CodeRabbit
-
New Features
- Added an admin CLI usage dashboard with date filtering, summaries, charts, and API-key usage details.
- Added CLI usage analytics and support for tracking command, version, operating system, and Node.js metadata.
- Added optional custom Supabase anonymous-key configuration during onboarding.
- Expanded CLI API support for app, version, channel, organization, bundle, and preview operations.
-
Bug Fixes
- Improved pagination, missing-resource handling, error reporting, and cleanup safeguards across CLI workflows.