Updated Clickhouse session logic.

pull/1653/head
Mike Cao 2022-11-08 17:11:08 -08:00
parent e9c8d16d5b
commit 1a8c7c42f4
1 changed files with 33 additions and 32 deletions

View File

@ -47,10 +47,24 @@ export async function findSession(req) {
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
const sessionId = uuid(websiteId, hostname, ip, userAgent);
// Clickhouse does not require session lookup
if (clickhouse.enabled) {
return {
id: sessionId,
websiteId,
hostname,
browser,
os,
device,
screen,
language,
country,
};
}
// Find session
let session;
if (!clickhouse.enabled) {
if (cache.enabled) {
session = await cache.fetchSession(sessionId);
} else {
@ -77,19 +91,6 @@ export async function findSession(req) {
}
}
}
} else {
session = {
id: sessionId,
websiteId,
hostname,
browser,
os,
device,
screen,
language,
country,
};
}
return session;
}