Merge pull request #3334 from perso182/props-in-session-definition

Use the props passed to identify to determine sessions
This commit is contained in:
Mike Cao
2025-04-24 19:22:24 -07:00
committed by GitHub
2 changed files with 14 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ const schema = z.object({
payload: z.object({
website: z.string().uuid(),
data: anyObjectParam.optional(),
id: z.string().optional(),
hostname: z.string().max(100).optional(),
language: z.string().max(35).optional(),
referrer: urlOrPathParam.optional(),
@@ -54,6 +55,7 @@ export async function POST(request: Request) {
title,
tag,
timestamp,
id,
} = payload;
// Cache check
@@ -97,7 +99,7 @@ export async function POST(request: Request) {
const sessionSalt = hash(startOfMonth(createdAt).toUTCString());
const visitSalt = hash(startOfHour(createdAt).toUTCString());
const sessionId = uuid(websiteId, ip, userAgent, sessionSalt);
const sessionId = uuid(websiteId, ip, userAgent, sessionSalt, id ? id : '');
// Find session
if (!clickhouse.enabled && !cache?.sessionId) {