mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-28 21:57:23 +02:00
📈 Improvements to posthog analytics data (#1189)
This commit is contained in:
parent
278713d57f
commit
587e11de17
10 changed files with 93 additions and 80 deletions
|
@ -174,9 +174,32 @@ const getAuthOptions = (...args: GetServerSessionParams) =>
|
|||
signOut: "/logout",
|
||||
error: "/auth/error",
|
||||
},
|
||||
events: {
|
||||
signIn({ user, account }) {
|
||||
posthog?.capture({
|
||||
distinctId: user.id,
|
||||
event: "login",
|
||||
properties: {
|
||||
method: account?.provider,
|
||||
$set: {
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
timeZone: user.timeZone,
|
||||
locale: user.locale,
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
signOut({ session }) {
|
||||
posthog?.capture({
|
||||
distinctId: session.user.id,
|
||||
event: "logout",
|
||||
});
|
||||
},
|
||||
},
|
||||
callbacks: {
|
||||
async signIn({ user, email, account, profile }) {
|
||||
const distinctId = user.email ?? user.id;
|
||||
async signIn({ user, email, profile }) {
|
||||
const distinctId = user.id;
|
||||
// prevent sign in if email is not verified
|
||||
if (
|
||||
profile &&
|
||||
|
@ -221,22 +244,6 @@ const getAuthOptions = (...args: GetServerSessionParams) =>
|
|||
if (session && session.user.email === null) {
|
||||
await mergeGuestsIntoUser(user.id, [session.user.id]);
|
||||
}
|
||||
|
||||
posthog?.identify({
|
||||
distinctId,
|
||||
properties: {
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
},
|
||||
});
|
||||
|
||||
posthog?.capture({
|
||||
distinctId,
|
||||
event: "login",
|
||||
properties: {
|
||||
method: account?.provider,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue