mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 20:35:24 +00:00
wrap posthog provider in suspense to fix build error
This commit is contained in:
parent
72da582145
commit
04f6772d3b
1 changed files with 8 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ import { PostHogProvider as PHProvider } from 'posthog-js/react'
|
|||
import { resolveServerPath } from './api/(client)/client'
|
||||
import { isDefined } from '@/lib/utils'
|
||||
import { usePathname, useSearchParams } from "next/navigation"
|
||||
import { useEffect } from "react"
|
||||
import { useEffect, Suspense } from "react"
|
||||
|
||||
const POSTHOG_ENABLED = isDefined(NEXT_PUBLIC_POSTHOG_PAPIK) && !NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED;
|
||||
|
||||
|
|
@ -30,6 +30,12 @@ function PostHogPageView() {
|
|||
return null
|
||||
}
|
||||
|
||||
export default function SuspendedPostHogPageView() {
|
||||
return <Suspense fallback={null}>
|
||||
<PostHogPageView />
|
||||
</Suspense>
|
||||
}
|
||||
|
||||
export function PostHogProvider({ children }: { children: React.ReactNode }) {
|
||||
useEffect(() => {
|
||||
if (POSTHOG_ENABLED) {
|
||||
|
|
@ -64,7 +70,7 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
|
|||
|
||||
return (
|
||||
<PHProvider client={posthog}>
|
||||
<PostHogPageView />
|
||||
<SuspendedPostHogPageView />
|
||||
{children}
|
||||
</PHProvider>
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue