feat: better logging for failed webhooks (#14825)
Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]> Co-authored-by: Omar López <[email protected]>
This commit is contained in:
7 files changed
+31
-18
No files matched your search
@@ -80,7 +80,10 @@ const triggerWebhook = async ({
|
|||||||
...evt,
|
...evt,
|
||||||
downloadLink,
|
downloadLink,
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.error(`Error executing webhook for event: ${eventTrigger}, URL: ${webhook.subscriberUrl}`, e);
|
log.error(
|
||||||
|
`Error executing webhook for event: ${eventTrigger}, URL: ${webhook.subscriberUrl}, bookingId: ${evt.bookingId}, bookingUid: ${evt.uid}`,
|
||||||
|
safeStringify(e)
|
||||||
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ export async function handleBookingRequested(args: {
|
|||||||
sub,
|
sub,
|
||||||
webhookPayload
|
webhookPayload
|
||||||
).catch((e) => {
|
).catch((e) => {
|
||||||
console.error(
|
log.error(
|
||||||
`Error executing webhook for event: ${WebhookTriggerEvents.BOOKING_REQUESTED}, URL: ${sub.subscriberUrl}`,
|
`Error executing webhook for event: ${WebhookTriggerEvents.BOOKING_REQUESTED}, URL: ${sub.subscriberUrl}, bookingId: ${evt.bookingId}, bookingUid: ${evt.uid}`,
|
||||||
e
|
safeStringify(e)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib";
|
|||||||
import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";
|
import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";
|
||||||
import { HttpError } from "@calcom/lib/http-error";
|
import { HttpError } from "@calcom/lib/http-error";
|
||||||
import logger from "@calcom/lib/logger";
|
import logger from "@calcom/lib/logger";
|
||||||
|
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||||
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
|
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
|
||||||
import prisma, { bookingMinimalSelect } from "@calcom/prisma";
|
import prisma, { bookingMinimalSelect } from "@calcom/prisma";
|
||||||
@@ -307,7 +308,10 @@ async function handler(req: CustomRequest) {
|
|||||||
status: "CANCELLED",
|
status: "CANCELLED",
|
||||||
smsReminderNumber: bookingToDelete.smsReminderNumber || undefined,
|
smsReminderNumber: bookingToDelete.smsReminderNumber || undefined,
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.error(`Error executing webhook for event: ${eventTrigger}, URL: ${webhook.subscriberUrl}`, e);
|
logger.error(
|
||||||
|
`Error executing webhook for event: ${eventTrigger}, URL: ${webhook.subscriberUrl}, bookingId: ${evt.bookingId}, bookingUid: ${evt.uid}`,
|
||||||
|
safeStringify(e)
|
||||||
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|||||||
@@ -369,9 +369,9 @@ export async function handleConfirmation(args: {
|
|||||||
smsReminderNumber: booking.smsReminderNumber || undefined,
|
smsReminderNumber: booking.smsReminderNumber || undefined,
|
||||||
metadata: meetingUrl ? { videoCallUrl: meetingUrl } : undefined,
|
metadata: meetingUrl ? { videoCallUrl: meetingUrl } : undefined,
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.error(
|
log.error(
|
||||||
`Error executing webhook for event: ${WebhookTriggerEvents.BOOKING_CREATED}, URL: ${sub.subscriberUrl}`,
|
`Error executing webhook for event: ${WebhookTriggerEvents.BOOKING_CREATED}, URL: ${sub.subscriberUrl}, bookingId: ${evt.bookingId}, bookingUid: ${evt.uid}`,
|
||||||
e
|
safeStringify(e)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -426,9 +426,9 @@ export async function handleConfirmation(args: {
|
|||||||
...(paid ? paymentMetadata : {}),
|
...(paid ? paymentMetadata : {}),
|
||||||
},
|
},
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.error(
|
log.error(
|
||||||
`Error executing webhook for event: ${WebhookTriggerEvents.BOOKING_PAID}, URL: ${sub.subscriberUrl}`,
|
`Error executing webhook for event: ${WebhookTriggerEvents.BOOKING_PAID}, URL: ${sub.subscriberUrl}, bookingId: ${evt.bookingId}, bookingUid: ${evt.uid}`,
|
||||||
e
|
safeStringify(e)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { deleteScheduledWhatsappReminder } from "@calcom/features/ee/workflows/l
|
|||||||
import sendPayload from "@calcom/features/webhooks/lib/sendOrSchedulePayload";
|
import sendPayload from "@calcom/features/webhooks/lib/sendOrSchedulePayload";
|
||||||
import type { EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";
|
import type { EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";
|
||||||
import { HttpError } from "@calcom/lib/http-error";
|
import { HttpError } from "@calcom/lib/http-error";
|
||||||
|
import logger from "@calcom/lib/logger";
|
||||||
|
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
import { WebhookTriggerEvents, WorkflowMethods } from "@calcom/prisma/enums";
|
import { WebhookTriggerEvents, WorkflowMethods } from "@calcom/prisma/enums";
|
||||||
@@ -130,9 +132,9 @@ async function cancelAttendeeSeat(
|
|||||||
status: "CANCELLED",
|
status: "CANCELLED",
|
||||||
smsReminderNumber: bookingToDelete.smsReminderNumber || undefined,
|
smsReminderNumber: bookingToDelete.smsReminderNumber || undefined,
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.error(
|
logger.error(
|
||||||
`Error executing webhook for event: ${WebhookTriggerEvents.BOOKING_CANCELLED}, URL: ${webhook.subscriberUrl}`,
|
`Error executing webhook for event: ${WebhookTriggerEvents.BOOKING_CANCELLED}, URL: ${webhook.subscriberUrl}, bookingId: ${evt.bookingId}, bookingUid: ${evt.uid}`,
|
||||||
e
|
safeStringify(e)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { GetSubscriberOptions } from "@calcom/features/webhooks/lib/getWebh
|
|||||||
import sendPayload from "@calcom/features/webhooks/lib/sendOrSchedulePayload";
|
import sendPayload from "@calcom/features/webhooks/lib/sendOrSchedulePayload";
|
||||||
import type { WebhookDataType } from "@calcom/features/webhooks/lib/sendPayload";
|
import type { WebhookDataType } from "@calcom/features/webhooks/lib/sendPayload";
|
||||||
import logger from "@calcom/lib/logger";
|
import logger from "@calcom/lib/logger";
|
||||||
|
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||||
|
|
||||||
export async function handleWebhookTrigger(args: {
|
export async function handleWebhookTrigger(args: {
|
||||||
subscriberOptions: GetSubscriberOptions;
|
subscriberOptions: GetSubscriberOptions;
|
||||||
@@ -15,9 +16,9 @@ export async function handleWebhookTrigger(args: {
|
|||||||
const promises = subscribers.map((sub) =>
|
const promises = subscribers.map((sub) =>
|
||||||
sendPayload(sub.secret, args.eventTrigger, new Date().toISOString(), sub, args.webhookData).catch(
|
sendPayload(sub.secret, args.eventTrigger, new Date().toISOString(), sub, args.webhookData).catch(
|
||||||
(e) => {
|
(e) => {
|
||||||
console.error(
|
logger.error(
|
||||||
`Error executing webhook for event: ${args.eventTrigger}, URL: ${sub.subscriberUrl}`,
|
`Error executing webhook for event: ${args.eventTrigger}, URL: ${sub.subscriberUrl}, bookingId: ${args.webhookData.bookingId}, bookingUid: ${args.webhookData.uid}`,
|
||||||
e
|
safeStringify(e)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -304,7 +304,10 @@ export const requestRescheduleHandler = async ({ ctx, input }: RequestReschedule
|
|||||||
...evt,
|
...evt,
|
||||||
smsReminderNumber: bookingToReschedule.smsReminderNumber || undefined,
|
smsReminderNumber: bookingToReschedule.smsReminderNumber || undefined,
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.error(`Error executing webhook for event: ${eventTrigger}, URL: ${webhook.subscriberUrl}`, e);
|
log.error(
|
||||||
|
`Error executing webhook for event: ${eventTrigger}, URL: ${webhook.subscriberUrl}, bookingId: ${evt.bookingId}, bookingUid: ${evt.uid}`,
|
||||||
|
safeStringify(e)
|
||||||
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|||||||
Reference in new issue
Block a user