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

Support lazy loading module

Open monkeycatdog opened this issue 4 years ago • 1 comments

Hi there.

I just tried use lazy loading with this lib and got an issue. Screenshot 2021-11-16 at 17 14 41

(async () => {
const mixpanel = await import('mixpanel-browser');
this.mixpanel.init(TOKEN, {debug: true})
this.mixpanel.identify(ID) <--- exception here. 
})();

monkeycatdog avatar Nov 16 '21 14:11 monkeycatdog

Seems like the problem was in the init function.

(async() => {
const module = await import('mixpanel-browser');

const mixpanel = module.init(TOKEN, {debug: true}, 'test'); <-- name is important 

})()

monkeycatdog avatar Nov 16 '21 14:11 monkeycatdog