Update session replay payload to use { type, payload } format
This commit is contained in:
@@ -16,9 +16,12 @@ interface Cache {
|
||||
}
|
||||
|
||||
const schema = z.object({
|
||||
website: z.uuid(),
|
||||
events: z.array(z.any()).max(200),
|
||||
timestamp: z.coerce.number().int().optional(),
|
||||
type: z.literal('record'),
|
||||
payload: z.object({
|
||||
website: z.uuid(),
|
||||
events: z.array(z.any()).max(200),
|
||||
timestamp: z.coerce.number().int().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export async function POST(request: Request) {
|
||||
@@ -29,7 +32,7 @@ export async function POST(request: Request) {
|
||||
return error();
|
||||
}
|
||||
|
||||
const { website: websiteId, events, timestamp } = body;
|
||||
const { website: websiteId, events, timestamp } = body.payload;
|
||||
|
||||
if (!events?.length) {
|
||||
return json({ ok: true });
|
||||
|
||||
@@ -99,6 +99,7 @@ export const COLLECTION_TYPE = {
|
||||
event: 'event',
|
||||
identify: 'identify',
|
||||
performance: 'performance',
|
||||
record: 'record',
|
||||
} as const;
|
||||
|
||||
export const WEB_VITALS_THRESHOLDS = {
|
||||
|
||||
@@ -39,9 +39,12 @@ import { record } from 'rrweb';
|
||||
if (!session?.cache) return;
|
||||
|
||||
const body = JSON.stringify({
|
||||
website,
|
||||
events,
|
||||
timestamp: Math.floor(Date.now() / 1000),
|
||||
type: 'record',
|
||||
payload: {
|
||||
website,
|
||||
events,
|
||||
timestamp: Math.floor(Date.now() / 1000),
|
||||
},
|
||||
});
|
||||
|
||||
// keepalive has a 64KB body limit — only use it for small payloads on unload
|
||||
|
||||
Reference in New Issue
Block a user