Smartech

Configuring Analytics via Firebase

Step 1: Create new Class

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

#import <SmartechNudges/Hansel-umbrella.h>

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

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
[FIRAnalytics logEventWithName:eventName parameters:properties];

//it would get updated to
[AppFirebase logEventWithName:eventName parameters:properties];
//If the original code was
Analytics.logEvent(eventName, parameters: properties)

//it would get updated to
AppFirebase.log(eventName, parameters: properties)

Updated 6 months ago


Next

Continue setting up Product experience

Product Experience

Configuring Analytics via Firebase


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.