samzilverberg/cordova-mixpanel-plugin

Callbacks on init are never called for browser

Opened this issue · 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

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

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 :/

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?