Skip to content

armgit / umami

Public Imported from GitHub
0

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.

Roll back session insert.

Brian Caod43ab3e55935
diff --git a/src/lib/session.ts b/src/lib/session.ts
index 5eb7398a9..85c173c52 100644
--- a/src/lib/session.ts
+++ b/src/lib/session.ts
@@ -1,12 +1,27 @@
-import { secret, uuid, isUuid } from 'lib/crypto';
+import { isUuid, secret, uuid } from 'lib/crypto';
import { getClientInfo, getJsonBody } from 'lib/detect';
import { parseToken } from 'next-basics';
import { CollectRequestBody, NextApiRequestCollect } from 'pages/api/send';
import { createSession } from 'queries';
import cache from './cache';
+import clickhouse from './clickhouse';
import { loadSession, loadWebsite } from './load';
-export async function findSession(req: NextApiRequestCollect) {
+export async function findSession(req: NextApiRequestCollect): Promise<{
+ id: any;
+ websiteId: string;
+ hostname: string;
+ browser: string;
+ os: any;
+ device: string;
+ screen: string;
+ language: string;
+ country: any;
+ subdivision1: any;
+ subdivision2: any;
+ city: any;
+ ownerId: string;
+}> {
const { payload } = getJsonBody<CollectRequestBody>(req);
if (!payload) {
@@ -53,6 +68,25 @@ export async function findSession(req: NextApiRequestCollect) {
const sessionId = uuid(websiteId, hostname, ip, userAgent);
+ // Clickhouse does not require session lookup
+ if (clickhouse.enabled) {
+ return {
+ id: sessionId,
+ websiteId,
+ hostname,
+ browser,
+ os: os as any,
+ device,
+ screen,
+ language,
+ country,
+ subdivision1,
+ subdivision2,
+ city,
+ ownerId: website.userId,
+ };
+ }
+
// Find session
let session = await loadSession(sessionId);