feat: privacy-respecting analytics

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-09 00:15:20 +00:00
co-authored by Claude Opus 4.6
parent 2170e9275c
commit e10c1dc8aa
6 changed files with 116 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import { Hono } from 'hono'
import { getPublicStats } from '../engine/analytics.js'
export const statsRouter = new Hono()
// GET /public — aggregate stats for last 30 days, no PII
statsRouter.get('/public', (c) => {
const days = Math.min(parseInt(c.req.query('days') || '30'), 90)
const rows = getPublicStats(days)
// Group by date for easier consumption
const byDate: Record<string, Record<string, number>> = {}
for (const row of rows) {
if (!byDate[row.date]) byDate[row.date] = {}
byDate[row.date][row.metric] = row.value
}
return c.json({ stats: byDate })
})