Configuring Analytics via Mixpanel

Step 1: Create new Class

Create a new class "AppMixpanel" and add the following method to it.

#import <SmartechNudges/Hansel-umbrella.h>

+ (void) track: (NSString*) eventName properties: (id) properties instance: (Mixpanel*) mixpanel{
    //Check if this event is being tracked in any one of the active Hansel Interaction Maps.
  //Please pass the string "mxp" for vendor if you are using Mixpanel to track the event.
  //get the data for all Interaction Maps created on hansel dashboard.
    NSDictionary* hanselData = [HanselTracker logEvent:eventName andVendor:@"mxp" withProperties:properties];
    if (![properties isKindOfClass:[NSMutableDictionary class]]){
        properties = [properties mutableCopy];
    }
    [properties addEntriesFromDictionary:hanselData];
    [mixpanel track:eventName properties:properties];
}
class func track(_ eventName: String, properties: [AnyHashable : Any]?, mixpanel: Mixpanel?){
        var properties = properties
        //Check if this event is being tracked in any one of the active Hansel Interaction Maps.
        //Please pass the string "mxp" for vendor if you are using Mixpanel to track the event.
        //getting the data for all interaction maps on hansel dashboard
 				let hanselData = HanselTracker.logEvent(eventName, vendor: "mxp", withProperties: properties)
  			for (k, v) in hanselData { properties[k] = v }   
        mixpanel?.track(eventName, properties: properties)
    }

Step 2: Update Code

For all those events on which you want to track the impact of Hansel changes, make the updates as suggested in the snippet below:

#import <SmartechNudges/Hansel-umbrella.h>

//If the original code was
[mixpanel track:eventName properties:properties];
	    
//it would get updated to
[AppMixpanel track:eventName properties:properties instance:mixpanel];
//If the original code was
mixpanel?.track(eventName, properties: properties)

//it would get updated to
AppMixpanel.track(eventName, properties: properties, mixpanel: mixpanel)