Use props passed to identify to define session
This commit is contained in:
@@ -18,6 +18,7 @@ const schema = z.object({
|
||||
payload: z.object({
|
||||
website: z.string().uuid(),
|
||||
data: anyObjectParam.optional(),
|
||||
identity: anyObjectParam.optional(),
|
||||
hostname: z.string().max(100).optional(),
|
||||
language: z.string().max(35).optional(),
|
||||
referrer: urlOrPathParam.optional(),
|
||||
@@ -59,6 +60,7 @@ export async function POST(request: Request) {
|
||||
title,
|
||||
tag,
|
||||
timestamp,
|
||||
identity,
|
||||
} = payload;
|
||||
|
||||
// Cache check
|
||||
@@ -97,7 +99,13 @@ 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,
|
||||
identity ? JSON.stringify(identity) : '',
|
||||
);
|
||||
|
||||
// Find session
|
||||
if (!clickhouse.enabled && !cache?.sessionId) {
|
||||
|
||||
Reference in New Issue
Block a user