mixpanel / mixpanel-react-native

Official React Native Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
108 stars 48 forks source link

How to set serverUrl? #211

Closed BamMironov closed 9 months ago

BamMironov commented 1 year ago

According to the docs there should be a way to assign a server URL. For instance, if we have users from the EU we have to set a different URL in order to be GDRP compliant.

As of now, mixpanel-react-native@2.3.1 seems to miss this feature. If I am not mistaken, there was a way to do that through the init method that accepted the serverUrl parameter but now there is no such method. There is the initialize method but it doesn't accept any parameters.

image

So how can I set serverURl?

catliaw commented 1 year ago

Hi @BamMironov, according to the documentation, you would need to init() the SDK first. Then you run mixpanel.setServerURL("https://api-eu.mixpanel.com"); to change the server URL to EU. I do not see a way where you can init the SDK with the EU server URL as a param in the init() code. Looking at the git-blame, I can see that this method for changing server URL has existed for 3 years: https://github.com/mixpanel/mixpanel-react-native/blame/f91b9a12f213c410c1e1cfec41835c70d9d605bf/ios/MixpanelReactNative.swift#L33

By chance were you using or looking at a different SDK? I know that the JS SDK accepts the EU server URL as a init() param. Different SDKs set it differently.

Also please note that a single Mixpanel project exists in only one region (US or EU). If your project is based in the US region (no eu.mixpanel.com in your logged-in project URL), you would need to create a separate project in EU region (can select this in the project creation modal). Then you would also need to update the project token to that of the EU residency project when you detect an EU user. It might make sense to make your entire Mixpanel project EU based if you want to analyze EU and non-EU users together in the same project.