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
Updated Clickhouse session logic.
Mike Cao1a8c7c42f4aa
diff --git a/lib/session.js b/lib/session.jsindex 442de39ca..ad9f75b8f 100644--- a/lib/session.js+++ b/lib/session.js@@ -47,38 +47,9 @@ export async function findSession(req) {const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);const sessionId = uuid(websiteId, hostname, ip, userAgent);- // Find session- let session;-- if (!clickhouse.enabled) {- if (cache.enabled) {- session = await cache.fetchSession(sessionId);- } else {- session = await getSession({ id: sessionId });- }-- // Create a session if not found- if (!session) {- try {- session = await createSession({- id: sessionId,- websiteId,- hostname,- browser,- os,- device,- screen,- language,- country,- });- } catch (e) {- if (!e.message.toLowerCase().includes('unique constraint')) {- throw e;- }- }- }- } else {- session = {+ // Clickhouse does not require session lookup+ if (clickhouse.enabled) {+ return {id: sessionId,websiteId,hostname,@@ -91,5 +62,35 @@ export async function findSession(req) {};}+ // Find session+ let session;++ if (cache.enabled) {+ session = await cache.fetchSession(sessionId);+ } else {+ session = await getSession({ id: sessionId });+ }++ // Create a session if not found+ if (!session) {+ try {+ session = await createSession({+ id: sessionId,+ websiteId,+ hostname,+ browser,+ os,+ device,+ screen,+ language,+ country,+ });+ } catch (e) {+ if (!e.message.toLowerCase().includes('unique constraint')) {+ throw e;+ }+ }+ }+return session;}