Add click heatmaps report

Extracts click events from rrweb session-replay buffers at write time
into a new heatmap_event table (Prisma + ClickHouse). New /heatmaps
report shows a page picker plus an overlay of click density on the
dominant viewport, with an optional iframe of the live page behind.
This commit is contained in:
Mike Cao committed 2026-04-27 22:20:38 -07:00
1 parent 9da332c489
commit a6b13b71db
18 files changed
+831

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import { parseRequest, setWebsiteDate } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { reportResultSchema } from '@/lib/schema';
import { canViewWebsite } from '@/permissions';
import { getHeatmap, type HeatmapParameters } from '@/queries/sql';
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)) as HeatmapParameters;
const data = await getHeatmap(websiteId, parameters);
return json(data);
}