Post sign up hook for google provider

Hi, I've implemented a post sign up hook for an email provider where I send an internal event to my team when a user signs up. Now I would like to do the same for the google provider. Can you advice how I can identify when the user signs up (creates a new account) as opposed to logs in? Here's my existing after hook
hooks: {
after: createAuthMiddleware(async (ctx) => {
const isFromEmail = ctx.path.startsWith('/verify-email');

if (isFromEmail) {
const newSession = ctx.context.newSession;
if (newSession) {
const user = newSession.user;
try {
await sendProductEventMessage(`[NEW USER SIGNED UP] ${user.name} (${user.email})`);
} catch (error) {
console.error('Error sending product event message', error);
}
}
}
}),
},
hooks: {
after: createAuthMiddleware(async (ctx) => {
const isFromEmail = ctx.path.startsWith('/verify-email');

if (isFromEmail) {
const newSession = ctx.context.newSession;
if (newSession) {
const user = newSession.user;
try {
await sendProductEventMessage(`[NEW USER SIGNED UP] ${user.name} (${user.email})`);
} catch (error) {
console.error('Error sending product event message', error);
}
}
}
}),
},
1 Reply
Byron
Byron6d ago
Also wondering this we can get the initial logic via ctx.path.startsWith('/callback/:id') && ctx.params.id === 'google' but as far as what defines a new user I believe there should be a dedicated field for this. Please update if you figure this out.

Did you find this page helpful?