From 1740e34c798005c2b4295597602d0e0d61cef453 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 15:14:51 +0100 Subject: [PATCH] perf: remove unused submitFeedback tRPC route to reduce type generation load (#21418) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: alex@cal.com --- .../server/routers/loggedInViewer/_router.tsx | 7 ---- .../loggedInViewer/submitFeedback.handler.ts | 38 ------------------- .../loggedInViewer/submitFeedback.schema.ts | 8 ---- 3 files changed, 53 deletions(-) delete mode 100644 packages/trpc/server/routers/loggedInViewer/submitFeedback.handler.ts delete mode 100644 packages/trpc/server/routers/loggedInViewer/submitFeedback.schema.ts diff --git a/packages/trpc/server/routers/loggedInViewer/_router.tsx b/packages/trpc/server/routers/loggedInViewer/_router.tsx index 7400068208..208bb58eab 100644 --- a/packages/trpc/server/routers/loggedInViewer/_router.tsx +++ b/packages/trpc/server/routers/loggedInViewer/_router.tsx @@ -8,13 +8,11 @@ import { ZNoShowInputSchema } from "./markNoShow.schema"; import { teamsAndUserProfilesQuery } from "./procedures/teamsAndUserProfilesQuery"; import { ZRemoveNotificationsSubscriptionInputSchema } from "./removeNotificationsSubscription.schema"; import { ZRoutingFormOrderInputSchema } from "./routingFormOrder.schema"; -import { ZSubmitFeedbackInputSchema } from "./submitFeedback.schema"; type AppsRouterHandlerCache = { stripeCustomer?: typeof import("./stripeCustomer.handler").stripeCustomerHandler; eventTypeOrder?: typeof import("./eventTypeOrder.handler").eventTypeOrderHandler; routingFormOrder?: typeof import("./routingFormOrder.handler").routingFormOrderHandler; - submitFeedback?: typeof import("./submitFeedback.handler").submitFeedbackHandler; teamsAndUserProfilesQuery?: typeof import("./teamsAndUserProfilesQuery.handler").teamsAndUserProfilesQuery; connectAndJoin?: typeof import("./connectAndJoin.handler").Handler; addSecondaryEmail?: typeof import("./addSecondaryEmail.handler").addSecondaryEmailHandler; @@ -46,11 +44,6 @@ export const loggedInViewerRouter = router({ return routingFormOrderHandler({ ctx, input }); }), - //Comment for PR: eventTypePosition is not used anywhere - submitFeedback: authedProcedure.input(ZSubmitFeedbackInputSchema).mutation(async ({ ctx, input }) => { - const { submitFeedbackHandler } = await import("./submitFeedback.handler"); - return submitFeedbackHandler({ ctx, input }); - }), teamsAndUserProfilesQuery, connectAndJoin: authedProcedure.input(ZConnectAndJoinInputSchema).mutation(async ({ ctx, input }) => { const { Handler } = await import("./connectAndJoin.handler"); diff --git a/packages/trpc/server/routers/loggedInViewer/submitFeedback.handler.ts b/packages/trpc/server/routers/loggedInViewer/submitFeedback.handler.ts deleted file mode 100644 index 0037445ea6..0000000000 --- a/packages/trpc/server/routers/loggedInViewer/submitFeedback.handler.ts +++ /dev/null @@ -1,38 +0,0 @@ -import dayjs from "@calcom/dayjs"; -import { sendFeedbackEmail } from "@calcom/emails"; -import { sendFeedbackFormbricks } from "@calcom/lib/formbricks"; -import { prisma } from "@calcom/prisma"; -import type { TrpcSessionUser } from "@calcom/trpc/server/types"; - -import type { TSubmitFeedbackInputSchema } from "./submitFeedback.schema"; - -type SubmitFeedbackOptions = { - ctx: { - user: NonNullable; - }; - input: TSubmitFeedbackInputSchema; -}; - -export const submitFeedbackHandler = async ({ ctx, input }: SubmitFeedbackOptions) => { - const { rating, comment } = input; - - const feedback = { - username: ctx.user.username || "Nameless", - email: ctx.user.email || "No email address", - rating: rating, - comment: comment, - }; - - await prisma.feedback.create({ - data: { - date: dayjs().toISOString(), - userId: ctx.user.id, - rating: rating, - comment: comment, - }, - }); - if (process.env.NEXT_PUBLIC_FORMBRICKS_HOST_URL && process.env.NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID) - sendFeedbackFormbricks(ctx.user.id, feedback); - - if (process.env.SEND_FEEDBACK_EMAIL && comment) sendFeedbackEmail(feedback); -}; diff --git a/packages/trpc/server/routers/loggedInViewer/submitFeedback.schema.ts b/packages/trpc/server/routers/loggedInViewer/submitFeedback.schema.ts deleted file mode 100644 index f56091c1ab..0000000000 --- a/packages/trpc/server/routers/loggedInViewer/submitFeedback.schema.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { z } from "zod"; - -export const ZSubmitFeedbackInputSchema = z.object({ - rating: z.string(), - comment: z.string(), -}); - -export type TSubmitFeedbackInputSchema = z.infer;