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