Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
Fix PostHog initialization when already loaded
Sushmithamallesha2bdc64da1f4
diff --git a/fumadocs/components/posthog-provider.tsx b/fumadocs/components/posthog-provider.tsxindex 47eb581bf..1ca956cfc 100644--- a/fumadocs/components/posthog-provider.tsx+++ b/fumadocs/components/posthog-provider.tsx@@ -9,14 +9,20 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {const [isInitialized, setIsInitialized] = useState(false);useEffect(() => {- if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_POSTHOG_KEY && !posthog.__loaded) {+ if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_POSTHOG_KEY) {+ // Already loaded (e.g., HMR, StrictMode remount)+ if (posthog.__loaded) {+ setIsInitialized(true);+ return;+ }+posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {api_host:process.env.NEXT_PUBLIC_POSTHOG_HOST || 'https://us.i.posthog.com',person_profiles: 'identified_only',capture_pageview: false, // We capture manually belowcapture_pageleave: true,- loaded: (posthog) => {+ loaded: () => {setIsInitialized(true);},});