Handle fragmented replay events in recording and playback

This commit is contained in:
Mike Cao committed 2026-06-15 13:46:24 -07:00
1 parent 4987e0ca01
commit 15038b09d9
6 files changed
+345 -34

No files matched your search

@@ -1,3 +1,4 @@
import { restoreReplayEventFragments } from '@/lib/replay';
import { parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { canViewAuthenticatedWebsite } from '@/permissions';
@@ -91,7 +92,9 @@ export async function GET(
}
const chunks = await getReplayChunks(websiteId, replayId, { endAt, endChunkIndex });
const allEvents = mergeReplayEvents(chunks, { until, endChunkIndex, endEventIndex });
const allEvents = restoreReplayEventFragments(
mergeReplayEvents(chunks, { until, endChunkIndex, endEventIndex }),
);
const sessionId = chunks.length > 0 ? chunks[0].sessionId : null;
const startedAt = chunks.length > 0 ? chunks[0].startedAt : null;
const endedAt = chunks.length > 0 ? chunks[chunks.length - 1].endedAt : null;