feat: privacy-respecting analytics
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2170e9275c
commit
e10c1dc8aa
@@ -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 })
|
||||
})
|
||||
Reference in New Issue
Block a user