diff --git a/src/AnalyticsPage.tsx b/src/AnalyticsPage.tsx
index 20eebb8..5d43d98 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";
@@ -34,6 +33,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));
@@ -161,24 +161,9 @@ function GrowthChart({ analytics }: { analytics: Analytics }) {
Verlauf · UTC
-
-
-
-
+
+
+ {[["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}
+
+ ))}
+
+
+
+ {scale.map((tick) => {volume ? tick.toLocaleString("de-DE") : `${tick}%`})}
+
+
+
+
+
+ {dates.map((row) => {
+ const pending = row.new_users - row.eligible;
+ const height = (value: number) => `${value / maximum * 100}%`;
+ const share = (value: number) => `${row.eligible ? value / row.eligible * 100 : 0}%`;
+ return (
+
setSelected(row.day)} onClick={() => setSelected(row.day)}
+ className={`relative flex h-full min-w-0 flex-1 justify-center ${current?.day === row.day ? "bg-primary-100/60 dark:bg-primary-900/30" : ""}`}>
+ {volume ? (
+
+ ) : (
+
+
+
+ {pending > 0 &&
}
+
+ )}
+
+ );
+ })}
+
+
+ {day(dates[0].day)}{day(dates.at(-1)!.day)}
+
+
+
+
+
+ setSelected(event.target.value)}>
+ {dates.map((row) => )}
+
+ {current &&
+ {number(current.new_users)} neu
+ {current.eligible > 0
+ ? ` · ${current.returned} / ${current.eligible} zurück (${percentage(100 * current.returned / current.eligible)}) · ${current.opened_module} / ${current.eligible} mit Modulstart (${percentage(100 * current.opened_module / current.eligible)})`
+ : current.new_users > 0 && " · Beobachtung läuft"}
+ }
+
+
+ );
+}
+
+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 (
+
+ Wochenvergleich
+
+ {([["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}
+
+
+ {percentage(rate)}
+ {window.eligible > 0 && (
+ {window[metric]} / {window.eligible}
+ )}
+
+
+ );
+ })}
+
+ ))}
+
+
+ );
+}
+
+function NewUserJourney({ journey, analytics }: { journey: Journey; analytics: Analytics }) {
+ const outcomes = new Map(journey.days.map((row) => [row.day, row]));
+ const dates = analytics.login_series.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,
+ returned: sum.returned + row.returned,
+ opened: sum.opened + row.opened_module,
+ }),
+ { eligible: 0, returned: 0, opened: 0 },
+ );
+
+ return (
+
+
+ Neue Konten · Erste Woche
+
+
+
+ {([
+ ["Rückkehr (Tag 1–7)", totals.returned],
+ ["Modulstart (Tag 0–7)", 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`
+ : "Beobachtung läuft"}
+
+
+ ))}
+
+
+ {journey.days.length ?
+ :
Keine neuen Konten im Zeitraum.
}
+
+ Beliebteste Module
+ {journey.modules.length ? (
+
+ ) : Keine Modulstarts erfasst.
}
+
+
+ {journey.days.length > 0 && }
+
+
+ );
+}
+
function Retention({ analytics }: { analytics: Analytics }) {
return (
-
+
- Retention · Kohorten
+ Rückkehr nach Erstnutzungswoche
@@ -458,18 +625,17 @@ function Retention({ analytics }: { analytics: Analytics }) {
{day(cohort.cohort)}
|
-
+ |
{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 && }
+ {percentage(rate)}
+
+ |
+ ))}
))}
@@ -561,32 +727,29 @@ export function AnalyticsPage({
{error}
)}
-
- {loading
- ? "Laden …"
- : `${rows[0]?.day || "—"} – ${rows.at(-1)?.day || "—"} · UTC · ${new Date(analytics.generated_at).toLocaleString("de-DE")}`}
-
+ {loading && Laden …
}
{totals.map(([label, value]) => (
{label}
-
+
{value.toLocaleString("de-DE", { maximumFractionDigits: 1 })}
))}
+ {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 }
}