Skip to content

Commit b7e11dc

Browse files
joeauyeungcoderabbitai[bot]emrysal
authored
chore: Add logging to handleNewBooking (calcom#22868)
* Add logging * Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update logger config, fix Create booking log * Added oooExcludedDateRanges + type error fix --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>
1 parent 35a373e commit b7e11dc

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

packages/features/bookings/lib/handleNewBooking.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,23 @@ export type BookingHandlerInput = {
387387
forcedSlug?: string;
388388
} & PlatformParams;
389389

390+
function formatAvailabilitySnapshot(data: {
391+
dateRanges: { start: dayjs.Dayjs; end: dayjs.Dayjs }[];
392+
oooExcludedDateRanges: { start: dayjs.Dayjs; end: dayjs.Dayjs }[];
393+
}) {
394+
return {
395+
...data,
396+
dateRanges: data.dateRanges.map(({ start, end }) => ({
397+
start: start.toISOString(),
398+
end: end.toISOString(),
399+
})),
400+
oooExcludedDateRanges: data.oooExcludedDateRanges.map(({ start, end }) => ({
401+
start: start.toISOString(),
402+
end: end.toISOString(),
403+
})),
404+
};
405+
}
406+
390407
async function handler(
391408
input: BookingHandlerInput,
392409
bookingDataSchemaGetter: BookingDataSchemaGetter = getBookingDataSchema
@@ -1397,7 +1414,10 @@ async function handler(
13971414

13981415
logger.info(`Booking created`, {
13991416
bookingUid: booking.uid,
1400-
availabilitySnapshot: organizerUserAvailability?.availabilityData,
1417+
selectedCalendarIds: organizerUser.allSelectedCalendars?.map((c) => c.id) ?? [],
1418+
availabilitySnapshot: organizerUserAvailability?.availabilityData
1419+
? formatAvailabilitySnapshot(organizerUserAvailability.availabilityData)
1420+
: null,
14011421
});
14021422
}
14031423

packages/lib/getBusyTimes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ const _getBusyTimes = async (params: {
252252
console.log("videoBusyTimes", videoBusyTimes);
253253
busyTimes.push(...videoBusyTimes);
254254
*/
255+
} else {
256+
logger.warn(`No credentials found for user ${userId}`, {
257+
selectedCalendarIds: selectedCalendars.map((calendar) => calendar.id),
258+
});
255259
}
256260
logger.debug(
257261
"getBusyTimes:",

packages/lib/logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ const logger = new Logger({
99
prettyErrorStackTemplate: " • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}", // default
1010
prettyErrorTemplate: "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}", // default
1111
prettyLogTemplate: "{{hh}}:{{MM}}:{{ss}}:{{ms}} [{{logLevelName}}] ", // default with exclusion of `{{filePathWithLine}}`
12-
stylePrettyLogs: true,
12+
stylePrettyLogs: !IS_PRODUCTION,
1313
prettyLogStyles: {
1414
name: "yellow",
1515
dateIsoStr: "blue",
1616
},
17+
type: IS_PRODUCTION ? "json" : "pretty",
1718
});
1819

1920
export default logger;

0 commit comments

Comments
 (0)