Skip to content

feat(analytics): PR-D -- Usage Analytics v1 frontend dashboard - #40

Merged
man4ish merged 1 commit into
mainfrom
feature/analytics-d-frontend
Aug 12, 2026
Merged

feat(analytics): PR-D -- Usage Analytics v1 frontend dashboard#40
man4ish merged 1 commit into
mainfrom
feature/analytics-d-frontend

Conversation

@man4ish

@man4ish man4ish commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fourth and final sub-PR implementing Usage Analytics v1 (#37 PR-A, #38 PR-B, #39 PR-C). Frontend for the merged /analytics/* API.

  • analytics.ts -- typed data layer for all 7 GET endpoints + CSV export (fetched with Authorization, not a bare link). /analytics/performance's type pins org_id/team_id to null, matching the backend's hard requirement that those numbers are never tenant-scoped.
  • pages/AnalyticsDashboard.tsx -- reuses the existing DashboardGrid/MetricCard family (PR10) and recharts (already used by BillingPage.tsx/EcosystemPage.tsx, same colors -- no new visual system, per the task brief's own instruction). Overview cards, trend chart, DAU/WAU/MAU, service table, performance cards, 7d/30d/90d presets, CSV export, org filter (platform_admin only).
  • auth.ts -- canSeeAnalytics(), UX mirror of the backend's RBAC matrix, built from existing SessionUser fields (no new claim).
  • navigation.ts/AdminApp.tsx -- wired exactly like interactions was.

Test plan

  • npm test: 474 passed (38 files), zero regressions.
  • AnalyticsDashboard.test.tsx (10 tests): load, date-range re-fetch, API failure + retry, 403 state, empty-data state, null → "--" rendering, CSV export success/failure, org filter visibility by role.
  • tsc -b and vite build --mode admin both clean.

🤖 Generated with Claude Code

Fourth and final sub-PR. Frontend for the /analytics/* API (#39 PR-C).

- analytics.ts: data layer, mirroring interactions.ts's own shape --
  typed fetch wrappers for all 7 GET endpoints plus exportAnalyticsCsv
  (fetched, not a bare <a href>, so Authorization can be attached; blob
  download). /analytics/performance's response type pins org_id/team_id
  to `null` and scope to 'platform' at the type level, matching the
  backend's own hard requirement that those numbers are never presented
  as tenant-scoped.
- pages/AnalyticsDashboard.tsx: reuses the existing DashboardGrid/
  MetricCard widget family (PR10) and recharts (already a dependency,
  already used by BillingPage.tsx/EcosystemPage.tsx -- same chart colors,
  no new visual system). Overview cards, a queries/active-users trend
  line chart, DAU/WAU/MAU, a service breakdown table, performance cards
  (explicitly labeled platform-wide), 7d/30d/90d date presets, CSV
  export, and an organization filter shown only to a platform_admin (an
  org_admin/team_admin's scope is already fixed server-side to their own
  org/team). Null values render as "--", never a fabricated number, same
  convention DashboardPage.tsx already established.
- auth.ts: canSeeAnalytics(), a UX-only mirror of the backend's
  require_analytics_scope matrix (platform_admin/org_admin/team_admin
  allowed, regular member denied) built from the SessionUser fields
  Phase 1 PR3/Team Management v0.8.0 already put there (orgRoles,
  teamRole) -- no new claim, no new auth mechanism.
- navigation.ts / AdminApp.tsx: wired in exactly like 'interactions' was
  -- one NAV entry (Business section, next to Billing) gated by
  canSeeAnalytics, one switch case rendering AnalyticsDashboard.

Test plan: `npm test` -- 474 passed (38 files), no regressions.
AnalyticsDashboard.test.tsx (10 tests): loads and renders live data,
date-range re-fetch, API failure + retry, 403 permission-denied state,
empty-data state, null-value "--" rendering, CSV export (success +
failure), organization filter shown only for a platform_admin.
`tsc -b` and `vite build --mode admin` both clean.
@man4ish
man4ish merged commit 41c1050 into main Aug 12, 2026
1 check passed
@man4ish
man4ish deleted the feature/analytics-d-frontend branch August 12, 2026 04:00
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