Skip to content

Commit

Permalink
fix: new user detection for dub analytics (calcom#16695)
Browse files Browse the repository at this point in the history
  • Loading branch information
zomars authored Sep 18, 2024
1 parent 5ad7360 commit 3a5325f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/features/auth/lib/next-auth-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const providers: Provider[] = [
belongsToActiveTeam: hasActiveTeams,
locale: user.locale,
profile: user.allProfiles[0],
createdAt: user.createdDate,
createdDate: user.createdDate,
};
},
}),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3a5325f

Please sign in to comment.