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

Set serverURL param (for EU Data Residency) #121

Open
chvonrohr opened this issue Apr 28, 2021 · 8 comments
Open

Set serverURL param (for EU Data Residency) #121

chvonrohr opened this issue Apr 28, 2021 · 8 comments

Comments

@chvonrohr
Copy link

chvonrohr commented Apr 28, 2021

Is it somehow possible to set the server URL as configuration of this plugin?

Mixpanel explains it in the Objective-C documentation like this:

[Mixpanel sharedInstanceWithToken:@"xxx"];
self.mixpanel.serverURL = @"https://api-eu.mixpanel.com";

See here: https://developer.mixpanel.com/docs/ios#eu-data-residency

For Android, I should be able to do it with AndroidManifest.xml adjustments:
https://developer.mixpanel.com/docs/android#eu-data-residency

@samzilverberg
Copy link
Owner

This sounds nice but I don't have the time to try it out myself atm.
I spent 5-10 mins to read a little and write down some pointers in case you want to try it out on your own (and possibly contribute it back :) ).

cordova plugins can use some user input variables, documented here:
https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#preference

you can add another variable for your server URL in the same way and then adjust android manifest file using one of the following:

this plugin has an example for FIREBASE_VERSION you can look up.

for ios it looks more tricky because this url needs to be set in-code (not in config like android) on the mixpanel instance after its initialized.
so maybe some specific function needs to be created for this in src/www/mixpanel.js and in src/ios/MixpanelPlugin.h (and .m).

@chvonrohr
Copy link
Author

🙏 for your investigation . I'll give it a shot 👍

@klemensz
Copy link

Have you found a solution how to do it on iOS?

@chvonrohr
Copy link
Author

@klemensz We moved away from this plugin, as the Mixpanel SDK is not updated and it's also not possible to override the IOS version, since the IOS SDK is packed in the code instead of installing it as a Cocoa pod. There were some major changes in the SDK so I would highly recommend to update.

Nevertheless, it's fairly easy to implement this and we did for the plugin we use now (see merge request: https://github.com/houseninjadojo/capacitor-mixpanel/pull/8/files). The plugin is for Ionic Capacitor and not Cordova, though.
So passing the serverUrl to init and adjust that function to set it on initialisation would be enough. Also cleaner for Android.

@klemensz
Copy link

klemensz commented May 1, 2022

@chvonrohr Thanks, I need the plugin for Capacitor anyway. So you suggest it's better to use https://github.com/houseninjadojo/capacitor-mixpanel instead?

The features I need are:

  • .track()
  • .identify()
  • .reset()
  • setting serverUrl (for EU) - the MR you linked is still open?

@chvonrohr
Copy link
Author

I prefer Capacitor plugins, as they are bit more lightweight and additionally support PWA (what we don't need at the moment, but you never know ;))

Your needs are covered, as you wrote except the serverUrl. We hope our PR is merged soon, otherwise we propose this fork for the @capacitor/community and maintain it our selfs

@klemensz
Copy link

klemensz commented May 2, 2022

I don't think that you will get PWA support with Capacitor plugins because they usually only support Android and iOS platforms. Some Cordova plugins support a "browser" platform but this has become obsolete (with newer versions of Ionic and Cordova). I know it because we build for all three platforms (web/PWA, Android, iOS). The route that I went for PWA is to additionally include the mixpanel-browser library and then have platform checks in the code to either call the native or browser plugin.

@chvonrohr
Copy link
Author

chvonrohr commented May 2, 2022

The good thing on capacitor is that it supports Android, IOS and PWAs.
And this plugin has the mixpanel-browser library already included and implemented (see also package.json), so it works the same way as you use it on IOS and Android

BTW: just tested and works. only difference for browser is, that you need to do Mixpanel.initialize

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

3 participants