Skip to content

Scheduling infrastructure for absolutely everyone.

fix: new user detection for dub analytics (#16695)

Omar López3a5325f2a800
diff --git a/packages/features/auth/lib/next-auth-options.ts b/packages/features/auth/lib/next-auth-options.ts
index d175b8e4baf..296d5365588 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