setting up mixpanel in our app:
import { Mixpanel, MixpanelProperties } from "mixpanel-react-native";
const useNative = false; // disable Native Mode because we're using RN + expo, instead use Javascript Mode
export const createAnalyticsClient = (
token: string,
trackAutomaticEvents = true,
persistentEventProperties: MixpanelProperties = {},
) => {
const superProperties: MixpanelProperties = {
application_id: applicationId,
application_name: applicationName,
app_version: nativeApplicationVersion,
build_version: __DEV__ ? "dev" : nativeBuildVersion,
device_name: deviceName,
device_type: deviceType ? DeviceType[deviceType] : undefined,
device_year_class: deviceYearClass,
is_simulator: !isDevice,
model_name: modelName,
model_id: modelId,
...persistentEventProperties,
};
const mixpanel = new Mixpanel(token, trackAutomaticEvents, useNative);
mixpanel.init(undefined, superProperties, "https://api-eu.mixpanel.com");
return mixpanel;
};package versions:
"mixpanel-react-native": "^3.1.2", "@react-native-async-storage/async-storage": "^1.24.0",