feat: listen analytics — track who heard what and when

Add listen_events table to record opens, plays and listen duration per
share link. Public POST/PATCH endpoints for fire-and-forget tracking
from the listen page; authenticated GET analytics endpoint aggregates
per version. Listen page gains optional name prompt after first play
and sendBeacon on unload. Track page gains Analytics tab with stats
grid and per-listener event list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Robin Choice
2026-04-23 10:21:56 +02:00
parent e5d0b00761
commit df571df567
10 changed files with 569 additions and 69 deletions

View File

@@ -8,3 +8,10 @@ export const subscribePushSchema = z.object({
}),
userAgent: z.string().optional(),
});
export const updateListenEventSchema = z.object({
listenerName: z.string().max(255).optional(),
firstPlay: z.boolean().optional(),
listenSeconds: z.number().int().min(0).optional(),
completed: z.boolean().optional(),
});