Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
📈 Include pollId when capturing events (#555)
Luke Vellad14a88e9ebcf
diff --git a/apps/web/src/components/create-poll.tsx b/apps/web/src/components/create-poll.tsxindex f3eeae9fb..7ef501dfe 100644--- a/apps/web/src/components/create-poll.tsx+++ b/apps/web/src/components/create-poll.tsx@@ -93,6 +93,7 @@ const Page: React.FunctionComponent<CreatePollPageProps> = ({onSuccess: (res) => {setIsRedirecting(true);posthog.capture("created poll", {+ pollId: res.id,numberOfOptions: formData.options?.options?.length,optionsView: formData?.options?.view,});diff --git a/apps/web/src/components/poll/mutations.ts b/apps/web/src/components/poll/mutations.tsindex 63c3628c4..e16289df8 100644--- a/apps/web/src/components/poll/mutations.ts+++ b/apps/web/src/components/poll/mutations.ts@@ -15,8 +15,9 @@ export const normalizeVotes = (export const useAddParticipantMutation = () => {return trpc.polls.participants.add.useMutation({- onSuccess: (_, { name }) => {+ onSuccess: (_, { pollId, name }) => {posthog.capture("add participant", {+ pollId,name,});},@@ -61,8 +62,9 @@ export const useDeleteParticipantMutation = () => {},);},- onSuccess: (_, { participantId }) => {+ onSuccess: (_, { pollId, participantId }) => {posthog.capture("remove participant", {+ pollId,participantId,});},diff --git a/apps/web/src/server/routers/polls.ts b/apps/web/src/server/routers/polls.tsindex 73084b312..a1cece593 100644--- a/apps/web/src/server/routers/polls.ts+++ b/apps/web/src/server/routers/polls.ts@@ -94,73 +94,80 @@ export const polls = router({demo: z.boolean().optional(),}),)- .mutation(async ({ ctx, input }): Promise<{ urlId: string }> => {- const adminUrlId = await nanoid();- const participantUrlId = await nanoid();- let verified = false;+ .mutation(+ async ({ ctx, input }): Promise<{ id: string; urlId: string }> => {+ const adminUrlId = await nanoid();+ const participantUrlId = await nanoid();+ let verified = false;- if (ctx.session.user.isGuest === false) {- const user = await prisma.user.findUnique({- where: { id: ctx.session.user.id },- });+ if (ctx.session.user.isGuest === false) {+ const user = await prisma.user.findUnique({+ where: { id: ctx.session.user.id },+ });- // If user is logged in with the same email address- if (user?.email === input.user.email) {- verified = true;+ // If user is logged in with the same email address+ if (user?.email === input.user.email) {+ verified = true;+ }}- }- const poll = await prisma.poll.create({- data: {- id: await nanoid(),- title: input.title,- type: input.type,- timeZone: input.timeZone,- location: input.location,- description: input.description,- authorName: input.user.name,- demo: input.demo,- verified: verified,- notifications: verified,- adminUrlId,- participantUrlId,- user: {- connectOrCreate: {- where: {- email: input.user.email,- },- create: {- id: await nanoid(),- ...input.user,+ const poll = await prisma.poll.create({+ select: {+ adminUrlId: true,+ id: true,+ title: true,+ },+ data: {+ id: await nanoid(),+ title: input.title,+ type: input.type,+ timeZone: input.timeZone,+ location: input.location,+ description: input.description,+ authorName: input.user.name,+ demo: input.demo,+ verified: verified,+ notifications: verified,+ adminUrlId,+ participantUrlId,+ user: {+ connectOrCreate: {+ where: {+ email: input.user.email,+ },+ create: {+ id: await nanoid(),+ ...input.user,+ },},},- },- options: {- createMany: {- data: input.options.map((value) => ({- value,- })),+ options: {+ createMany: {+ data: input.options.map((value) => ({+ value,+ })),+ },},},- },- });+ });- const adminLink = absoluteUrl(`/admin/${adminUrlId}`);- const participantLink = absoluteUrl(`/p/${participantUrlId}`);+ const adminLink = absoluteUrl(`/admin/${adminUrlId}`);+ const participantLink = absoluteUrl(`/p/${participantUrlId}`);- await sendEmail("NewPollEmail", {- to: input.user.email,- subject: `Let's find a date for ${poll.title}`,- props: {- title: poll.title,- name: input.user.name,- adminLink,- participantLink,- },- });+ await sendEmail("NewPollEmail", {+ to: input.user.email,+ subject: `Let's find a date for ${poll.title}`,+ props: {+ title: poll.title,+ name: input.user.name,+ adminLink,+ participantLink,+ },+ });- return { urlId: adminUrlId };- }),+ return { id: poll.id, urlId: adminUrlId };+ },+ ),update: publicProcedure.input(z.object({