mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 03:55:37 +01:00
End-to-end performance metrics tracking: dedicated database table with percentile aggregation, tracker collection behind data-perf attribute, /api/send handling, report API endpoints, and Performance dashboard page with threshold-based metric cards, time-series chart, and per-page breakdown. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
869 B
TypeScript
26 lines
869 B
TypeScript
import { getQueryFilters, parseRequest, setWebsiteDate } from '@/lib/request';
|
|
import { json, unauthorized } from '@/lib/response';
|
|
import { reportResultSchema } from '@/lib/schema';
|
|
import { canViewWebsite } from '@/permissions';
|
|
import { getPerformance, type PerformanceParameters } from '@/queries/sql/reports/getPerformance';
|
|
|
|
export async function POST(request: Request) {
|
|
const { auth, body, error } = await parseRequest(request, reportResultSchema);
|
|
|
|
if (error) {
|
|
return error();
|
|
}
|
|
|
|
const { websiteId } = body;
|
|
|
|
if (!(await canViewWebsite(auth, websiteId))) {
|
|
return unauthorized();
|
|
}
|
|
|
|
const parameters = await setWebsiteDate(websiteId, body.parameters);
|
|
const filters = await getQueryFilters(body.filters, websiteId);
|
|
|
|
const data = await getPerformance(websiteId, parameters as PerformanceParameters, filters);
|
|
|
|
return json(data);
|
|
}
|