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
Handle unique session errors.
Mike Cao56cf55e05360
diff --git a/lib/session.js b/lib/session.jsindex 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;