posthogjs 1.151.0 - Type error: Type 'PostHog' is missing the following properties from type 'PostHog': requestRouter, _send_retriable_request
Just upgraded to 1.151.0 and started getting this error when building my next 14.2.5 app.
./app/PostHogProvider.tsx:15:27
Type error: Type 'PostHog' is missing the following properties from type 'PostHog': __captureHooks, __autocapture, elementsChainAsString, segmentIntegration, and 4 more.
13 |
14 | export function PHProvider({ children }: { children: React.ReactNode }) {
> 15 | return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
| ^
16 | }
17 |
▲ Next.js 14.2.5
Downgraded back to 1.103.1 and the error went away.
Hey - any other details you can give? I just checked with our nextjs app (that is in this repo) and it all builds fine on the latest version.
Can you share a snippet of how posthog is imported / initialized?
Yep, our ./app/PostHogProvider.tsx looks like this:
'use client';
import posthog from 'posthog-js';
import { PostHogProvider } from 'posthog-js/react';
if (typeof window !== 'undefined') {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY as string, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
capture_pageview: false, // Disable automatic pageview capture, as we capture manually in <PosthHogPageView>
autocapture: false,
});
}
export function PHProvider({ children }: { children: React.ReactNode }) {
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
}
Hey, @DavidMelnychuk! Are you still seeing this on the most recent version? v1.200.1+. There's also some improved documentation on how you should run Posthog inside NextJS in our documentation
No, haven't seen this in a while, can close this issue. Thanks!