Closed luisfuertes closed 4 years ago
Ok in server side it solved adding api_host:
mixpanel.init("YOUR_TOKEN", { "api_host": "https://api-eu.mixpanel.com" }, "");
But how can i set api_host with react-native-mixpanel?
Ok, in android i had to add this to the manifest and it works
<meta-data android:name="com.mixpanel.android.MPConfig.EventsEndpoint"
android:value="https://api-eu.mixpanel.com/track" />
<meta-data android:name="com.mixpanel.android.MPConfig.PeopleEndpoint"
android:value="https://api-eu.mixpanel.com/engage" />
<meta-data android:name="com.mixpanel.android.MPConfig.GroupsEndpoint"
android:value="https://api-eu.mixpanel.com/groups" />
And on iOS y try to send url with launchOptions but it doesnt work.
Mixpanel.sharedInstanceWithToken(MIXPANEL_TOKEN, false, false, false, { serverURL: 'https://api-eu.mixpanel.com' })
Any idea how can i fix it on iOS? Docs in Objective-c says this:
self.mixpanel = [Mixpanel sharedInstanceWithToken:@"MIXPANEL_TOKEN" launchOptions:launchOptions];
self.mixpanel.serverURL = @"https://api-eu.mixpanel.com";
But i dont know how can i add that.
PD: This isnt work
Mixpanel.serverURL = 'https://api-eu.mixpanel.com'
I tried your fix for Android, but it is still not working for me.
@tibbus Your mixpanel server url is in EU?
Yes, I got from the panel: https://api-eu.mixpanel.com
meta-data are inside "application" in mannifest?
<application
android:name=".MainApplication"
...
android:theme="@style/AppTheme">
<meta-data android:name="com.mixpanel.android.MPConfig.EventsEndpoint"
android:value="https://api-eu.mixpanel.com/track" />
<meta-data android:name="com.mixpanel.android.MPConfig.PeopleEndpoint"
android:value="https://api-eu.mixpanel.com/engage" />
<meta-data android:name="com.mixpanel.android.MPConfig.GroupsEndpoint"
android:value="https://api-eu.mixpanel.com/groups" />
For iOS add instance.serverURL = @"https://api-eu.mixpanel.com";
in node_modules/react-native-mixpanel/RNMixpanel/RNMixpanel.m
and it works
// sharedInstanceWithToken
RCT_EXPORT_METHOD(sharedInstanceWithToken:(NSString *)apiToken
optOutTrackingByDefault:(BOOL)optOutTrackingByDefault
trackCrashes:(BOOL)trackCrashes
automaticPushTracking:(BOOL)automaticPushTracking
launchOptions:(nullable NSDictionary *)launchOptions
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject) {
@synchronized(self) {
if (instances != nil && [instances objectForKey:apiToken] != nil) {
resolve(nil);
return;
}
Mixpanel *instance = [Mixpanel sharedInstanceWithToken:apiToken
launchOptions:launchOptions
trackCrashes:trackCrashes
automaticPushTracking:automaticPushTracking
optOutTrackingByDefault:optOutTrackingByDefault];
instance.serverURL = @"https://api-eu.mixpanel.com";
// copy instances and add the new instance. then reassign instances
NSMutableDictionary *newInstances = [NSMutableDictionary dictionaryWithDictionary:instances];
[newInstances setObject:instance forKey:apiToken];
instances = [NSDictionary dictionaryWithDictionary:newInstances];
[instance applicationDidBecomeActive:nil];
resolve(nil);
}
}
I will try to submit a PR with serverURL as param, but I think there are no active collaborators
Another solution (more permanent, since you don't have to add every time you do an npm install) is to create an instance in our AppDelegate.m.
First add the import (before #if DEBUG
): #import "Mixpanel / Mixpanel.h"
and in didFinishLaunchingWithOptions:
Mixpanel *mixpanel = [Mixpanel sharedInstanceWithToken:@"MIXPANEL_TOKEN"];
mixpanel.serverURL = @"https://api-eu.mixpanel.com";
I have raised a small quickfix. Once/if this is merged README could be updated to surface this functionality. https://github.com/davodesign84/react-native-mixpanel/pull/253
Merged!
@davodesign84 readme updated: https://github.com/davodesign84/react-native-mixpanel/pull/254 Would that close this issue?
Yes thanks.
What version is this upgrade available in?
On the latest npm version 1.2.2
great thx
I have mixpanel configured without errors, but cant see my events or my users in Mixpanel dashboard.
To install i only write:
yarn add react-native-mixpanel
andnpx react-native run-android
My versions:
My App.js
When user register:
When load auth data:
Anybody return error, but in Mixpanel panel i cant see anything.
And is token, true? Not api key. To init app.
And in live preview:
It should show my "track" events in "Live view data" in dashborad, is correct? I cant see my data