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:
1 parent
9da332c489
commit
a6b13b71db
18 files changed
+831
No files matched your search
@@ -9,6 +9,8 @@ import { parseRequest } from '@/lib/request';
|
||||
import { badRequest, forbidden, json, serverError } from '@/lib/response';
|
||||
import { getWebsite } from '@/queries/prisma';
|
||||
import { saveRecording } from '@/queries/sql';
|
||||
import { extractHeatmapEvents } from '@/queries/sql/heatmap/extractHeatmapEvents';
|
||||
import { saveHeatmapEvents } from '@/queries/sql/heatmap/saveHeatmapEvents';
|
||||
|
||||
interface Cache {
|
||||
sessionId: string;
|
||||
@@ -113,6 +115,22 @@ export async function POST(request: Request) {
|
||||
endedAt,
|
||||
});
|
||||
|
||||
try {
|
||||
const heatmapRows = extractHeatmapEvents(events).map(e => ({
|
||||
websiteId,
|
||||
sessionId,
|
||||
visitId,
|
||||
...e,
|
||||
}));
|
||||
|
||||
if (heatmapRows.length) {
|
||||
await saveHeatmapEvents(heatmapRows);
|
||||
}
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('heatmap extraction failed', serializeError(e));
|
||||
}
|
||||
|
||||
return json({ ok: true });
|
||||
} catch (e) {
|
||||
const error = serializeError(e);
|
||||
|
||||
Reference in new issue
Block a user