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.

Handle unique session errors.

Mike Cao56cf55e05360
diff --git a/lib/session.js b/lib/session.js
index 3d2fc7bc1..167fda9ca 100644
--- a/lib/session.js
+++ b/lib/session.js
@@ -37,16 +37,22 @@ export async function getSession(req) {
let session = await getSessionByUuid(session_uuid);
if (!session) {
- session = await createSession(website_id, {
- session_uuid,
- hostname,
- browser,
- os,
- screen,
- language,
- country,
- device,
- });
+ try {
+ session = await createSession(website_id, {
+ session_uuid,
+ hostname,
+ browser,
+ os,
+ screen,
+ language,
+ country,
+ device,
+ });
+ } catch (e) {
+ if (!e.message.includes('Unique constraint')) {
+ throw e;
+ }
+ }
}
const { session_id } = session;