source: Klonkt/src/routes/admin-stats.js@ dbde7f8

main
Last change on this file since dbde7f8 was d549549, checked in by roboburr <roboburr@…>, 3 months ago

Statistics module (Phase 3): cookie-free tracking + premium stats page

Counters: posts.view_count, audio_tracks.play_count, stat_daily
(pageviews/day) + stat_visitor_day (unique visitors via daily rotating
salted hash of IP+UA, never stored → no cookie, no consent needed).
StatsService records pageview on home + post-view (skips admins), play on
the initial player stream fetch. /admin/stats (god-only +
premiumUnlocked-gated): cards + 14-day cookie-free bar chart
(visitors/views) + top posts/tracks. Dashboard button is premium-gated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

  • Property mode set to 100644
File size: 1008 bytes
Line 
1/**
2 * Admin: Statistieken (premium-module, god-only).
3 *
4 * GET /admin/stats -> cookievrije statistieken: bezoekers/weergaven per dag,
5 * plays, en de populairste posts/tracks.
6 *
7 * Premium-gated via premiumUnlocked() (premium-laag uit = gewoon beschikbaar;
8 * aan = Patreon vereist). Tracking zit in StatsService (geen cookies).
9 */
10
11import express from 'express';
12import { renderPage } from '../middleware/render.js';
13import { requireGod } from '../middleware/auth.js';
14import { premiumUnlocked } from '../services/PatreonService.js';
15import { getStats } from '../services/StatsService.js';
16
17const router = express.Router();
18
19router.get('/', requireGod, (req, res) => {
20 if (!premiumUnlocked()) {
21 return res.status(403).send('Statistieken is een premium-functie — koppel Patreon in Beheer → Instellingen.');
22 }
23 renderPage(req, res, 'pages/admin-stats', {
24 pageTitle: 'Statistieken',
25 bodyClass: 'on-admin',
26 stats: getStats(14),
27 });
28});
29
30export default router;
Note: See TracBrowser for help on using the repository browser.