Scheduling infrastructure for absolutely everyone.
chore: Add logging to handleNewBooking (#22868)
Joe Au-Yeungb7e11dc112b3
diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.tsindex ebe8d1ec24b..14310476949 100644--- a/packages/features/bookings/lib/handleNewBooking.ts+++ b/packages/features/bookings/lib/handleNewBooking.ts@@ -387,6 +387,23 @@ export type BookingHandlerInput = {forcedSlug?: string;} & PlatformParams;+function formatAvailabilitySnapshot(data: {+ dateRanges: { start: dayjs.Dayjs; end: dayjs.Dayjs }[];+ oooExcludedDateRanges: { start: dayjs.Dayjs; end: dayjs.Dayjs }[];+}) {+ return {+ ...data,+ dateRanges: data.dateRanges.map(({ start, end }) => ({+ start: start.toISOString(),+ end: end.toISOString(),+ })),+ oooExcludedDateRanges: data.oooExcludedDateRanges.map(({ start, end }) => ({+ start: start.toISOString(),+ end: end.toISOString(),+ })),+ };+}+async function handler(input: BookingHandlerInput,bookingDataSchemaGetter: BookingDataSchemaGetter = getBookingDataSchema@@ -1397,7 +1414,10 @@ async function handler(logger.info(`Booking created`, {bookingUid: booking.uid,- availabilitySnapshot: organizerUserAvailability?.availabilityData,+ selectedCalendarIds: organizerUser.allSelectedCalendars?.map((c) => c.id) ?? [],+ availabilitySnapshot: organizerUserAvailability?.availabilityData+ ? formatAvailabilitySnapshot(organizerUserAvailability.availabilityData)+ : null,});}diff --git a/packages/lib/getBusyTimes.ts b/packages/lib/getBusyTimes.tsindex ee8131027db..2b316d51e53 100644--- a/packages/lib/getBusyTimes.ts+++ b/packages/lib/getBusyTimes.ts@@ -252,6 +252,10 @@ const _getBusyTimes = async (params: {console.log("videoBusyTimes", videoBusyTimes);busyTimes.push(...videoBusyTimes);*/+ } else {+ logger.warn(`No credentials found for user ${userId}`, {+ selectedCalendarIds: selectedCalendars.map((calendar) => calendar.id),+ });}logger.debug("getBusyTimes:",diff --git a/packages/lib/logger.ts b/packages/lib/logger.tsindex d9f22f3a45e..5d60e8dd782 100644--- a/packages/lib/logger.ts+++ b/packages/lib/logger.ts@@ -9,11 +9,12 @@ const logger = new Logger({prettyErrorStackTemplate: " • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}", // defaultprettyErrorTemplate: "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}", // defaultprettyLogTemplate: "{{hh}}:{{MM}}:{{ss}}:{{ms}} [{{logLevelName}}] ", // default with exclusion of `{{filePathWithLine}}`- stylePrettyLogs: true,+ stylePrettyLogs: !IS_PRODUCTION,prettyLogStyles: {name: "yellow",dateIsoStr: "blue",},+ type: IS_PRODUCTION ? "json" : "pretty",});export default logger;