Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The only remaining use of Metabase on the app was an old
/adminpage dashboard. This PR updates that dashboard to use native PG data, and removes all remaining metabase code.The
/adminpage 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/adminURLnow 301-redirects to
/superadmin/analytics.All data is served by a single API endpoint (
GET /api/platformAnalytics) thatis restricted to superadmin users. Results are cached in-memory for 1 hour.
A second endpoint (
GET /api/platformAnalytics/period) provides date-rangefiltered counts and a paginated new-communities table.
Files changed / created
server/platformAnalytics/api.tsclient/containers/SuperAdminDashboard/PlatformAnalytics.tsxclient/containers/SuperAdminDashboard/platformAnalytics.scssclient/containers/SuperAdminDashboard/tabs.tsxanalyticstab entry.utils/superAdmin.ts'analytics'tosuperAdminTabKinds.server/apiRoutes.tsplatformAnalyticsRouter.server/routes/adminDashboard.tsxclient/containers/index.tsAdminDashboardexport.client/containers/App/paths.tsAdminDashboardpath entry.Graph details
All-Time Totals (scalar cards)
SELECT COUNT(*) FROM "Communities"CommunitiestableSELECT COUNT(*) FROM "Users"UserstableSELECT COUNT(*) FROM "Pubs"PubstableSELECT SUM(page_views) FROM analytics_daily_summaryanalytics_daily_summarymaterialized view (pre-aggregated fromAnalyticsEvents)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.
GROUP BY DATE_TRUNC('month', "createdAt")CommunitiestableGROUP BY DATE_TRUNC('month', "createdAt")UserstableGROUP BY DATE_TRUNC('month', "createdAt")PubstableGROUP BY DATE_TRUNC('month', date)withSUM(page_views)analytics_daily_summarymaterialized viewThe 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:
COUNT(DISTINCT "communityId") GROUP BY monthActivityItemstable – counts distinct communities with any activity item per monthCOUNT(DISTINCT "communityId") GROUP BY monthfromPubsPubstable – counts distinct communities that had at least one pub created per monthSeries are merged client-side by month key and sorted chronologically.
Period Explorer (bottom section)
Driven by
GET /api/platformAnalytics/period?startDate=…&endDate=…&page=….COUNT(*) FROM "Communities" WHERE "createdAt" BETWEEN …CommunitiestableCOUNT(*) FROM "Users" WHERE "createdAt" BETWEEN …UserstableCOUNT(*) FROM "Pubs" WHERE "createdAt" BETWEEN …PubstableSUM(page_views) FROM analytics_daily_summary WHERE date BETWEEN …analytics_daily_summarymaterialized viewSELECT title, subdomain, createdAt, description FROM "Communities" WHERE "createdAt" BETWEEN … ORDER BY "createdAt" DESC LIMIT 25 OFFSET …CommunitiestablePreset buttons: 30 days, 90 days, 1 year, 2 years. Custom date inputs use
native
<input type="date">.Performance
analytics_daily_summary(pre-aggregated by community + day) instead ofscanning millions of raw
AnalyticsEventsrows.because they filter on indexed
createdAtcolumns and the matview's(communityId, date)unique index.