feat(admin): track users with 2FA on users trend

Merged
RI
2mo ago
+137-29

Summary (AI generated)

  • Snapshot users_with_2fa in daily global_stats: how many Capgo users have at least one verified MFA factor
  • Overlay that series on the admin Users Trend chart

Motivation (AI generated)

We already know who has 2FA at request time (has_2fa_enabled), but the admin dashboard had no daily view of how many people actually set it up.

Business Impact (AI generated)

Makes 2FA adoption visible over time so we can see whether org enforcement and onboarding are actually getting people onto MFA.

Test Plan (AI generated)

  • Confirm the core global stats shard writes users_with_2fa
  • Open /admin/dashboard/users and check Users Trend shows Users with 2FA next to paying and trial orgs
  • Confirm historical days stay 0 until the next daily snapshot
  • Unit test: bunx vitest run tests/logsnag-insights-revenue.unit.test.ts

Visual changes (AI generated)

Users Trend chart with the new 2FA series:

Admin Users Trend chart with users-with-2FA series

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.

Summary by CodeRabbit

  • New Features
    • Added a “Users with 2FA” series to the admin dashboard’s user trends chart.
    • Global statistics now track users with verified and completed 2FA.
    • Added English localization for the new metric.
  • Bug Fixes
    • Added safe zero-value handling when 2FA statistics are unavailable.
    • Improved compatibility with deployments where newer statistics fields are not yet available.
  • Tests
    • Added coverage validating 2FA statistics collection and dashboard reporting.