Skip to content
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

Studio - only show intercom post-login #880

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { PropsWithChildren } from "react"
import { useMemo } from "react"
import { useRouter } from "next/router"
import Intercom from "@intercom/messenger-js-sdk"

import { env } from "~/env.mjs"
import { useLoginState } from "~/features/auth"
import { SIGN_IN } from "~/lib/routes"
import { callbackUrlSchema } from "~/schemas/url"
Expand Down Expand Up @@ -46,6 +48,13 @@ export const EnforceLoginStatePageWrapper = ({
const { hasLoginStateFlag } = useLoginState()

if (hasLoginStateFlag) {
// Initialize Intercom
if (env.NEXT_PUBLIC_INTERCOM_APP_ID) {
Intercom({
app_id: env.NEXT_PUBLIC_INTERCOM_APP_ID,
})
}

return <>{children}</>
}

Expand Down
7 changes: 0 additions & 7 deletions apps/studio/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Skeleton, Stack } from "@chakra-ui/react"
import { datadogRum } from "@datadog/browser-rum"
import { GrowthBook } from "@growthbook/growthbook"
import { GrowthBookProvider } from "@growthbook/growthbook-react"
import Intercom from "@intercom/messenger-js-sdk"
import { ThemeProvider } from "@opengovsg/design-system-react"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import { ErrorBoundary } from "react-error-boundary"
Expand Down Expand Up @@ -59,12 +58,6 @@ void gb.init({
})

const MyApp = ((props: AppPropsWithAuthAndLayout) => {
if (env.NEXT_PUBLIC_INTERCOM_APP_ID) {
Intercom({
app_id: env.NEXT_PUBLIC_INTERCOM_APP_ID,
})
}

return (
<EnvProvider env={env}>
<LoginStateProvider>
Expand Down
Loading