GET /api/analytics/dashboard
Admin-only analytics bundle for StatsDashboard and related UI.
Handler
- Runtime:
nodejs - Method:
GETviawithUniversalEnhancements(getHandler)
Auth
auth()session required — else401.checkUserPermission(userId, PERMISSIONS.ADMIN.ACCESS)— else403.
Query
Parsed with DashboardQuerySchema from search params, including:
dateRange:7d|30d|90d|1ymetrics: sessions, pageviews, clicks, users, geographic, devices, vpn, heatmap, subscriptionsgranularity: hourly | daily | weekly | monthlytimezone,country,device_type, … (see OpenAPI block in route)
getDateRange converts range to startDate / endDate; handler fetches metric slices in parallel (implementation in lower half of route.ts).
Sources: src/app/api/analytics/dashboard/route.ts, @lib/permissions/permissions