fix: some modifications to logging event detail input (#19070)
* some modifications to logging event detail input * add descriptive name
This commit is contained in:
@@ -7,6 +7,7 @@ import type { Dayjs } from "@calcom/dayjs";
|
||||
import { checkForConflicts } from "@calcom/features/bookings/lib/conflictChecker/checkForConflicts";
|
||||
import { parseBookingLimit, parseDurationLimit } from "@calcom/lib";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { getPiiFreeUser } from "@calcom/lib/piiFreeData";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
|
||||
import type { getEventTypeResponse } from "./getEventTypesFromDB";
|
||||
@@ -101,6 +102,22 @@ export async function ensureAvailableUsers(
|
||||
},
|
||||
});
|
||||
|
||||
const piiFreeInputDataForLogging = safeStringify({
|
||||
startDateTimeUtc,
|
||||
endDateTimeUtc,
|
||||
...{
|
||||
...input,
|
||||
originalRescheduledBooking: input.originalRescheduledBooking
|
||||
? {
|
||||
...input.originalRescheduledBooking,
|
||||
user: input.originalRescheduledBooking?.user
|
||||
? getPiiFreeUser(input.originalRescheduledBooking.user)
|
||||
: null,
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
usersAvailability.forEach(({ oooExcludedDateRanges: dateRanges, busy: bufferedBusyTimes }, index) => {
|
||||
const user = eventType.users[index];
|
||||
|
||||
@@ -112,25 +129,14 @@ export async function ensureAvailableUsers(
|
||||
if (!dateRanges.length) {
|
||||
loggerWithEventDetails.error(
|
||||
`User does not have availability at this time.`,
|
||||
safeStringify({
|
||||
startDateTimeUtc,
|
||||
endDateTimeUtc,
|
||||
input,
|
||||
})
|
||||
piiFreeInputDataForLogging
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
//check if event time is within the date range
|
||||
if (!hasDateRangeForBooking(dateRanges, startDateTimeUtc, endDateTimeUtc)) {
|
||||
loggerWithEventDetails.error(
|
||||
`No date range for booking.`,
|
||||
safeStringify({
|
||||
startDateTimeUtc,
|
||||
endDateTimeUtc,
|
||||
input,
|
||||
})
|
||||
);
|
||||
loggerWithEventDetails.error(`No date range for booking.`, piiFreeInputDataForLogging);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,14 +155,7 @@ export async function ensureAvailableUsers(
|
||||
});
|
||||
|
||||
if (availableUsers.length === 0) {
|
||||
loggerWithEventDetails.error(
|
||||
`No available users found.`,
|
||||
safeStringify({
|
||||
startDateTimeUtc,
|
||||
endDateTimeUtc,
|
||||
input,
|
||||
})
|
||||
);
|
||||
loggerWithEventDetails.error(`No available users found.`, piiFreeInputDataForLogging);
|
||||
throw new Error(ErrorCode.NoAvailableUsersFound);
|
||||
}
|
||||
// make sure TypeScript understands availableUsers is at least one.
|
||||
|
||||
Reference in New Issue
Block a user