Solved

Mixpanel people.set not working in production?

  • 27 August 2020
  • 8 replies
  • 180 views

Badge
  • Frequent Contributor
  • 6 replies


Hello,

I’ve implemented Mixpanel locally and it works on my machine as well as another developers machine locally, however after launching to production we’re getting the error above. We’re using the client-side Mixpanel SDK and installed it with the npm mixpanel-browser package.

Events are all firing to the “Live View” fine and user’s are being identified locally perfect, but as mentioned in production it fails.

Any advice?

Thanks!

icon

Best answer by jcq 28 August 2020, 21:40

Thread can be closed/deleted, my build process had an error with Laravel mix and was failing to correctly build our ENV keys which is where I had the token so it worked locally but not remotely.

Thanks!

View original

8 replies

Userlevel 2
Badge +1

Hello,

Can you share more context over your project? Is it react, gatsbyjs, vuejs ?

Badge

Hey @robin ,

It’s a Vue project but the implementation is framework agnostic, as we’re only including the transpiled JS from the mixpanel-browser lib. I didn’t include more code as the error is just saying the actual Mixpanel library .people.set() can’t be called on undefined.

Just curious if you or anyone knows what could be causing the mixpanel library to not have .people defined? We have the correct token in as well and everything fires locally into Mixpanel.

This is the code being called and it’s solely a wrapper:
 

 

Userlevel 2
Badge +1

I’m not familiar with vue.js

I managed to install mixpanel on a react project. 

Can you execute another mixpanel tracking at the same line? May be your mixpanel is not ready when you are calling your code?

If you are in a hurry, you could use the HTTP endpoint to solve this issue. Not the best way, I agree.

Badge

The framework shouldn’t matter, it’s just the Mixpanel method call that is failing even though it works locally. Just curious if anyone knows what could cause the actual underlying Mixpanel library to be undefined after going into prod.

The only thing I can think of is that the mixpanel token is incorrect but even when I add a fake token locally, it doesn’t fail like that it just doesn’t send the events properly.

Badge

Posting screenshots of the flow where it breaks, if anyone sees any issue with this please let me I’d very much appreciate it. Reminder that all of this works/tracks/fires perfectly on my local, it’s not until production that this fails and our build process passes.
 

Library import in .js file ^


 

method calling imported mixpanel variable ^


 

Call failing in Chrome console
Chrome error showing it’s the Mixpanel call specifically failing^

`l.a.people.set({..}) is mixpanel but just webpack transpiled

 

The actual boot call

 

Badge

+1 bump for any help, pretty urgent as this broke our production instance for 5 minutes live. Any help appreciated!

Badge

Thread can be closed/deleted, my build process had an error with Laravel mix and was failing to correctly build our ENV keys which is where I had the token so it worked locally but not remotely.

Thanks!

Userlevel 5
Badge +3

@jcq — thank you so much for closing the loop on this! It’s really helpful to know where your error came from, so if anyone finds themself in a similar situation in the future it can point them in the right direction. So thanks for sharing!

Reply