Add self-hosted usage analytics: pageview tracking + admin stats dashboard

Records pageviews (path, referrer, browser/OS/device, IP, GeoIP country) via
a POST /api/track beacon into a new PageView table, and exposes aggregated
daily/breakdown stats behind a token-gated GET /api/admin/stats endpoint with
brute-force lockout. Frontend gets a /admin dashboard (charts + breakdown
tables) built on recharts, with a switchable per-day pageviews chart.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
tim
2026-07-01 19:43:10 +02:00
co-authored by Claude Sonnet 5
parent c59dca754f
commit 0845562a21
17 changed files with 1386 additions and 18 deletions
+2
View File
@@ -8,6 +8,8 @@ SQLAlchemy[asyncio]>=2.0
aiosqlite>=0.20 # dev / default DATABASE_URL
asyncpg>=0.29 # production (PostgreSQL)
pyotp>=2.9 # TOTP login
user-agents>=2.2 # parse User-Agent for /track (self-hosted analytics)
geoip2>=4.8 # resolve IP -> country from a local .mmdb file (no external calls)
# NOTE: the legacy Flask/Jinja HTTP UI (api/routes.py, api/forms.py,
# api/templates/) is dormant and its dependencies (Flask, Flask-WTF, etc.)