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

TypeScript Error: Property 'track_pageview' does not exist on type 'OverridedMixpanel'. - v2.47.0

Open beforeoafterm opened this issue 2 years ago • 7 comments

Hi, all!

I'm currently using React (^18.1.0) with TypeScript (^5.0.4) and mixpanel-browser (^2.47.0).

Using the new track_pageview() method in the latest release, however, I am encountering this TS error:

Property 'track_pageview' does not exist on type 'OverridedMixpanel'.
Screenshot 2023-05-31 at 1 11 30 PM

When I checked mixpanel/index.d.ts, it looks like the Mixpanel interface does not have the method signature defined for track_pageview().

Screenshot 2023-05-31 at 1 14 42 PM

I believe we can fix this issue for TS users by adding the method signature:

track_pageview(properties?: Dict): void

beforeoafterm avatar May 31 '23 05:05 beforeoafterm

It looks like these are types from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/mixpanel-browser/index.d.ts. That repo would probably be the right place to submit updates.

tdumitrescu avatar May 31 '23 14:05 tdumitrescu

Same issue

khanhtn91 avatar Jun 02 '23 04:06 khanhtn91

Opened a new discussion on the DefinitelyTyped repo for this here: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65666

beforeoafterm avatar Jun 02 '23 09:06 beforeoafterm

Same problem. I need a solution to track page view in browser...

cotarelorodrigo avatar Jun 27 '23 17:06 cotarelorodrigo

Looks like this was already merged? https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65672

tdumitrescu avatar Jun 27 '23 18:06 tdumitrescu

But mixpanel needs to update mixpanel-browser version?

Looks like this was already merged? DefinitelyTyped/DefinitelyTyped#65672

cotarelorodrigo avatar Jun 28 '23 15:06 cotarelorodrigo

But mixpanel needs to update mixpanel-browser version?

If the new types haven't been published yet, I'd guess that's something to take up with https://github.com/DefinitelyTyped/DefinitelyTyped

tdumitrescu avatar Jun 28 '23 15:06 tdumitrescu

Same problem - this is over a year old now? What happened?

Aah wait I was doing this browser-side and instead of:

import mixpanel from "mixpanel";

I needed to do:

import mixpanel from "mixpanel-browser";

(and also add the types via npm install @types/mixpanel-browser

markalroberts avatar Oct 21 '24 12:10 markalroberts

It still has a problem in 2.63.0 if import like import mixpanel from 'mixpanel-browser/src/loaders/loader-module-core' to reduce bundle size

koooge avatar Apr 30 '25 09:04 koooge