Configuring Analytics via Localytics
Step 1: Create new Class
Create a new class "AppLocalytics" and add the following method to it.
public static void tagEvent(String eventName, HashMap<String, Object> properties) {
//Please pass the string "loca" for vendor if you are using Localytics to track the event.
HashMap<String, Object> hanselData = HanselTracker.logEvent(eventName, "loca", properties);
if (properties == null) {
properties = new HashMap<>();
}
properties.putAll(hanselData);
Localytics.tagEvent(eventName, properties);
}
fun tagEvent(eventName: String, properties: HashMap<String, Any>?) {
var properties = properties
//Please pass the string "loca" for vendor if you are using Localytics to track the event.
val hanselData = HanselTracker.logEvent(eventName, "loca", properties)
if (properties == null) {
properties = HashMap()
}
properties.putAll(hanselData)
Localytics.tagEvent(eventName, properties)
}
import {NativeModules} from 'react-native';
var AppLocalytics = (function () {
function tagEvent(localyticsClient, eventName, properties) {
var mergedProperties = {};
NativeModules.HanselTrackerRn.logEvent(eventName,"loca",properties,(hanselData) => {
if(!properties) {properties = {};}
mergedProperties = Object.assign(properties, hanselData);
localyticsClient.tagEvent(eventName, mergedProperties);
});
}
})();
Step 2: Tracking Hansel changes
For all those events on which you want to track the impact of Hansel changes, make the updates as suggested in the snippet below:
//If the original code was
Localytics.tagEvent(eventName, properties)
//it would get updated to
AppLocalytics.tagEvent(eventName, properties);
//If the original code was
Localytics.tagEvent(eventName, properties)
//it would get updated to
AppLocalytics.tagEvent(eventName, properties);
//If the original code was
localyticsClient.tagEvent(eventName, properties)
//it would get updated to
AppLocalytics.tagEvent(localyticsClient, eventName, properties);
Updated 6 months ago