refactor: Uses withReporting to force named functions for tracing (#21219)
This commit is contained in:
1 parent
79d695236f
commit
b3d3cb1dee
35 files changed
+853
-393
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import type { FormResponse, Fields } from "@calcom/app-store/routing-forms/types/types";
|
||||
import { zodRoutes } from "@calcom/app-store/routing-forms/zod";
|
||||
import { acrossQueryValueCompatiblity } from "@calcom/lib/raqb/raqbUtils";
|
||||
import { withReporting } from "@calcom/lib/sentryWrapper";
|
||||
import { getUsersAttributes } from "@calcom/lib/service/attribute/server/getAttributes";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { AssignmentReasonEnum } from "@calcom/prisma/enums";
|
||||
@@ -13,7 +14,16 @@ export enum RRReassignmentType {
|
||||
}
|
||||
|
||||
export default class AssignmentReasonRecorder {
|
||||
static async routingFormRoute({
|
||||
/**
|
||||
* We should use decorators to wrap the methods with withReporting
|
||||
* but we can't don't have support for static methods in decorators
|
||||
* so this is a workaround to wrap the methods with withReporting.
|
||||
*/
|
||||
static routingFormRoute = withReporting(
|
||||
AssignmentReasonRecorder._routingFormRoute,
|
||||
"AssignmentReasonRecorder.routingFormRoute"
|
||||
);
|
||||
static async _routingFormRoute({
|
||||
bookingId,
|
||||
routingFormResponseId,
|
||||
organizerId,
|
||||
@@ -113,8 +123,11 @@ export default class AssignmentReasonRecorder {
|
||||
}
|
||||
|
||||
// Separate method to handle rerouting
|
||||
|
||||
static async CRMOwnership({
|
||||
static CRMOwnership = withReporting(
|
||||
AssignmentReasonRecorder._CRMOwnership,
|
||||
"AssignmentReasonRecorder.CRMOwnership"
|
||||
);
|
||||
static async _CRMOwnership({
|
||||
bookingId,
|
||||
crmAppSlug,
|
||||
teamMemberEmail,
|
||||
@@ -143,8 +156,11 @@ export default class AssignmentReasonRecorder {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
static async roundRobinReassignment({
|
||||
static roundRobinReassignment = withReporting(
|
||||
AssignmentReasonRecorder._roundRobinReassignment,
|
||||
"AssignmentReasonRecorder.roundRobinReassignment"
|
||||
);
|
||||
static async _roundRobinReassignment({
|
||||
bookingId,
|
||||
reassignById,
|
||||
reassignReason,
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import type { Workflow, WorkflowStep } from "@calcom/features/ee/workflows/lib/types";
|
||||
import { checkSMSRateLimit } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
import { SENDER_NAME } from "@calcom/lib/constants";
|
||||
import { withReporting } from "@calcom/lib/sentryWrapper";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { SchedulingType, WorkflowActions, WorkflowTriggerEvents } from "@calcom/prisma/enums";
|
||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||
@@ -177,7 +178,7 @@ const processWorkflowStep = async (
|
||||
}
|
||||
};
|
||||
|
||||
export const scheduleWorkflowReminders = async (args: ScheduleWorkflowRemindersArgs) => {
|
||||
const _scheduleWorkflowReminders = async (args: ScheduleWorkflowRemindersArgs) => {
|
||||
const {
|
||||
workflows,
|
||||
smsReminderNumber,
|
||||
@@ -232,7 +233,7 @@ export interface SendCancelledRemindersArgs {
|
||||
hideBranding?: boolean;
|
||||
}
|
||||
|
||||
export const sendCancelledReminders = async (args: SendCancelledRemindersArgs) => {
|
||||
const _sendCancelledReminders = async (args: SendCancelledRemindersArgs) => {
|
||||
const { smsReminderNumber, evt, workflows, hideBranding } = args;
|
||||
|
||||
if (!workflows.length) return;
|
||||
@@ -241,7 +242,7 @@ export const sendCancelledReminders = async (args: SendCancelledRemindersArgs) =
|
||||
if (workflow.trigger !== WorkflowTriggerEvents.EVENT_CANCELLED) continue;
|
||||
|
||||
for (const step of workflow.steps) {
|
||||
processWorkflowStep(workflow, step, {
|
||||
await processWorkflowStep(workflow, step, {
|
||||
smsReminderNumber,
|
||||
hideBranding,
|
||||
calendarEvent: evt,
|
||||
@@ -249,3 +250,10 @@ export const sendCancelledReminders = async (args: SendCancelledRemindersArgs) =
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Export functions wrapped with withReporting
|
||||
export const scheduleWorkflowReminders = withReporting(
|
||||
_scheduleWorkflowReminders,
|
||||
"scheduleWorkflowReminders"
|
||||
);
|
||||
export const sendCancelledReminders = withReporting(_sendCancelledReminders, "sendCancelledReminders");
|
||||
@@ -3,6 +3,7 @@ import { scheduleEmailReminder } from "@calcom/features/ee/workflows/lib/reminde
|
||||
import type { Workflow } from "@calcom/features/ee/workflows/lib/types";
|
||||
import type { getDefaultEvent } from "@calcom/lib/defaultEvents";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { withReporting } from "@calcom/lib/sentryWrapper";
|
||||
import { WorkflowTriggerEvents, TimeUnit, WorkflowActions, WorkflowTemplates } from "@calcom/prisma/enums";
|
||||
|
||||
import type { ExtendedCalendarEvent } from "./reminderScheduler";
|
||||
@@ -11,7 +12,7 @@ const log = logger.getSubLogger({ prefix: ["[scheduleMandatoryReminder]"] });
|
||||
|
||||
export type NewBookingEventType = Awaited<ReturnType<typeof getDefaultEvent>> | getEventTypeResponse;
|
||||
|
||||
export async function scheduleMandatoryReminder({
|
||||
async function _scheduleMandatoryReminder({
|
||||
evt,
|
||||
workflows,
|
||||
requiresConfirmation,
|
||||
@@ -75,3 +76,8 @@ export async function scheduleMandatoryReminder({
|
||||
log.error("Error while scheduling mandatory reminders", JSON.stringify({ error }));
|
||||
}
|
||||
}
|
||||
|
||||
export const scheduleMandatoryReminder = withReporting(
|
||||
_scheduleMandatoryReminder,
|
||||
"scheduleMandatoryReminder"
|
||||
);
|
||||
Reference in new issue
Block a user