Added survival curve metrics and table minimizing

This commit is contained in:
George Powell
2026-03-19 00:18:54 -04:00
parent 83cfcc66c0
commit bdc08bc58e
2 changed files with 107 additions and 6 deletions

View File

@@ -202,6 +202,26 @@ export const load: PageServerLoad = async () => {
// Net growth = truly new arrivals minus departures
const netGrowth7d = newUsers7d - churned7d;
// ── Session depth funnel ──────────────────────────────────────────────────
// For each depth d, count players with >= d completions.
// returnRate at depth d = (players with >= d+1) / (players with >= d).
const depthCounts = new Map<number, number>();
for (const r of firstDates) {
const n = r.totalCompletions;
for (let d = 1; d <= n; d++) {
depthCounts.set(d, (depthCounts.get(d) ?? 0) + 1);
}
}
const sessionDepthCards = [2, 3, 4, 5, 7].map((d) => {
const atD = depthCounts.get(d) ?? 0;
const atDplus1 = depthCounts.get(d + 1) ?? 0;
return {
depth: d,
players: atD,
returnRate: atD >= 3 ? Math.round((atDplus1 / atD) * 1000) / 10 : null
};
});
// ── Return rate ───────────────────────────────────────────────────────────
// "Return rate": % of all-time unique players who have ever played more than once.
const playersWithReturn = firstDates.filter((r) => r.totalCompletions >= 2).length;
@@ -329,6 +349,7 @@ export const load: PageServerLoad = async () => {
return {
todayEst,
sessionDepthCards,
stats: {
todayCount,
totalCount,