fix(stats): unify success rate formula across admin and public metrics
Summary (AI generated)
- Public
/datalive update metrics now compute headline success rate fromversion_usageusinginstall / (install + fail), matching the admin dashboard formula. - Fixed
getUpdateStatsCF,getUpdate_statsSQL, andgetUpdateStatsSB, which previously usedget / (install + get)— not a real install success rate. - Public dimensional breakdowns (platform/country/version) now use event counts from
app_loginstead of device-day dedup that produced a separate ~70% number.
Motivation (AI generated)
The marketing /data page and admin dashboard showed different success rates because they used different datasets and formulas. A prior fix aligned public stats with global_stats, but a follow-up PR reintroduced a separate Analytics Engine device-day calculation from app_log. Meanwhile, the cron snapshot stored in global_stats used get/(install+get), which is also semantically wrong for "successful update installations".
Business Impact (AI generated)
Capgo can now publish one consistent, correct install success rate on the marketing page and admin dashboard. This removes misleading lower public numbers and prevents overstating success via the old get-ratio formula.
Test Plan (AI generated)
-
npx vitest run tests/public-live-update-metrics.unit.test.ts tests/public-stats.unit.test.ts tests/cron-email-stats-backtest.unit.test.ts - Deploy and compare
/private/website_stats/live_updatessuccess_rate with adminsuccess_ratemetric for the same 30-day window - Verify next
global_statscron run stores updated success_rate values after migration
Generated with AI


Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by CodeRabbit
-
Bug Fixes
- Improved update success-rate accuracy by counting completed installs and failures, excluding download events.
- Updated live metrics to reflect outcomes across platforms, countries, and updater versions more reliably.
- Preserved existing app health-status thresholds while correcting the underlying calculations.
-
Tests
- Updated analytics coverage to verify install/failure-based metrics and version-usage data.