-
Notifications
You must be signed in to change notification settings - Fork 11.7k
feat: booking errors logging #12325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: booking errors logging #12325
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
dafb55f
feat: booking errors logging
Udit-takkar 957dd65
chore: add more logs
Udit-takkar a1a133a
fix: imports
Udit-takkar ad0eb2d
chore: type errors
Udit-takkar f74c19d
chore: add seat bookng error
Udit-takkar ef0ca14
Merge branch 'main' into feat/booking-error-logging
Udit-takkar 8f268e6
chore: add ErrorCoes
Udit-takkar 083b8d7
chore: remove log
Udit-takkar 73f0399
Merge branch 'main' into feat/booking-error-logging
PeerRich 28b30d7
chore: small fixes
Udit-takkar f83892a
fix: remove calendar event error
Udit-takkar 14fbb0b
chore: comment
Udit-takkar 368d8d4
chore: remove unused
Udit-takkar 317eae0
fix: tests
Udit-takkar 5502f66
chore
Udit-takkar f1a1565
fix: test collective scheduling
Udit-takkar b0fcf29
chore: undo change
Udit-takkar 6fe7d39
Merge branch 'main' into feat/booking-error-logging
zomars 4fe5d0b
Update common.json
zomars File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { isValidPhoneNumber } from "libphonenumber-js"; | |
| import { cloneDeep } from "lodash"; | ||
| import type { NextApiRequest } from "next"; | ||
| import short, { uuid } from "short-uuid"; | ||
| import type { Logger } from "tslog"; | ||
| import { v5 as uuidv5 } from "uuid"; | ||
| import z from "zod"; | ||
|
|
||
|
|
@@ -52,6 +53,7 @@ import { cancelScheduledJobs, scheduleTrigger } from "@calcom/features/webhooks/ | |
| import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib"; | ||
| import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser"; | ||
| import { getDefaultEvent, getUsernameList } from "@calcom/lib/defaultEvents"; | ||
| import { ErrorCode } from "@calcom/lib/errorCodes"; | ||
| import { getErrorFromUnknown } from "@calcom/lib/errors"; | ||
| import getPaymentAppData from "@calcom/lib/getPaymentAppData"; | ||
| import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType"; | ||
|
|
@@ -362,7 +364,8 @@ async function ensureAvailableUsers( | |
| eventType: Awaited<ReturnType<typeof getEventTypesFromDB>> & { | ||
| users: IsFixedAwareUser[]; | ||
| }, | ||
| input: { dateFrom: string; dateTo: string; timeZone: string; originalRescheduledBooking?: BookingType } | ||
| input: { dateFrom: string; dateTo: string; timeZone: string; originalRescheduledBooking?: BookingType }, | ||
| loggerWithEventDetails: Logger<unknown> | ||
| ) { | ||
| const availableUsers: IsFixedAwareUser[] = []; | ||
| const duration = dayjs(input.dateTo).diff(input.dateFrom, "minute"); | ||
|
|
@@ -414,7 +417,8 @@ async function ensureAvailableUsers( | |
| } | ||
| } | ||
| if (!availableUsers.length) { | ||
| throw new Error("No available users found."); | ||
| loggerWithEventDetails.error(`No available users found.`); | ||
| throw new Error(ErrorCode.NoAvailableUsersFound); | ||
| } | ||
| return availableUsers; | ||
| } | ||
|
|
@@ -537,7 +541,7 @@ async function getBookingData({ | |
| return true; | ||
| }; | ||
| if (!reqBodyWithEnd(reqBody)) { | ||
| throw new Error("Internal Error."); | ||
| throw new Error(ErrorCode.RequestBodyWithouEnd); | ||
| } | ||
| // reqBody.end is no longer an optional property. | ||
| if ("customInputs" in reqBody) { | ||
|
|
@@ -628,6 +632,7 @@ async function handler( | |
| ) { | ||
| const { userId } = req; | ||
|
|
||
| throw new Error("Not implemented"); | ||
| // handle dynamic user | ||
| let eventType = | ||
| !req.body.eventTypeId && !!req.body.eventTypeSlug | ||
|
|
@@ -672,10 +677,11 @@ async function handler( | |
|
|
||
| const fullName = getFullName(bookerName); | ||
|
|
||
| // Why are we only using "en" locale | ||
| const tGuests = await getTranslation("en", "common"); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we only using "en" locale? |
||
|
|
||
| const dynamicUserList = Array.isArray(reqBody.user) ? reqBody.user : getUsernameList(reqBody.user); | ||
| if (!eventType) throw new HttpError({ statusCode: 404, message: "eventType.notFound" }); | ||
| if (!eventType) throw new HttpError({ statusCode: 404, message: "event_type_not_found" }); | ||
|
|
||
| const isTeamEventType = | ||
| !!eventType.schedulingType && ["COLLECTIVE", "ROUND_ROBIN"].includes(eventType.schedulingType); | ||
|
|
@@ -916,7 +922,8 @@ async function handler( | |
| dateTo: dayjs(reqBody.end).tz(reqBody.timeZone).format(), | ||
| timeZone: reqBody.timeZone, | ||
| originalRescheduledBooking, | ||
| } | ||
| }, | ||
| loggerWithEventDetails | ||
| ); | ||
|
|
||
| const luckyUsers: typeof users = []; | ||
|
|
@@ -946,7 +953,7 @@ async function handler( | |
| if ( | ||
| availableUsers.filter((user) => user.isFixed).length !== users.filter((user) => user.isFixed).length | ||
| ) { | ||
| throw new Error("Some of the hosts are unavailable for booking."); | ||
| throw new Error(ErrorCode.HostsUnavailableForBooking); | ||
| } | ||
| // Pushing fixed user before the luckyUser guarantees the (first) fixed user as the organizer. | ||
| users = [...availableUsers.filter((user) => user.isFixed), ...luckyUsers]; | ||
|
|
@@ -1264,7 +1271,7 @@ async function handler( | |
| booking.attendees.find((attendee) => attendee.email === invitee[0].email) && | ||
| dayjs.utc(booking.startTime).format() === evt.startTime | ||
| ) { | ||
| throw new HttpError({ statusCode: 409, message: "Already signed up for this booking." }); | ||
| throw new HttpError({ statusCode: 409, message: ErrorCode.AlreadySignedUpForBooking }); | ||
| } | ||
|
|
||
| // There are two paths here, reschedule a booking with seats and booking seats without reschedule | ||
|
|
@@ -2675,7 +2682,7 @@ const findBookingQuery = async (bookingId: number) => { | |
|
|
||
| // This should never happen but it's just typescript safe | ||
| if (!foundBooking) { | ||
| throw new Error("Internal Error."); | ||
| throw new Error("Internal Error. Couldn't find booking"); | ||
| } | ||
|
|
||
| // Don't leak any sensitive data | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.