posthog-js icon indicating copy to clipboard operation
posthog-js copied to clipboard

posthogjs 1.151.0 - Type error: Type 'PostHog' is missing the following properties from type 'PostHog': requestRouter, _send_retriable_request

Open williamlmao opened this issue 1 year ago • 2 comments

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.

williamlmao avatar Jul 31 '24 13:07 williamlmao

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?

benjackwhite avatar Jul 31 '24 13:07 benjackwhite

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>;
}

DavidMelnychuk avatar Jul 31 '24 17:07 DavidMelnychuk

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

rafaeelaudibert avatar Dec 16 '24 16:12 rafaeelaudibert

No, haven't seen this in a while, can close this issue. Thanks!

DavidMelnychuk avatar Dec 16 '24 17:12 DavidMelnychuk