From 3a5325f2a800e3fd4e909022f25b656a08236bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Tue, 17 Sep 2024 19:19:25 -0700 Subject: [PATCH] fix: new user detection for dub analytics (#16695) --- packages/features/auth/lib/next-auth-options.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/features/auth/lib/next-auth-options.ts b/packages/features/auth/lib/next-auth-options.ts index d175b8e4ba..296d536558 100644 --- a/packages/features/auth/lib/next-auth-options.ts +++ b/packages/features/auth/lib/next-auth-options.ts @@ -237,7 +237,7 @@ const providers: Provider[] = [ belongsToActiveTeam: hasActiveTeams, locale: user.locale, profile: user.allProfiles[0], - createdAt: user.createdDate, + createdDate: user.createdDate, }; }, }), @@ -941,12 +941,12 @@ export const getOptions = ({ */ const user = message.user as User & { username: string; - createdAt: string; + createdDate: string; }; // check if the user was created in the last 10 minutes // this is a workaround – in the future once we move to use the Account model in the DB // we should use NextAuth's isNewUser flag instead: https://next-auth.js.org/configuration/events#signin - const isNewUser = new Date(user.createdAt) > new Date(Date.now() - 10 * 60 * 1000); + const isNewUser = new Date(user.createdDate) > new Date(Date.now() - 10 * 60 * 1000); if ((isENVDev || IS_CALCOM) && process.env.DUB_API_KEY && isNewUser) { const clickId = getDubId(); // check if there's a clickId (dub_id) cookie set by @dub/analytics