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.

Changed session id generation.

Mike Caod44be466d8cc
diff --git a/src/app/api/send/route.ts b/src/app/api/send/route.ts
index f3c8697e9..582b05ff5 100644
--- a/src/app/api/send/route.ts
+++ b/src/app/api/send/route.ts
@@ -55,7 +55,7 @@ export async function POST(request: Request) {
title,
tag,
timestamp,
- id = '',
+ id,
} = payload;
// Cache check
@@ -101,7 +101,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, id);
+ const sessionId = id ? uuid(websiteId, id) : uuid(websiteId, ip, userAgent, sessionSalt);
// Find session
if (!clickhouse.enabled && !cache?.sessionId) {
@@ -148,6 +148,10 @@ export async function POST(request: Request) {
const urlQuery = currentUrl.search.substring(1);
const urlDomain = currentUrl.hostname.replace(/^www./, '');
+ let referrerPath: string;
+ let referrerQuery: string;
+ let referrerDomain: string;
+
// UTM Params
const utmSource = currentUrl.searchParams.get('utm_source');
const utmMedium = currentUrl.searchParams.get('utm_medium');
@@ -167,10 +171,6 @@ export async function POST(request: Request) {
urlPath = urlPath.replace(/(.+)\/$/, '$1');
}
- let referrerPath: string;
- let referrerQuery: string;
- let referrerDomain: string;
-
if (referrer) {
const referrerUrl = new URL(referrer, base);
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 2060811f6..7e7e606b8 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -1,4 +1,3 @@
-/* eslint-disable no-unused-vars */
export const CURRENT_VERSION = process.env.currentVersion;
export const AUTH_TOKEN = 'umami.auth';
export const LOCALE_CONFIG = 'umami.locale';