Remove intercom from public booking pages (#1835)
* Remove intercom from public pages * remove from success and cancel pages as well * remove from Reschedule page as well * Fix comment Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>pull/1807/head^2
parent
228dea1308
commit
34c5360a4d
|
@ -6,6 +6,7 @@ import React, { ComponentProps, ReactNode } from "react";
|
|||
|
||||
import DynamicIntercomProvider from "@ee/lib/intercom/providerDynamic";
|
||||
|
||||
import usePublicPage from "@lib/hooks/usePublicPage";
|
||||
import { createTelemetryClient, TelemetryProvider } from "@lib/telemetry";
|
||||
|
||||
import { trpc } from "./trpc";
|
||||
|
@ -40,14 +41,22 @@ const CustomI18nextProvider = (props: AppPropsWithChildren) => {
|
|||
|
||||
const AppProviders = (props: AppPropsWithChildren) => {
|
||||
const session = trpc.useQuery(["viewer.session"]).data;
|
||||
// No need to have intercom on public pages - Good for Page Performance
|
||||
const isPublicPage = usePublicPage();
|
||||
const RemainingProviders = (
|
||||
<SessionProvider session={session || undefined}>
|
||||
<CustomI18nextProvider {...props}>{props.children}</CustomI18nextProvider>
|
||||
</SessionProvider>
|
||||
);
|
||||
|
||||
return (
|
||||
<TelemetryProvider value={createTelemetryClient()}>
|
||||
<IdProvider>
|
||||
<DynamicIntercomProvider>
|
||||
<SessionProvider session={session || undefined}>
|
||||
<CustomI18nextProvider {...props}>{props.children}</CustomI18nextProvider>
|
||||
</SessionProvider>
|
||||
</DynamicIntercomProvider>
|
||||
{isPublicPage ? (
|
||||
RemainingProviders
|
||||
) : (
|
||||
<DynamicIntercomProvider>{RemainingProviders}</DynamicIntercomProvider>
|
||||
)}
|
||||
</IdProvider>
|
||||
</TelemetryProvider>
|
||||
);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import { useRouter } from "next/router";
|
||||
|
||||
export default function usePublicPage() {
|
||||
const router = useRouter();
|
||||
const isPublicPage = ["/[user]", "/success", "/cancel", "/reschedule"].find((route) =>
|
||||
router.pathname.startsWith(route)
|
||||
);
|
||||
return isPublicPage;
|
||||
}
|
Loading…
Reference in New Issue