mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-17 10:56:19 +02:00
📈 Include pollId when capturing events (#555)
This commit is contained in:
parent
e77ed269f5
commit
d14a88e9eb
3 changed files with 73 additions and 63 deletions
|
@ -93,6 +93,7 @@ const Page: React.FunctionComponent<CreatePollPageProps> = ({
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
setIsRedirecting(true);
|
setIsRedirecting(true);
|
||||||
posthog.capture("created poll", {
|
posthog.capture("created poll", {
|
||||||
|
pollId: res.id,
|
||||||
numberOfOptions: formData.options?.options?.length,
|
numberOfOptions: formData.options?.options?.length,
|
||||||
optionsView: formData?.options?.view,
|
optionsView: formData?.options?.view,
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,8 +15,9 @@ export const normalizeVotes = (
|
||||||
|
|
||||||
export const useAddParticipantMutation = () => {
|
export const useAddParticipantMutation = () => {
|
||||||
return trpc.polls.participants.add.useMutation({
|
return trpc.polls.participants.add.useMutation({
|
||||||
onSuccess: (_, { name }) => {
|
onSuccess: (_, { pollId, name }) => {
|
||||||
posthog.capture("add participant", {
|
posthog.capture("add participant", {
|
||||||
|
pollId,
|
||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -61,8 +62,9 @@ export const useDeleteParticipantMutation = () => {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onSuccess: (_, { participantId }) => {
|
onSuccess: (_, { pollId, participantId }) => {
|
||||||
posthog.capture("remove participant", {
|
posthog.capture("remove participant", {
|
||||||
|
pollId,
|
||||||
participantId,
|
participantId,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -94,7 +94,8 @@ export const polls = router({
|
||||||
demo: z.boolean().optional(),
|
demo: z.boolean().optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ ctx, input }): Promise<{ urlId: string }> => {
|
.mutation(
|
||||||
|
async ({ ctx, input }): Promise<{ id: string; urlId: string }> => {
|
||||||
const adminUrlId = await nanoid();
|
const adminUrlId = await nanoid();
|
||||||
const participantUrlId = await nanoid();
|
const participantUrlId = await nanoid();
|
||||||
let verified = false;
|
let verified = false;
|
||||||
|
@ -111,6 +112,11 @@ export const polls = router({
|
||||||
}
|
}
|
||||||
|
|
||||||
const poll = await prisma.poll.create({
|
const poll = await prisma.poll.create({
|
||||||
|
select: {
|
||||||
|
adminUrlId: true,
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
},
|
||||||
data: {
|
data: {
|
||||||
id: await nanoid(),
|
id: await nanoid(),
|
||||||
title: input.title,
|
title: input.title,
|
||||||
|
@ -159,8 +165,9 @@ export const polls = router({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return { urlId: adminUrlId };
|
return { id: poll.id, urlId: adminUrlId };
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
update: publicProcedure
|
update: publicProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue