mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-05 05:06:04 +02:00
📈 Alias anonymous user with the user (#1517)
This commit is contained in:
parent
dc608d66e0
commit
c8b7093d89
1 changed files with 3 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { prisma } from "@rallly/database";
|
import { prisma } from "@rallly/database";
|
||||||
|
import { posthog } from "@rallly/posthog/server";
|
||||||
import * as Sentry from "@sentry/nextjs";
|
import * as Sentry from "@sentry/nextjs";
|
||||||
|
|
||||||
export const mergeGuestsIntoUser = async (
|
export const mergeGuestsIntoUser = async (
|
||||||
|
@ -6,7 +7,7 @@ export const mergeGuestsIntoUser = async (
|
||||||
guestIds: string[],
|
guestIds: string[],
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
return await prisma.$transaction(async (tx) => {
|
await prisma.$transaction(async (tx) => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
tx.poll.updateMany({
|
tx.poll.updateMany({
|
||||||
where: {
|
where: {
|
||||||
|
@ -45,6 +46,7 @@ export const mergeGuestsIntoUser = async (
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
posthog?.alias({ distinctId: userId, alias: guestIds[0] });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Sentry.captureException(error);
|
Sentry.captureException(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue