chore: Add logging to handleNewBooking (#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>
This commit is contained in:
co-authored by
coderabbitai[bot]
Alex van Andel
parent
35a373e70a
commit
b7e11dc112
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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:",
|
||||
|
||||
@@ -9,11 +9,12 @@ const logger = new Logger({
|
||||
prettyErrorStackTemplate: " • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}", // default
|
||||
prettyErrorTemplate: "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}", // default
|
||||
prettyLogTemplate: "{{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;
|
||||
|
||||
Reference in New Issue
Block a user