fix(admin): restore frontend onboarding analytics

Merged
WC
2mo ago
+144-99

Summary

  • replace unsupported PostHog HogQL functions with supported equivalents
  • fail the analytics request when PostHog is unavailable instead of returning misleading zero metrics
  • show a clear dashboard error state while preserving legitimate zero-result analytics
  • add regression coverage for query syntax, all PostHog failure modes, successful empty results, and the UI error state

Motivation

The production Frontend onboarding dashboard displayed 0 attempts even though PostHog contained onboarding events. The deployed query used toInt64OrZero and parseDateTime64BestEffort, which PostHog rejects. The PostHog read helper translated that failure into empty rows, and the dashboard rendered those rows as real zero metrics.

Business impact

Admins can once again use the dashboard to measure onboarding drop-off. Future PostHog query failures will be visible instead of silently appearing as zero customer activity.

Production evidence

  • the live project contained 84 unique frontend onboarding attempts in the selected 90-day window
  • PostHog rejected the deployed function names
  • the same query returned 84 attempts after switching to toIntOrZero and parseDateTimeBestEffort

Test plan

  • bunx vitest run tests/frontend-onboarding-analytics.unit.test.ts tests/admin-frontend-onboarding-dashboard.unit.test.ts tests/translation-queue.unit.test.ts
  • bun test:unit
  • bun run lint
  • bun run lint:backend
  • bun run typecheck:frontend
  • bun run typecheck:backend
  • CHOKIDAR_USEPOLLING=1 bun run build

Summary by CodeRabbit

  • Bug Fixes

    • Added a clear, localized error alert when onboarding analytics fail to load.
    • Hid analytics cards and charts while data is unavailable to prevent misleading results.
    • Improved handling of invalid dates, versions, timeouts, and analytics service failures.
    • Empty successful analytics responses are now handled correctly.
  • Tests

    • Added coverage for dashboard error states, translated messaging, and analytics failure scenarios.