Analytics
The dashboard’s analytics tab — revenue, members, classes, and workouts metrics for an org’s owner and admins. Implemented as a wide, deliberately denormalized read surface over the operational tables.
What
GET /organizations/:orgId/analytics/... returns per-area summaries and trend series:
| Surface | Endpoint | Service method |
|---|---|---|
| Revenue summary | GET /analytics/revenue/summary | getRevenueSummary |
| Revenue trend | GET /analytics/revenue/trend?months=12 | getRevenueTrend |
| Plan distribution | GET /analytics/revenue/plan-distribution | getPlanDistribution |
| Members summary | GET /analytics/members/summary | getMembersSummary |
| Members growth | GET /analytics/members/growth?months=6 | getMembersGrowth |
| Members activation | GET /analytics/members/activation | getMembersActivation |
| At-risk members | GET /analytics/members/at-risk?sample=5 | getAtRiskMembers |
| Popular classes | GET /analytics/classes/popular?days=30&limit=10 | getPopularClasses |
| Class utilization | GET /analytics/classes/utilization?days=30 | getClassUtilization |
| Workouts summary | GET /analytics/workouts/summary | getWorkoutsSummary |
| Coach overview | GET /analytics/coaches/overview | getCoachOverview |
| CSV export | GET /analytics/export?tab=<tab> | per-tab payload → toCsv |
Why
- Owners track the gym as a business. Without revenue, MRR, debt, churn, and class utilization in one place, they fall back on spreadsheets.
- The same metrics power the Spotter agent’s
analytics.*tool family — agent answers like “how’s the gym doing?” pull from this service. - Keeping every query close to the operational tables means metrics never lag — there is no nightly aggregation job that could drift.
Who
- Owner / admin — full access (role-gated server-side).
- Coach / member — no access (403).
- Spotter agent — staff-only via the agent tools.
Persona impact
| Persona | Impact |
|---|---|
| Owner | Single-pane view on revenue, growth, retention, programming engagement. CSV export for each tab to share with accountant/business advisor. |
| Admin | Same as owner. |
| Coach | Coach Overview (separate endpoint) gives them their own students-and-engagement view; the broader analytics tab is locked. |
Capabilities
Revenue
- MRR computation normalized by plan interval (
INTERVAL_MONTHSmapping inanalytics.service.ts). - Month-over-month delta percentages on MRR and collected revenue.
- Outstanding receivables (subscriptions with debt > 0).
- 12-month trend by month-start bucket; configurable horizon.
- Plan distribution: active subs per plan with monthly revenue contribution.
Members
- Total / active / activated-active counts (the
activatedActivediscriminator distinguishes Clerk-linked from CSV-imported members). - New + churned this month with MoM deltas.
- Activation funnel (
imported→invited→activated). - At-risk sample (past-due subscriptions) with
?sample=Ncap. - Growth trend over configurable months.
Classes
- Most-booked class types over a window.
- Capacity fill rate per class type plus a roll-up.
Workouts
- Assignments scheduled / completed MTD, PRs MTD.
Coach overview
- Per-coach panel: assigned athletes, recent activity, programming load.
CSV exports
- Per-tab synchronous CSV via
GET /analytics/export?tab=...— handler builds the same rows the dashboard renders, then writes them as CSV withContent-Disposition: attachment.
Related features
insights— small ranked widget; the agent’sorg_insightstool delegates to it.payments/subscriptions— source of all revenue metrics.memberships/users— source of growth + activation metrics.class-sessions/bookings/class-types— source of class metrics.workouts/workout-assignments/workout-results— source of workout metrics.spotter-agent—analytics.*tools mirror these endpoints 1:1 for the agent.
Status
Shipped. New endpoints land as the dashboard grows. CSV export covers the most-requested tabs.
Gaps
- All metrics are computed on-read with no caching layer. A 5000-member org with 5 years of payment history will see latency creep. Pre-aggregated rollups remain future work.
- No cohort retention, LTV, or churn curve — only point-in-time counts and MoM deltas.
- Class utilization is over a fixed past window — no “next 30 days at current bookings pace” forecast.
- CSV exports are synchronous; very large orgs may need the async queue path the members export uses.
- No PostHog/Mixpanel-style event funnel — pure SQL aggregations on operational tables.