Skip to content

Commit

Permalink
📈 Alias anonymous user with the user (#1517)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella authored Jan 26, 2025
1 parent dc608d6 commit c8b7093
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/web/src/auth/merge-user.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { prisma } from "@rallly/database";
import { posthog } from "@rallly/posthog/server";
import * as Sentry from "@sentry/nextjs";

export const mergeGuestsIntoUser = async (
userId: string,
guestIds: string[],
) => {
try {
return await prisma.$transaction(async (tx) => {
await prisma.$transaction(async (tx) => {
await Promise.all([
tx.poll.updateMany({
where: {
Expand Down Expand Up @@ -45,6 +46,7 @@ export const mergeGuestsIntoUser = async (
}),
]);
});
posthog?.alias({ distinctId: userId, alias: guestIds[0] });
} catch (error) {
Sentry.captureException(error);
}
Expand Down

0 comments on commit c8b7093

Please sign in to comment.