Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixpanel with Cordova attempts to load mixpanel-2-latest.min.js from filesystem #48

Open
tlhunter opened this issue Aug 19, 2015 · 4 comments

Comments

@tlhunter
Copy link

If one includes mixpanel.js in their Cordova application, messages won't get logged. The problem comes with the script tag that is generated and inserted into the DOM:

//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js

By default it matches the same protocol the document is loaded under, which in Cordova on Android, is file://. The filesystem lookup for file://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js of course ends up failing.

One possible solution would be to always use https://. If there's a clean way to merge the mixpanel.js and mixpanel-2-latest.min.js files into one (or even do it as a build step and provide the file in the mixpanel-js repo) and ship that, it would be preferred.

@tdumitrescu
Copy link
Member

Thanks for writing in. I think you should already have everything you need here:

If you need more info on loading the lib from 'non-standard' locations, take a look at the Bower section in https://github.com/mixpanel/mixpanel-js/blob/master/README.md which details some variables we offer for overriding default lib locations.

Also happy to help dig into your specific case via email at support@mixpanel.com.

Does this help?

@tlhunter
Copy link
Author

Aah, my bad, I was actually referring to the little bootloader snippet when I said mixpanel.js. The latest version you've linked to doesn't appear to have that issue (I can see the file: check).

I'll check out the Bower section, looks like that'll answer the second part.

Related question: If I ship a snapshot of the Mixpanel JS, will it be future proof, or will it eventually become incompatible with the Mixpanel API?

@franciscolourenco
Copy link

This is also broken with chrome:// on chrome extension pages.
Why not fetch the library always using https? That way you wouldn't need to handle all these special cases. Wouldn't that be more secure as well? Is there anything to be gained by sometimes fetching the lib using http?

Thanks!

@jfbloom22
Copy link

I believe this issue can be closed. I should mention that the readme now has a section titled: Using Bower to load the entire library which explains how to load Mixpanel without the CDN. This will allow it to pass the CSP for Chrome:extensions.
Side note: the instructions are slightly wrong. mixpanel.js does not exist. It should be mixpanel.min.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants