fix: new user detection for dub analytics (#16695)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user