feat(api): add endpoint for retrieving growth data for the dashboard

This commit is contained in:
shay
2026-05-27 10:16:11 -07:00
parent e7a0521ff6
commit 99c40cb0ce
5 changed files with 111 additions and 0 deletions
+6
View File
@@ -36,6 +36,11 @@ export type Health = {
oldest_event_ts: number | null
}
export type Growth = {
daily: { day: string; users: number; requests: number }[]
weekly: { week: string; users: number; requests: number }[]
}
async function getJSON<T>(path: string): Promise<T> {
const r = await fetch(path, { credentials: 'include' })
if (r.status === 401) throw new Error('unauthorized')
@@ -49,3 +54,4 @@ export const fetchUsers = (q = '', sort = 'requests') =>
getJSON<UserRow[]>(`/api/dev/users?q=${encodeURIComponent(q)}&sort=${sort}`)
export const fetchLatency = () => getJSON<LatencyRow[]>('/api/dev/latency')
export const fetchHealth = () => getJSON<Health>('/api/dev/health')
export const fetchGrowth = () => getJSON<Growth>('/api/dev/growth')
@@ -5,6 +5,7 @@ import { StatCards } from '../components/StatCards'
import { UsersTable } from '../components/UsersTable'
import { LatencyChart } from '../components/LatencyChart'
import { HealthStrip } from '../components/HealthStrip'
import { GrowthChart } from '../components/GrowthChart'
const REFRESH_MS = 15_000
@@ -45,6 +46,9 @@ export function DevScreen() {
return (
<Shell lastRefresh={lastRefresh}>
{s ? <StatCards s={s} /> : <div className="text-white/40">loading…</div>}
<div className="mt-6">
<GrowthChart />
</div>
<div className="mt-6">
<UsersTable />
</div>