From 63c6c4f92d78b15a43f51c5a2f3a5e78a5c5ede7 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Fri, 26 Jan 2024 12:45:48 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Use=20email=20as=20distinct=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/utils/auth.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/web/src/utils/auth.ts b/apps/web/src/utils/auth.ts index add318497..7025f16d0 100644 --- a/apps/web/src/utils/auth.ts +++ b/apps/web/src/utils/auth.ts @@ -162,6 +162,7 @@ const getAuthOptions = (...args: GetServerSessionParams) => callbacks: { async signIn({ user, email, account, profile }) { const posthog = PostHogClient(); + const distinctId = user.email ?? user.id; // prevent sign in if email is not verified if ( profile && @@ -169,7 +170,7 @@ const getAuthOptions = (...args: GetServerSessionParams) => profile.email_verified === false ) { posthog?.capture({ - distinctId: user.id, + distinctId, event: "login failed", properties: { reason: "email not verified", @@ -209,7 +210,7 @@ const getAuthOptions = (...args: GetServerSessionParams) => } posthog?.capture({ - distinctId: user.id, + distinctId, event: "login", properties: { method: account?.provider,