diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index bb3cacf..c86486b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -174,7 +174,8 @@ if (!browser) return; anonymousId = getOrCreateAnonymousId(); if ((window as any).umami) { - (window as any).umami.identify(anonymousId); + // Use user id if logged in, otherwise use anonymous id + (window as any).umami.identify(user ? user.id : anonymousId); } const statsKey = `bibdle-stats-submitted-${dailyVerse.date}`; statsSubmitted = localStorage.getItem(statsKey) === "true"; @@ -264,7 +265,7 @@ (async () => { try { const response = await fetch( - `/api/submit-completion?anonymousId=${anonymousId}&date=${dailyVerse.date}`, + `/api/submit-completion?anonymousId=${user ? user.id : anonymousId}&date=${dailyVerse.date}`, ); const result = await response.json(); console.log("Stats response:", result); @@ -294,7 +295,7 @@ async function submitStats() { try { const payload = { - anonymousId, + anonymousId: user ? user.id : anonymousId, date: dailyVerse.date, guessCount: guesses.length, }; @@ -455,7 +456,7 @@