diff --git a/packages/app-store/googlecalendar/lib/CalendarService.ts b/packages/app-store/googlecalendar/lib/CalendarService.ts index 3366a4c11e38b4..72924189d2609a 100644 --- a/packages/app-store/googlecalendar/lib/CalendarService.ts +++ b/packages/app-store/googlecalendar/lib/CalendarService.ts @@ -62,6 +62,7 @@ export default class GoogleCalendarService implements Calendar { // `Failed to refresh access token for Google Calendar: userId: ${credential.userId}` // ); this.log.error("Error refreshing google token", err); + Sentry.captureException(err); } return myGoogleAuth; }; @@ -339,7 +340,10 @@ export default class GoogleCalendarService implements Calendar { }, }, (err, apires) => { - if (err) return reject(err); + if (err) { + Sentry.captureException(err); + return reject(err); + } // If there's no calendar we just skip if (!apires?.data.calendars) return resolve([]); const result = Object.values(apires.data.calendars).reduce((c, i) => { diff --git a/packages/core/CalendarManager.ts b/packages/core/CalendarManager.ts index 30d4dba73242de..ce522ed9dcda62 100644 --- a/packages/core/CalendarManager.ts +++ b/packages/core/CalendarManager.ts @@ -1,4 +1,5 @@ import { SelectedCalendar } from "@prisma/client"; +import * as Sentry from "@sentry/nextjs"; import { createHash } from "crypto"; import _ from "lodash"; @@ -186,6 +187,12 @@ export const getBusyCalendarTimes = async ( calendars: selectedCalendars, credentials: withCredentials, }); + Sentry.captureException(error, { + extra: { + calendars: selectedCalendars, + credentials: withCredentials, + }, + }); } return results.reduce((acc, availability) => acc.concat(availability), []); }; diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.ts index 403e94339c89a0..81998f09d73f8a 100644 --- a/packages/features/bookings/lib/handleCancelBooking.ts +++ b/packages/features/bookings/lib/handleCancelBooking.ts @@ -6,6 +6,7 @@ import { WorkflowMethods, WorkflowReminder, } from "@prisma/client"; +import * as Sentry from "@sentry/nextjs"; import { NextApiRequest } from "next"; import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; @@ -182,6 +183,7 @@ async function handler(req: NextApiRequest & { userId?: number }) { smsReminderNumber: bookingToDelete.smsReminderNumber || undefined, }).catch((e) => { console.error(`Error executing webhook for event: ${eventTrigger}, URL: ${webhook.subscriberUrl}`, e); + Sentry.captureException(e); }) ); await Promise.all(promises); diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index a9ad9acd9ad35a..f71e732842869c 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -6,6 +6,7 @@ import { SchedulingType, WebhookTriggerEvents, } from "@prisma/client"; +import * as Sentry from "@sentry/nextjs"; import async from "async"; import { isValidPhoneNumber } from "libphonenumber-js"; import { cloneDeep } from "lodash"; @@ -243,10 +244,11 @@ async function ensureAvailableUsers( } else { isAvailableToBeBooked = isAvailable(bufferedBusyTimes, input.dateFrom, eventType.length); } - } catch { + } catch (e) { log.debug({ message: "Unable set isAvailableToBeBooked. Using true. ", }); + Sentry.captureException(e); } if (isAvailableToBeBooked) { @@ -311,6 +313,7 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) { log.debug({ message: "Unable set timeOutOfBounds. Using false. ", }); + Sentry.captureException(error); } if (timeOutOfBounds) { @@ -772,6 +775,9 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) { } catch (_err) { const err = getErrorFromUnknown(_err); log.error(`Booking ${eventTypeId} failed`, "Error when saving booking to db", err.message); + + Sentry.captureException(err); + if (err.code === "P2002") { throw new HttpError({ statusCode: 409, message: "booking.conflict" }); } @@ -1007,6 +1013,7 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) { }); } catch (error) { log.error("Error while running scheduledJobs for booking", error); + Sentry.captureException(error); } try { @@ -1041,11 +1048,13 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) { smsReminderNumber: booking?.smsReminderNumber || undefined, }).catch((e) => { console.error(`Error executing webhook for event: ${eventTrigger}, URL: ${sub.subscriberUrl}`, e); + Sentry.captureException(e); }) ); await Promise.all(promises); } catch (error) { log.error("Error while sending webhook", error); + Sentry.captureException(error); } } @@ -1067,6 +1076,7 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) { } } catch (error) { log.error("Error while updating hashed link", error); + Sentry.captureException(error); } if (!booking) throw new HttpError({ statusCode: 400, message: "Booking failed" }); @@ -1087,6 +1097,7 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) { }); } catch (error) { log.error("Error while creating booking references", error); + Sentry.captureException(error); } try { @@ -1100,6 +1111,7 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) { ); } catch (error) { log.error("Error while scheduling workflow reminders", error); + Sentry.captureException(error); } // booking successful