Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Update session replay payload to use { type, payload } format
Mike Cao7582aed67b1b
diff --git a/src/app/api/record/route.ts b/src/app/api/record/route.tsindex 28ce0f40c..20ca53469 100644--- a/src/app/api/record/route.ts+++ b/src/app/api/record/route.ts@@ -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 });diff --git a/src/lib/constants.ts b/src/lib/constants.tsindex 9044897a7..a4a004f31 100644--- a/src/lib/constants.ts+++ b/src/lib/constants.ts@@ -99,6 +99,7 @@ export const COLLECTION_TYPE = {event: 'event',identify: 'identify',performance: 'performance',+ record: 'record',} as const;export const WEB_VITALS_THRESHOLDS = {diff --git a/src/recorder/index.js b/src/recorder/index.jsindex 5b73cd678..3651793ca 100644--- a/src/recorder/index.js+++ b/src/recorder/index.js@@ -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