Configuring Analytics via Clevertap

Step 1: Base code

Use the below code to get started

public static void push(CleverTapAPI clevertapAPI, String eventName, HashMap<String, Object> properties) {
        //Please pass the string "ctp" for vendor if you are using Clevertap to track the event.
        HashMap<String, Object> hanselData = HanselTracker.logEvent(eventName, "ctp", properties);
        if (properties == null) {
            properties = new HashMap<>();
        }
        properties.putAll(hanselData);

        clevertapAPI.event.push(eventName, properties);
    }
fun push(clevertapAPI: CleverTapAPI, eventName: String, properties: HashMap<String, Any>?) {
        var properties = properties
        //Please pass the string "ctp" for vendor if you are using Clevertap to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "ctp", properties)
        if (properties == null) {
            properties = HashMap()
        }
        properties.putAll(hanselData)

        clevertapAPI.event.push(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppCleverTap = (function () {
  function logEvent(eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"ctp",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
        CleverTap.recordEvent(eventName, mergedProperties);
    });
  }
})();

Step 2: Update the code as shown below

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
CleverTapAPI.getInstance(context).event.push(eventName, properties);

//it would get updated to
AppCleverTap.push(CleverTapAPI.getInstance(context), eventName, properties);
//If the original code was
CleverTapAPI.getInstance(context).event.push(eventName, properties)

//it would get updated to
AppCleverTap.push(CleverTapAPI.getInstance(context), eventName, properties)
//If the original code was
CleverTap.recordEvent(eventName, properties);

//it would get updated to
AppCleverTap.logEvent(eventName, properties);