📈 Alias anonymous user with the user (#1517)

This commit is contained in:
Luke Vella 2025-01-26 22:50:57 +00:00 committed by GitHub
parent dc608d66e0
commit c8b7093d89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,5 @@
import { prisma } from "@rallly/database";
import { posthog } from "@rallly/posthog/server";
import * as Sentry from "@sentry/nextjs";
export const mergeGuestsIntoUser = async (
@ -6,7 +7,7 @@ export const mergeGuestsIntoUser = async (
guestIds: string[],
) => {
try {
return await prisma.$transaction(async (tx) => {
await prisma.$transaction(async (tx) => {
await Promise.all([
tx.poll.updateMany({
where: {
@ -45,6 +46,7 @@ export const mergeGuestsIntoUser = async (
}),
]);
});
posthog?.alias({ distinctId: userId, alias: guestIds[0] });
} catch (error) {
Sentry.captureException(error);
}