2026-08-25 07:51:38 +02:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
|
import { getSessionTimeline } from "@/lib/db/queries/stats";
|
2026-08-26 08:45:15 +02:00
|
|
|
import { withRouteLogging } from "@/lib/api/with-route-logging";
|
2026-08-25 07:51:38 +02:00
|
|
|
|
2026-08-26 08:45:15 +02:00
|
|
|
export const GET = withRouteLogging(
|
|
|
|
|
"stats.session-timeline",
|
|
|
|
|
async (req: Request, { params }: { params: Promise<{ id: string }> }) => {
|
|
|
|
|
const { id } = await params;
|
|
|
|
|
const bucketMs = Number(new URL(req.url).searchParams.get("bucketMs") ?? 1000);
|
|
|
|
|
const timeline = await getSessionTimeline(Number(id), bucketMs);
|
|
|
|
|
return NextResponse.json({ timeline });
|
|
|
|
|
},
|
|
|
|
|
);
|