Handle fragmented replay events in recording and playback
This commit is contained in:
1 parent
4987e0ca01
commit
15038b09d9
6 files changed
+345
-34
No files matched your search
@@ -7,6 +7,7 @@ import { getClientInfo, hasBlockedIp } from '@/lib/detect';
|
||||
import { parseToken } from '@/lib/jwt';
|
||||
import { fetchAccount, fetchTeam } from '@/lib/load';
|
||||
import { getRecorderConfig } from '@/lib/recorder';
|
||||
import { getReplayEventCount } from '@/lib/replay';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { badRequest, forbidden, json, payloadTooLarge, serverError } from '@/lib/response';
|
||||
import { getWebsite } from '@/queries/prisma';
|
||||
@@ -197,7 +198,7 @@ export async function POST(request: Request) {
|
||||
visitId,
|
||||
chunkIndex,
|
||||
events,
|
||||
eventCount: events.length,
|
||||
eventCount: getReplayEventCount(events),
|
||||
startedAt,
|
||||
endedAt,
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user