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

In IE9, the library fails with a `mixpanel is not defined` error when mixpanel is not a global object

Open johanneslumpe opened this issue 8 years ago • 5 comments

Interestingly this only happens in IE9, but not 10 or any other browser. Adding mixpanel to the window object solves it, but that seems like a rather dirty workaround. Any advice here? The issue seems to be a response from the mixpanel api which includes a piece of code like mixpanel._jsx[123123]....

johanneslumpe avatar Mar 18 '16 23:03 johanneslumpe

Thanks for the report - surprised our browser matrix testing hasn't caught this. I presume you're using a module-based build (webpack, browserify, etc) rather than the async embed code? Either way, I'm afraid that any browser which needs JSONP instead of XHR for getting HTTP responses will need a global mixpanel object - so our patch will probably involve ensuring that mixpanel is available on window whenever USE_XHR is false (i.e. it will only be exposed for older browsers). Does that seem acceptable?

tdumitrescu avatar Mar 21 '16 16:03 tdumitrescu

@tdumitrescu Yep we're using the module-based build. Luckily we today decided to drop IE9 support so for me personally it's not an issue anymore, but I do think that ensuring that mixpanel is available on the global object is a good workaround. And since it only needs to be exposed for really old browsers it shouldn't be an issue at all for modern browsers :+1:

johanneslumpe avatar Mar 21 '16 19:03 johanneslumpe

Same issue here, it happens when the sendEvent call is used with a callback in IE9

mteodori avatar May 04 '16 13:05 mteodori

Same issue here

jonashaag avatar Feb 24 '17 13:02 jonashaag

Yep, I confirm I also have this issue.

resurtm avatar Feb 06 '18 08:02 resurtm