remove unused replay snapshot path before merge

This commit is contained in:
Francis Cao committed 2026-05-22 11:09:57 -07:00
1 parent 462be82782
commit b5d56a2a29
3 files changed
+31 -177

No files matched your search

+24 -31
View File
@@ -3,16 +3,15 @@ import { HEATMAP_EVENT_TYPE } from '@/lib/constants';
const RRWEB_TYPE_INCREMENTAL = 3;
const RRWEB_TYPE_META = 4;
const RRWEB_TYPE_CUSTOM = 5;
const RRWEB_SOURCE_MOUSE_INTERACTION = 2;
const RRWEB_SOURCE_VIEWPORT_RESIZE = 4;
const RRWEB_MOUSE_CLICK = 2;
export interface ExtractedHeatmapEvent {
eventType: number;
nodeId: number | null;
x: number | null;
y: number | null;
pageX: number | null;
pageY: number | null;
pageW: number | null;
viewportW: number | null;
viewportH: number | null;
pageH: number | null;
@@ -77,9 +76,6 @@ export function extractHeatmapEvents(
nodeId: null,
x: null,
y: null,
pageX: null,
pageY: null,
pageW: typeof p.pageW === 'number' ? p.pageW : null,
viewportW: typeof p.viewportW === 'number' ? p.viewportW : viewportW,
viewportH: typeof p.viewportH === 'number' ? p.viewportH : viewportH,
pageH: typeof p.pageH === 'number' ? p.pageH : null,
@@ -94,31 +90,6 @@ export function extractHeatmapEvents(
replayTimeMs,
});
}
if (ev.data.tag === 'heatmap-click' && ev.data.payload) {
const p = ev.data.payload;
const path = safePathname(p.url) ?? urlPath;
if (path === null) continue;
out.push({
eventType: HEATMAP_EVENT_TYPE.click,
nodeId: null,
x: typeof p.x === 'number' ? Math.round(p.x) : null,
y: typeof p.y === 'number' ? Math.round(p.y) : null,
pageX: typeof p.pageX === 'number' ? Math.round(p.pageX) : null,
pageY: typeof p.pageY === 'number' ? Math.round(p.pageY) : null,
pageW: typeof p.pageW === 'number' ? Math.round(p.pageW) : null,
viewportW: typeof p.viewportW === 'number' ? Math.round(p.viewportW) : viewportW,
viewportH: typeof p.viewportH === 'number' ? Math.round(p.viewportH) : viewportH,
pageH: typeof p.pageH === 'number' ? Math.round(p.pageH) : null,
scrollPct: null,
urlPath: path,
createdAt: new Date(replayTimeMs ?? Date.now()),
replayChunkIndex: chunkIndex ?? null,
replayEventIndex: eventIndex,
replayTimeMs,
});
}
continue;
}
@@ -131,6 +102,28 @@ export function extractHeatmapEvents(
if (typeof d.height === 'number') viewportH = d.height;
continue;
}
if (
d.source === RRWEB_SOURCE_MOUSE_INTERACTION &&
d.type === RRWEB_MOUSE_CLICK &&
urlPath !== null
) {
out.push({
eventType: HEATMAP_EVENT_TYPE.click,
nodeId: typeof d.id === 'number' ? d.id : null,
x: typeof d.x === 'number' ? Math.round(d.x) : null,
y: typeof d.y === 'number' ? Math.round(d.y) : null,
viewportW,
viewportH,
pageH: null,
scrollPct: null,
urlPath,
createdAt: new Date(replayTimeMs ?? Date.now()),
replayChunkIndex: chunkIndex ?? null,
replayEventIndex: eventIndex,
replayTimeMs,
});
}
}
return out;
+6 -37
View File
@@ -18,9 +18,6 @@ export interface ReplayChunk {
interface GetReplayChunksOptions {
endAt?: Date;
endChunkIndex?: number;
startChunkIndex?: number;
limit?: number;
order?: 'asc' | 'desc';
}
export async function getReplayChunks(
@@ -37,7 +34,7 @@ export async function getReplayChunks(
async function relationalQuery(
websiteId: string,
visitId: string,
{ endAt, endChunkIndex, startChunkIndex, limit, order = 'asc' }: GetReplayChunksOptions,
{ endAt, endChunkIndex }: GetReplayChunksOptions,
): Promise<ReplayChunk[]> {
const { rawQuery } = prisma;
const endAtFilter = endAt
@@ -51,18 +48,6 @@ async function relationalQuery(
and chunk_index <= {{endChunkIndex}}
`
: '';
const startChunkFilter =
startChunkIndex !== undefined
? `
and chunk_index >= {{startChunkIndex}}
`
: '';
const limitClause =
limit !== undefined
? `
limit ${limit}
`
: '';
const chunks: {
sessionId: string;
@@ -86,12 +71,10 @@ async function relationalQuery(
where website_id = {{websiteId::uuid}}
and visit_id = {{visitId::uuid}}
${endAtFilter}
${startChunkFilter}
${endChunkFilter}
order by chunk_index ${order}
${limitClause}
order by chunk_index asc
`,
{ websiteId, visitId, endAt, endChunkIndex, startChunkIndex },
{ websiteId, visitId, endAt, endChunkIndex },
FUNCTION_NAME,
);
@@ -104,7 +87,7 @@ async function relationalQuery(
async function clickhouseQuery(
websiteId: string,
visitId: string,
{ endAt, endChunkIndex, startChunkIndex, limit, order = 'asc' }: GetReplayChunksOptions,
{ endAt, endChunkIndex }: GetReplayChunksOptions,
): Promise<ReplayChunk[]> {
const { rawQuery } = clickhouse;
const endAtFilter = endAt
@@ -118,18 +101,6 @@ async function clickhouseQuery(
and chunk_index <= {endChunkIndex:UInt32}
`
: '';
const startChunkFilter =
startChunkIndex !== undefined
? `
and chunk_index >= {startChunkIndex:UInt32}
`
: '';
const limitClause =
limit !== undefined
? `
limit ${limit}
`
: '';
const results = await rawQuery<
{
@@ -155,12 +126,10 @@ async function clickhouseQuery(
prewhere website_id = {websiteId:UUID}
and visit_id = {visitId:UUID}
${endAtFilter}
${startChunkFilter}
${endChunkFilter}
order by chunk_index ${order}
${limitClause}
order by chunk_index asc
`,
{ websiteId, visitId, endAt, endChunkIndex, startChunkIndex },
{ websiteId, visitId, endAt, endChunkIndex },
FUNCTION_NAME,
);