Skip to content

Scheduling infrastructure for absolutely everyone.

feat: implement booking page error boundary (#20492)

Benny Joob5b4134b7566
diff --git a/apps/web/components/error/BookingPageErrorBoundary.tsx b/apps/web/components/error/BookingPageErrorBoundary.tsx
new file mode 100644
index 00000000000..79cc3b2707f
--- /dev/null
+++ b/apps/web/components/error/BookingPageErrorBoundary.tsx
@@ -0,0 +1,17 @@
+import { captureReactException } from "@sentry/nextjs";
+import React from "react";
+import { ErrorBoundary } from "react-error-boundary";
+
+import { ErrorPage } from "./error-page";
+
+export default function BookingPageErrorBoundary({ children }: { children: React.ReactNode }) {
+ return (
+ <ErrorBoundary
+ fallbackRender={({ error }) => <ErrorPage error={error} message={`${error}`} displayDebug={true} />}
+ onError={(error, info) => {
+ captureReactException(error, info);
+ }}>
+ {children}
+ </ErrorBoundary>
+ );
+}
diff --git a/apps/web/modules/d/[link]/d-type-view.tsx b/apps/web/modules/d/[link]/d-type-view.tsx
index 7f2595ead8d..39c221ab12b 100644
--- a/apps/web/modules/d/[link]/d-type-view.tsx
+++ b/apps/web/modules/d/[link]/d-type-view.tsx
@@ -5,6 +5,8 @@ import { getBookerWrapperClasses } from "@calcom/features/bookings/Booker/utils/
import { type PageProps } from "@lib/d/[link]/[slug]/getServerSideProps";
+import BookingPageErrorBoundary from "@components/error/BookingPageErrorBoundary";
+
export default function Type({
slug,
isEmbed,
@@ -18,18 +20,20 @@ export default function Type({
durationConfig,
}: PageProps) {
return (
- <main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
- <Booker
- username={user}
- eventSlug={slug}
- bookingData={booking}
- hideBranding={isBrandingHidden}
- isTeamEvent={isTeamEvent}
- entity={entity}
- duration={duration}
- hashedLink={hashedLink}
- durationConfig={durationConfig}
- />
- </main>
+ <BookingPageErrorBoundary>
+ <main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
+ <Booker
+ username={user}
+ eventSlug={slug}
+ bookingData={booking}
+ hideBranding={isBrandingHidden}
+ isTeamEvent={isTeamEvent}
+ entity={entity}
+ duration={duration}
+ hashedLink={hashedLink}
+ durationConfig={durationConfig}
+ />
+ </main>
+ </BookingPageErrorBoundary>
);
}
diff --git a/apps/web/modules/org/[orgSlug]/instant-meeting/team/[slug]/[type]/instant-meeting-view.tsx b/apps/web/modules/org/[orgSlug]/instant-meeting/team/[slug]/[type]/instant-meeting-view.tsx
index 8b30d62d652..c0c3f70c0c3 100644
--- a/apps/web/modules/org/[orgSlug]/instant-meeting/team/[slug]/[type]/instant-meeting-view.tsx
+++ b/apps/web/modules/org/[orgSlug]/instant-meeting/team/[slug]/[type]/instant-meeting-view.tsx
@@ -8,22 +8,26 @@ import { getBookerWrapperClasses } from "@calcom/features/bookings/Booker/utils/
import type { getServerSideProps } from "@lib/org/[orgSlug]/instant-meeting/team/[slug]/[type]/getServerSideProps";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
+import BookingPageErrorBoundary from "@components/error/BookingPageErrorBoundary";
+
export type Props = inferSSRProps<typeof getServerSideProps> & EmbedProps;
function Type({ slug, user, booking, isEmbed, isBrandingHidden, entity, eventTypeId, duration }: Props) {
return (
- <main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
- <Booker
- username={user}
- eventSlug={slug}
- bookingData={booking}
- hideBranding={isBrandingHidden}
- isTeamEvent
- isInstantMeeting
- entity={{ ...entity, eventTypeId: eventTypeId }}
- duration={duration}
- />
- </main>
+ <BookingPageErrorBoundary>
+ <main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
+ <Booker
+ username={user}
+ eventSlug={slug}
+ bookingData={booking}
+ hideBranding={isBrandingHidden}
+ isTeamEvent
+ isInstantMeeting
+ entity={{ ...entity, eventTypeId: eventTypeId }}
+ duration={duration}
+ />
+ </main>
+ </BookingPageErrorBoundary>
);
}
diff --git a/apps/web/modules/team/type-view.tsx b/apps/web/modules/team/type-view.tsx
index 4fce3061dc4..6153b6a0257 100644
--- a/apps/web/modules/team/type-view.tsx
+++ b/apps/web/modules/team/type-view.tsx
@@ -9,6 +9,8 @@ import { getBookerWrapperClasses } from "@calcom/features/bookings/Booker/utils/
import type { getServerSideProps } from "@lib/team/[slug]/[type]/getServerSideProps";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
+import BookingPageErrorBoundary from "@components/error/BookingPageErrorBoundary";
+
export type PageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
export const getMultipleDurationValue = (
@@ -37,30 +39,32 @@ function Type({
const searchParams = useSearchParams();
return (
- <main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
- <Booker
- username={user}
- eventSlug={slug}
- bookingData={booking}
- isInstantMeeting={isInstantMeeting}
- hideBranding={isBrandingHidden}
- isTeamEvent
- entity={{ ...eventData.entity, eventTypeId: eventData?.eventTypeId }}
- durationConfig={eventData.metadata?.multipleDuration}
- /* TODO: Currently unused, evaluate it is needed-
- * Possible alternative approach is to have onDurationChange.
- */
- duration={getMultipleDurationValue(
- eventData.metadata?.multipleDuration,
- searchParams?.get("duration"),
- eventData.length
- )}
- orgBannerUrl={orgBannerUrl}
- teamMemberEmail={teamMemberEmail}
- crmOwnerRecordType={crmOwnerRecordType}
- crmAppSlug={crmAppSlug}
- />
- </main>
+ <BookingPageErrorBoundary>
+ <main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
+ <Booker
+ username={user}
+ eventSlug={slug}
+ bookingData={booking}
+ isInstantMeeting={isInstantMeeting}
+ hideBranding={isBrandingHidden}
+ isTeamEvent
+ entity={{ ...eventData.entity, eventTypeId: eventData?.eventTypeId }}
+ durationConfig={eventData.metadata?.multipleDuration}
+ /* TODO: Currently unused, evaluate it is needed-
+ * Possible alternative approach is to have onDurationChange.
+ */
+ duration={getMultipleDurationValue(
+ eventData.metadata?.multipleDuration,
+ searchParams?.get("duration"),
+ eventData.length
+ )}
+ orgBannerUrl={orgBannerUrl}
+ teamMemberEmail={teamMemberEmail}
+ crmOwnerRecordType={crmOwnerRecordType}
+ crmAppSlug={crmAppSlug}
+ />
+ </main>
+ </BookingPageErrorBoundary>
);
}
diff --git a/apps/web/modules/users/views/users-type-public-view.tsx b/apps/web/modules/users/views/users-type-public-view.tsx
index a5f6a3ce135..7104580858c 100644
--- a/apps/web/modules/users/views/users-type-public-view.tsx
+++ b/apps/web/modules/users/views/users-type-public-view.tsx
@@ -8,6 +8,8 @@ import { getBookerWrapperClasses } from "@calcom/features/bookings/Booker/utils/
import type { inferSSRProps } from "@lib/types/inferSSRProps";
+import BookingPageErrorBoundary from "@components/error/BookingPageErrorBoundary";
+
import type { getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps";
export type PageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
@@ -26,25 +28,27 @@ function Type({ slug, user, isEmbed, booking, isBrandingHidden, eventData, orgBa
const searchParams = useSearchParams();
return (
- <main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
- <Booker
- username={user}
- eventSlug={slug}
- bookingData={booking}
- hideBranding={isBrandingHidden}
- entity={{ ...eventData.entity, eventTypeId: eventData?.id }}
- durationConfig={eventData.metadata?.multipleDuration}
- orgBannerUrl={orgBannerUrl}
- /* TODO: Currently unused, evaluate it is needed-
- * Possible alternative approach is to have onDurationChange.
- */
- duration={getMultipleDurationValue(
- eventData.metadata?.multipleDuration,
- searchParams?.get("duration"),
- eventData.length
- )}
- />
- </main>
+ <BookingPageErrorBoundary>
+ <main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
+ <Booker
+ username={user}
+ eventSlug={slug}
+ bookingData={booking}
+ hideBranding={isBrandingHidden}
+ entity={{ ...eventData.entity, eventTypeId: eventData?.id }}
+ durationConfig={eventData.metadata?.multipleDuration}
+ orgBannerUrl={orgBannerUrl}
+ /* TODO: Currently unused, evaluate it is needed-
+ * Possible alternative approach is to have onDurationChange.
+ */
+ duration={getMultipleDurationValue(
+ eventData.metadata?.multipleDuration,
+ searchParams?.get("duration"),
+ eventData.length
+ )}
+ />
+ </main>
+ </BookingPageErrorBoundary>
);
}