From 287528acff64057e679d23a9f67751fb2cae9157 Mon Sep 17 00:00:00 2001 From: Matteo Boschi Date: Mon, 14 Jun 2021 16:23:29 +0200 Subject: [PATCH] Update mixpanel setup (#3138) * update mixpanel config - Android * invoke iOS setup * fix --- android/app/src/main/AndroidManifest.xml | 8 ++++++++ ts/mixpanel.ts | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b4625f6756d..6b3852984eb 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -42,6 +42,7 @@ + @@ -72,6 +73,11 @@ + + + + + + diff --git a/ts/mixpanel.ts b/ts/mixpanel.ts index 0483453ead6..8e6d144b9f0 100644 --- a/ts/mixpanel.ts +++ b/ts/mixpanel.ts @@ -1,9 +1,10 @@ import DeviceInfo from "react-native-device-info"; import { MixpanelInstance } from "react-native-mixpanel"; -import { Appearance, Platform } from "react-native"; +import { Appearance } from "react-native"; import { mixpanelToken } from "./config"; import { isScreenReaderEnabled } from "./utils/accessibility"; import { getAppVersion } from "./utils/appVersion"; +import { isAndroid, isIos } from "./utils/platform"; // eslint-disable-next-line export let mixpanel: MixpanelInstance | undefined; @@ -24,7 +25,12 @@ initializeMixPanel() const setupMixpanel = async (mp: MixpanelInstance) => { const screenReaderEnabled: boolean = await isScreenReaderEnabled(); - await mp.disableIpAddressGeolocalization(); + // on iOS it can be deactivate by invoking a SDK method + // on Android it can be done adding an extra config in AndroidManifest + // see https://help.mixpanel.com/hc/en-us/articles/115004494803-Disable-Geolocation-Collection + if (isIos) { + await mp.disableIpAddressGeolocalization(); + } await mp.registerSuperProperties({ isScreenReaderEnabled: screenReaderEnabled, fontScale: DeviceInfo.getFontScaleSync(), @@ -38,10 +44,10 @@ const setupMixpanel = async (mp: MixpanelInstance) => { export const setMixpanelPushNotificationToken = (token: string) => { if (mixpanel) { - if (Platform.OS === "ios") { + if (isIos) { return mixpanel.addPushDeviceToken(token); } - if (Platform.OS === "android") { + if (isAndroid) { return mixpanel.setPushRegistrationId(token); } }