From 71552e1b133f64e900ed3ddd0e9c05dd687a04ea Mon Sep 17 00:00:00 2001 From: Joan Code <172996447+joan-code6@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:48:58 +0100 Subject: [PATCH 1/4] Show new account activity and retention in admin analytics --- src/AnalyticsPage.tsx | 113 +++++++++++++++++++++++++++++++++++++++--- src/api.ts | 4 ++ 2 files changed, 111 insertions(+), 6 deletions(-) diff --git a/src/AnalyticsPage.tsx b/src/AnalyticsPage.tsx index 20eebb8..e1f4361 100644 --- a/src/AnalyticsPage.tsx +++ b/src/AnalyticsPage.tsx @@ -34,6 +34,7 @@ function percentage(value: number | null) { function day(value: string) { return new Intl.DateTimeFormat("de-DE", { + timeZone: "UTC", day: "2-digit", month: "short", }).format(new Date(value)); @@ -144,7 +145,7 @@ function Heatmap({ analytics }: { analytics: Analytics }) { } function GrowthChart({ analytics }: { analytics: Analytics }) { - const [metric, setMetric] = useState("logins"); + const [metric, setMetric] = useState("new_users"); const [selected, setSelected] = useState(""); const [table, setTable] = useState(false); const points = trendRows(analytics); @@ -427,14 +428,113 @@ function Anomalies({ analytics }: { analytics: Analytics }) { ); } +function NewUserJourney({ journey }: { journey: NonNullable }) { + const dates = [...journey.days].reverse(); + const totals = dates.reduce( + (sum, row) => ({ + eligible: sum.eligible + row.eligible, + returned: sum.returned + row.returned, + opened: sum.opened + row.opened_module, + }), + { eligible: 0, returned: 0, opened: 0 }, + ); + + return ( + + + Neue Konten · Erste Woche + + Rückkehr an mindestens einem der Tage 1 bis 7 nach der ersten Anmeldung. + Erfasste Modulstarts zählen ab Tag 0. Die Quoten berücksichtigen Konten, für die Tag 7 vollständig vergangen ist (UTC). + + + +
+ {([ + ["Wieder aktiv", totals.returned], + ["Mindestens ein Modul gestartet", totals.opened], + ] as const).map(([label, count]) => ( +
+

{label}

+

+ {percentage(totals.eligible ? count / totals.eligible * 100 : null)} +

+

+ {totals.eligible + ? `${number(count)} von ${number(totals.eligible)} Konten` + : "Keine vollständig beobachtete erste Woche"} +

+
+ ))} +
+
+
+

Erstanmeldungen pro Tag

+ {dates.length ? ( +
+ + + + + + + + + + + {dates.map((row) => ( + + + + {row.eligible ? ( + <> + + + + ) : ( + + )} + + ))} + +
Datum (UTC)NeuZurückModul genutzt
{number(row.new_users)}{number(row.returned)} / {number(row.eligible)}{number(row.opened_module)} / {number(row.eligible)}Beobachtung läuft
+
+ ) :

Keine neuen Konten im Zeitraum.

} +
+
+

Module in der ersten Woche

+ {journey.modules.length ? ( +
    + {journey.modules.map((module) => ( +
  • +
    + {module.module} + {number(module.unique_users)} Konten · {number(module.launches)} Starts +
    +
  • + ))} +
+ ) :

Keine Modulstarts in vollständig beobachteten Wochen erfasst.

} +
+
+
+
+ ); +} + function Retention({ analytics }: { analytics: Analytics }) { return ( - Retention · Kohorten + Rückkehr nach Erstnutzungswoche + {analytics.definitions.retention} {analytics.retention.length ? ( @@ -578,15 +678,16 @@ export function AnalyticsPage({ ))} + {analytics.new_user_journey && ( + + )} +
-
- - -
+ ); } diff --git a/src/api.ts b/src/api.ts index 44e2ecf..aa045ce 100644 --- a/src/api.ts +++ b/src/api.ts @@ -106,6 +106,10 @@ export type Analytics = { heatmap: Array<{ weekday: number; hour: number; events: number; unique_users: number }> module_usage: Array<{ module: string; launches: number; unique_users: number }> anomalies: Array<{ day: string; metric: string; value: number; baseline: number; direction: 'spike' | 'drop'; severity: 'medium' | 'high' }> + new_user_journey?: { + days: Array<{ day: string; new_users: number; eligible: number; returned: number; opened_module: number }> + modules: Array<{ module: string; unique_users: number; launches: number }> + } retention: Array<{ cohort: string; new_users: number; retention_1d: number | null; retention_7d: number | null; retention_30d: number | null }> definitions: { heatmap: string; modules: string; anomalies: string; retention: string } } From 95d3487082546a6d48e98c8dc7517334870f2cfc Mon Sep 17 00:00:00 2001 From: Joan Code <172996447+joan-code6@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:00:19 +0100 Subject: [PATCH 2/4] Visualize new account retention and first-week usage --- src/AnalyticsPage.tsx | 202 ++++++++++++++++++++++++++++++++---------- 1 file changed, 154 insertions(+), 48 deletions(-) diff --git a/src/AnalyticsPage.tsx b/src/AnalyticsPage.tsx index e1f4361..402098e 100644 --- a/src/AnalyticsPage.tsx +++ b/src/AnalyticsPage.tsx @@ -145,7 +145,7 @@ function Heatmap({ analytics }: { analytics: Analytics }) { } function GrowthChart({ analytics }: { analytics: Analytics }) { - const [metric, setMetric] = useState("new_users"); + const [metric, setMetric] = useState("logins"); const [selected, setSelected] = useState(""); const [table, setTable] = useState(false); const points = trendRows(analytics); @@ -428,8 +428,135 @@ function Anomalies({ analytics }: { analytics: Analytics }) { ); } -function NewUserJourney({ journey }: { journey: NonNullable }) { - const dates = [...journey.days].reverse(); +type Journey = NonNullable; + +function NewUserChart({ dates }: { dates: Journey["days"] }) { + const [mode, setMode] = useState<"volume" | "rates">("volume"); + const [selected, setSelected] = useState(""); + const current = dates.find((row) => row.day === selected) ?? dates.at(-1); + const maximum = Math.max(1, ...dates.map((row) => row.new_users)); + const volume = mode === "volume"; + const top = volume ? maximum : 100; + const scale = [top, top / 2, 0]; + return ( +
+
+

Neue Konten im Zeitverlauf

+ +
+
+ {[["bg-primary-500", "Wieder aktiv"], + [volume ? "bg-surface-300 dark:bg-surface-700" : "bg-violet-500", + volume ? "Ohne Rückkehr" : "Modul gestartet"], + ["bg-amber-400", "Beobachtung läuft"]].map(([color, label]) => ( + + {label} + + ))} +
+
+ ); +} + +function WeekComparison({ dates }: { dates: Journey["days"] }) { + // The latest eight dates include today and seven cohorts still under observation. + const recent = dates.slice(-15, -8); + const previous = dates.slice(-22, -15); + if (recent.length !== 7 || previous.length !== 7) return null; + const windows = [previous, recent].map((week) => ({ + label: `${day(week[0].day)} – ${day(week[6].day)}`, + eligible: week.reduce((sum, row) => sum + row.eligible, 0), + returned: week.reduce((sum, row) => sum + row.returned, 0), + opened_module: week.reduce((sum, row) => sum + row.opened_module, 0), + })); + return ( +
+

Die letzten zwei vollständig beobachteten Anmeldewochen

+
+ {([["returned", "Wieder aktiv"], ["opened_module", "Modul gestartet"]] as const).map(([metric, label]) => ( +
+

{label}

+ {windows.map((window, index) => { + const rate = window.eligible ? 100 * window[metric] / window.eligible : null; + return ( +
+ {window.label} + + ); + })} +
+ ))} +
+
+ ); +} + +function NewUserJourney({ journey, analytics }: { journey: Journey; analytics: Analytics }) { + const outcomes = new Map(journey.days.map((row) => [row.day, row])); + const dates = trendRows(analytics).map(({ day }) => + outcomes.get(day) ?? { day, new_users: 0, eligible: 0, returned: 0, opened_module: 0 }, + ); const totals = dates.reduce( (sum, row) => ({ eligible: sum.eligible + row.eligible, @@ -442,7 +569,17 @@ function NewUserJourney({ journey }: { journey: NonNullable - Neue Konten · Erste Woche +
+ Neue Konten · Erste Woche + +
Rückkehr an mindestens einem der Tage 1 bis 7 nach der ersten Anmeldung. Erfasste Modulstarts zählen ab Tag 0. Die Quoten berücksichtigen Konten, für die Tag 7 vollständig vergangen ist (UTC). @@ -468,39 +605,8 @@ function NewUserJourney({ journey }: { journey: NonNullable
-
-

Erstanmeldungen pro Tag

- {dates.length ? ( -
- - - - - - - - - - - {dates.map((row) => ( - - - - {row.eligible ? ( - <> - - - - ) : ( - - )} - - ))} - -
Datum (UTC)NeuZurückModul genutzt
{number(row.new_users)}{number(row.returned)} / {number(row.eligible)}{number(row.opened_module)} / {number(row.eligible)}Beobachtung läuft
-
- ) :

Keine neuen Konten im Zeitraum.

} -
+ {journey.days.length ? + :

Keine neuen Konten im Zeitraum.

}

Module in der ersten Woche

{journey.modules.length ? ( @@ -509,7 +615,7 @@ function NewUserJourney({ journey }: { journey: NonNullable
{module.module} - {number(module.unique_users)} Konten · {number(module.launches)} Starts + {percentage(module.unique_users / totals.eligible * 100)} · {number(module.unique_users)} Konten · {number(module.launches)} Starts
+ {journey.days.length > 0 && } ); @@ -561,15 +668,14 @@ function Retention({ analytics }: { analytics: Analytics }) { {number(cohort.new_users)} - - {percentage(cohort.retention_1d)} - - - {percentage(cohort.retention_7d)} - - - {percentage(cohort.retention_30d)} - + {[cohort.retention_1d, cohort.retention_7d, cohort.retention_30d].map((rate, index) => ( + + + {rate !== null && + + ))} ))} @@ -679,7 +785,7 @@ export function AnalyticsPage({ ))} {analytics.new_user_journey && ( - + )}
From 6ce5e1bd97bdb68ba5bdf8751ac15b15bbae8c2d Mon Sep 17 00:00:00 2001 From: Joan Code <172996447+joan-code6@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:14:40 +0100 Subject: [PATCH 3/4] Simplify admin analytics typography and copy --- src/AnalyticsPage.tsx | 96 ++++++++++++------------------------------- 1 file changed, 26 insertions(+), 70 deletions(-) diff --git a/src/AnalyticsPage.tsx b/src/AnalyticsPage.tsx index 402098e..9542cf6 100644 --- a/src/AnalyticsPage.tsx +++ b/src/AnalyticsPage.tsx @@ -1,5 +1,5 @@ import { useState } from "react"; -import { trendRows, downloadCsv, type TrendMetric } from "./analytics-data"; +import { trendRows, type TrendMetric } from "./analytics-data"; import { Button } from "@/components/ui/button"; import { Select } from "@/components/ui/select"; import { Input } from "@/components/ui/input"; @@ -17,7 +17,6 @@ import { Badge } from "@/components/ui/badge"; import { Card, CardContent, - CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; @@ -162,24 +161,9 @@ function GrowthChart({ analytics }: { analytics: Analytics }) {
Verlauf · UTC -
- - -
+
( {row.module} - + {number(row.launches)} - + {number(row.unique_users)} - + {percentage(total ? (row.launches / total) * 100 : 0)} @@ -441,7 +416,7 @@ function NewUserChart({ dates }: { dates: Journey["days"] }) { return (
-

Neue Konten im Zeitverlauf

+

Pro Tag