Skip to content

dev: Metabase cleanup#3582

Merged
isTravis merged 4 commits intomainfrom
tr/metabase-clean
Apr 16, 2026
Merged

dev: Metabase cleanup#3582
isTravis merged 4 commits intomainfrom
tr/metabase-clean

Conversation

@isTravis
Copy link
Copy Markdown
Member

@isTravis isTravis commented Apr 16, 2026

The only remaining use of Metabase on the app was an old /admin page dashboard. This PR updates that dashboard to use native PG data, and removes all remaining metabase code.

The /admin page previously embedded a Metabase iframe that displayed the
"PubPub Top Metrics" dashboard. This has been replaced with a native Analytics
tab on the Superadmin dashboard (/superadmin/analytics). The old /admin URL
now 301-redirects to /superadmin/analytics.

All data is served by a single API endpoint (GET /api/platformAnalytics) that
is restricted to superadmin users. Results are cached in-memory for 1 hour.

A second endpoint (GET /api/platformAnalytics/period) provides date-range
filtered counts and a paginated new-communities table.


Files changed / created

File Change
server/platformAnalytics/api.ts New. API endpoint with two routes: all-time overview + period drill-down.
client/containers/SuperAdminDashboard/PlatformAnalytics.tsx New. React component with recharts graphs and date-range explorer.
client/containers/SuperAdminDashboard/platformAnalytics.scss New. Grid layout with responsive breakpoints.
client/containers/SuperAdminDashboard/tabs.tsx Added analytics tab entry.
utils/superAdmin.ts Added 'analytics' to superAdminTabKinds.
server/apiRoutes.ts Registered platformAnalyticsRouter.
server/routes/adminDashboard.tsx Replaced Metabase iframe SSR with a 301 redirect.
client/containers/index.ts Removed AdminDashboard export.
client/containers/App/paths.ts Removed AdminDashboard path entry.

Graph details

All-Time Totals (scalar cards)

Metric Query Source
Total Communities SELECT COUNT(*) FROM "Communities" Communities table
Registered Users SELECT COUNT(*) FROM "Users" Users table
Total Pubs SELECT COUNT(*) FROM "Pubs" Pubs table
Total Pageviews SELECT SUM(page_views) FROM analytics_daily_summary analytics_daily_summary materialized view (pre-aggregated from AnalyticsEvents)

Cumulative Growth (area charts)

Each chart shows total-to-date as an area fill. Data is computed client-side by
cumulatively summing the monthly series.

Chart Query Source
Communities GROUP BY DATE_TRUNC('month', "createdAt") Communities table
Users GROUP BY DATE_TRUNC('month', "createdAt") Users table
Pubs GROUP BY DATE_TRUNC('month', "createdAt") Pubs table
Pageviews GROUP BY DATE_TRUNC('month', date) with SUM(page_views) analytics_daily_summary materialized view

The server returns raw per-month counts. The client component runs a running
sum to produce the cumulative series for the area chart.

Monthly Growth (line charts)

Same underlying data as Cumulative Growth, but plotted as raw monthly counts
(no accumulation). Each line shows how many new entities were created that month.

Active Communities (dual line chart)

Two lines on the same chart:

Line Query Source
By Activity COUNT(DISTINCT "communityId") GROUP BY month ActivityItems table – counts distinct communities with any activity item per month
By Pub Creation COUNT(DISTINCT "communityId") GROUP BY month from Pubs Pubs table – counts distinct communities that had at least one pub created per month

Series are merged client-side by month key and sorted chronologically.

Period Explorer (bottom section)

Driven by GET /api/platformAnalytics/period?startDate=…&endDate=…&page=….

Metric Query Source
New Communities COUNT(*) FROM "Communities" WHERE "createdAt" BETWEEN … Communities table
New Users COUNT(*) FROM "Users" WHERE "createdAt" BETWEEN … Users table
New Pubs COUNT(*) FROM "Pubs" WHERE "createdAt" BETWEEN … Pubs table
Pageviews SUM(page_views) FROM analytics_daily_summary WHERE date BETWEEN … analytics_daily_summary materialized view
New Communities Table SELECT title, subdomain, createdAt, description FROM "Communities" WHERE "createdAt" BETWEEN … ORDER BY "createdAt" DESC LIMIT 25 OFFSET … Communities table

Preset buttons: 30 days, 90 days, 1 year, 2 years. Custom date inputs use
native <input type="date">.


Performance

  • In-memory cache with 1-hour TTL for the all-time overview endpoint.
  • Materialized views: Pageview total and monthly series read from
    analytics_daily_summary (pre-aggregated by community + day) instead of
    scanning millions of raw AnalyticsEvents rows.
  • Period endpoint is not cached (date range varies) but queries are fast
    because they filter on indexed createdAt columns and the matview's
    (communityId, date) unique index.

@isTravis isTravis merged commit 0b67273 into main Apr 16, 2026
1 check passed
@isTravis isTravis deleted the tr/metabase-clean branch April 16, 2026 18:11
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