Skip to content

Commit 04f6772

Browse files
committed
wrap posthog provider in suspense to fix build error
1 parent 72da582 commit 04f6772

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/web/src/app/posthogProvider.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { PostHogProvider as PHProvider } from 'posthog-js/react'
66
import { resolveServerPath } from './api/(client)/client'
77
import { isDefined } from '@/lib/utils'
88
import { usePathname, useSearchParams } from "next/navigation"
9-
import { useEffect } from "react"
9+
import { useEffect, Suspense } from "react"
1010

1111
const POSTHOG_ENABLED = isDefined(NEXT_PUBLIC_POSTHOG_PAPIK) && !NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED;
1212

@@ -30,6 +30,12 @@ function PostHogPageView() {
3030
return null
3131
}
3232

33+
export default function SuspendedPostHogPageView() {
34+
return <Suspense fallback={null}>
35+
<PostHogPageView />
36+
</Suspense>
37+
}
38+
3339
export function PostHogProvider({ children }: { children: React.ReactNode }) {
3440
useEffect(() => {
3541
if (POSTHOG_ENABLED) {
@@ -64,7 +70,7 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
6470

6571
return (
6672
<PHProvider client={posthog}>
67-
<PostHogPageView />
73+
<SuspendedPostHogPageView />
6874
{children}
6975
</PHProvider>
7076
)

0 commit comments

Comments
 (0)