cordova-mixpanel-plugin icon indicating copy to clipboard operation
cordova-mixpanel-plugin copied to clipboard

Callbacks on init are never called for browser

Open cyrilgandon opened this issue 5 years ago • 3 comments

If we look at the definition in .d.ts of init function:

init(token: string, onSuccess: () => void, onFail: (errors: string) => void): void;

It is misleading, because the actual code just ignore those params:

  mixpanel.init = function(token, onSuccess, onFail) {
    var r = mixpanel.original_init(token, {
      'loaded': function() {
        setTimeout(on_mixpanel_loaded, 10); // Let the original_init function be executed after lib loaded
      }
    });
  }

https://github.com/samzilverberg/cordova-mixpanel-plugin/blob/master/src/browser/MixpanelProxy.js#L253

cyrilgandon avatar Jul 09 '19 15:07 cyrilgandon

nice find 👍 , could you also create a PR fixing this?

samzilverberg avatar Jul 18 '19 10:07 samzilverberg

Well, I have look at the history of this plugin, and while both android & ios part are well maintained, the browser part is not. More than a PR to add callback, I think this needs a serious rework to full integrate the last mixpanel js sdk into this project. For example, some function, like clear are not supported in this plugin for browser, while they have been implemented in the mixpanel js sdk.

I am not sure I have the time though :/

cyrilgandon avatar Jul 18 '19 11:07 cyrilgandon

i took another look at the JS lib code. i dont see that they offer any indication that mixpanel.init has failed, and only let pass in some 'loaded' callback fn. am i missing something?

samzilverberg avatar Aug 01 '19 11:08 samzilverberg