BuiltAnalytics Class Reference

Inherits from NSObject
Declared in BuiltAnalytics.h

Overview

Class for integrating BuiltAnalytics support for apps. Use BuiltAnalytics class to track an event to analyse the datapoints, the usecase and usage behaviour throughout the app.

// 'blt5d4sample2633b' is a dummy Application API key
BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
BuiltAnalytics *analytics = [builtApplication analytics];

// Set super properties that are to be sent with every event
NSDictionary *superProperties = @{@"company_name": @"raweng"};
[analytics registerSuperProperties:superProperties];

//Create event
BuiltEvent *loginEvent = [analytics eventWithUID:@"logged_in"];

//Track event
[loginEvent trigger];

Initializing

– eventWithUID:

Represents a analytics event in this application.

- (BuiltAnalyticsEvent *)eventWithUID:(NSString *)eventUID

Parameters

eventName

name of event

Return Value

Returns an instance of a BuiltAnalyticsEvent.

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltAnalytics *analytics = [builtApplication analytics];
 BuiltAnalyticsEvent *bugEvent = [analytics eventWithUID:@"create_bug"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics =  builtApplication.analytics()
 var bugEvent:BuiltAnalyticsEvent = analytics.eventWithUID("create_bug")

Declared In

BuiltAnalytics.h

Headers

– setHeader:forKey:

Set a header for an application

- (void)setHeader:(NSString *)headerValue forKey:(NSString *)headerKey

Parameters

headerValue

The header key

headerKey

The header value

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltAnalytics *analytics = [builtApplication analytics];
 [analytics setHeader:@"MyValue" forKey:@"My-Custom-Header"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics =  builtApplication.analytics()
 analytics.setHeader("MyValue", forKey:"My-Custom-Header")

Declared In

BuiltAnalytics.h

– addHeadersWithDictionary:

Set a header for an application

- (void)addHeadersWithDictionary:(NSDictionary *)headers

Parameters

headers

The headers as dictionary which needs to be added to the application

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltAnalytics *analytics = [builtApplication analytics];
 [analytics addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics =  builtApplication.analytics()
 analytics.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])

Declared In

BuiltAnalytics.h

– removeHeaderForKey:

Removes a header from this application.

- (void)removeHeaderForKey:(NSString *)headerKey

Parameters

headerKey

The header key that needs to be removed

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltAnalytics *analytics = [builtApplication analytics];
 [analytics removeHeaderForKey:@"My-Custom-Header"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics =  builtApplication.analytics()
 analytics.removeHeaderForKey("My-Custom-Header")

Declared In

BuiltAnalytics.h

Properties

  batchSize

  • Threshold batch size for event to flush. If set below 2 then event will be triggered immediately or else it will send when its greater than or equal to batch size.
@property (nonatomic, assign) NSInteger batchSize

Discussion

// 'blt5d4sample2633b' is a dummy Application API key

//Obj-C
BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
BuiltAnalytics *analytics = [builtApplication analytics];
analytics.batchSize = 10;
NSInteger batchSize = analytics.batchSize; //Read the batch size

//Swift
var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
var analytics:BuiltAnalytics =  builtApplication.analytics()
analytics.batchSize = 10
let batchSize:Integer = analytics.batchSize //Read the batch size

Declared In

BuiltAnalytics.h

  trackAnonymously

  • If FALSE then loggedin user id will be attached with the event for user base analytics if set TRUE user info is not been tracked by analytics. By default its FALSE. Value is inhereted from BuiltApplication’s trackAnonymously property when instance is created.
@property (nonatomic, assign, getter=isAnonymousTrackingEnabled) BOOL trackAnonymously

Discussion

// 'blt5d4sample2633b' is a dummy Application API key

//Obj-C
BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
BuiltAnalytics *analytics = [builtApplication analytics];
if ([analytics isAnonymousTrackingEnabled]) {
    analytics.trackAnonymously = YES;
} else {
    analytics.trackAnonymously = NO;
}

//Swift
var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
var analytics:BuiltAnalytics =  builtApplication.analytics()
if (analytics.isAnonymousTrackingEnabled) {
    // Anonymously tracking events
} else {
    // User based tracking
}

Declared In

BuiltAnalytics.h

Register super/dynamic properties

– registerSuperProperties:

Registers super properties, overwriting ones that have already been set.

- (void)registerSuperProperties:(NSDictionary *)superProperties

Parameters

superProperties

super properties dictionary

Discussion

Super properties, once registered, are automatically sent as properties for all event tracking calls. They save you having to maintain and add a common set of properties to your events. Property keys must be NSString objects and values must be NSString, NSNumber, NSNull, NSArray, NSDictionary, NSDate or NSURL objects.

//'blt5d4sample2633b' is a dummy Application API key

//Obj-C
BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
BuiltAnalytics *analytics = [builtApplication analytics];
[analytics registerSuperProperties:@{@"Custom_Key":@"Custom_Value"}];

//Swift
var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
var analytics:BuiltAnalytics =  builtApplication.analytics()
analytics.registerSuperProperties(["Custom_Key":"Custom_Value"])

Declared In

BuiltAnalytics.h

– registerDynamicPropertiesWithBlock:

Registers dynamic properties, this will be common properties when will set when event is about to trigger. Dynamic change properties i.e Wifi status etc can be terms as Dynamic properties.

- (void)registerDynamicPropertiesWithBlock:(NSDictionary *( ^ ) ( NSString *eventUID ))dynamicPropertyBlock

Parameters

dynamicPropertyBlock

block that will execute to register properties.

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltAnalytics *analytics = [builtApplication analytics];
 [analytics registerDynamicPropertiesWithBlock:^NSDictionary *(NSString *eventUID) {
    if([eventUID isEqualToString:@"home"]) {
        return @{@"Custom_Key":@"Custom_Value"};
    }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics =  builtApplication.analytics()
 analytics.registerDynamicPropertiesWithBlock { (eventUID) -> [NSObject : AnyObject]! in
    if([eventUID isEqualToString:@"home"]) {
        return ["Custom_Key":"Custom_Value"]
    }
 }

Property keys must be NSString objects and values must be NSString, NSNumber, NSNull, NSArray, NSDictionary, NSDate or NSURL objects.

Declared In

BuiltAnalytics.h

Trigger events

– triggerEventsFromArray:

Trigger multiple events

- (void)triggerEventsFromArray:(NSArray *)events

Parameters

events

multiple event object, terminated by nil.

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltAnalytics *analytics = [builtApplication analytics];
 BuiltAnalyticsEvent *eventBug1 = [analytics eventWithUID:@"create_bug1"];
 BuiltAnalyticsEvent *eventBug2 = [analytics eventWithUID:@"create_bug2"];
 [analytics triggerEventsFromArray:@[eventBug1, eventBug2]];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics =  builtApplication.analytics()
 var eventBug1:BuiltAnalyticsEvent = analytics.eventWithUID("create_bug1")
 var eventBug2:BuiltAnalyticsEvent = analytics.eventWithUID("create_bug2")
 analytics.triggerEventsFromArray([eventBug1, eventBug2])

Declared In

BuiltAnalytics.h

– triggerEventsImmediatelyFromArray:

Trigger multiple events

- (void)triggerEventsImmediatelyFromArray:(NSArray *)events

Parameters

events

array object.

Discussion

//'blt5d4sample2633b' is a dummy Application API key

//Obj-C
BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
BuiltAnalytics *analytics = [builtApplication analytics];
BuiltAnalyticsEvent *eventBug1 = [analytics eventWithUID:@"create_bug1"];
BuiltAnalyticsEvent *eventBug2 = [analytics eventWithUID:@"create_bug2"];
[analytics triggerEventsImmediatelyFromArray:@[eventBug1, eventBug2]];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics =  builtApplication.analytics()
 var eventBug1:BuiltAnalyticsEvent = analytics.eventWithUID("create_bug1")
 var eventBug2:BuiltAnalyticsEvent = analytics.eventWithUID("create_bug2")
 analytics.triggerEventsImmediatelyFromArray([eventBug1, eventBug2])

Declared In

BuiltAnalytics.h

Forcefully Send

– flush

Forcefully send all events at background to the server.

- (void)flush

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltAnalytics *analytics = [builtApplication analytics];
 [analytics flush];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics = builtApplication.analytics()
 analytics.flush()

Declared In

BuiltAnalytics.h

Cancel

– cancel

Advises the operation object that it should stop executing its task.

- (void)cancel

Discussion

This method does not force your operation code to stop. Instead, it updates the object’s internal flags to reflect the change in state. If the operation has already finished executing, this method has no effect. Canceling an operation that is currently in an operation queue, but not yet executing, makes it possible to remove the operation from the queue sooner than usual.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltAnalytics *analytics = [builtApplication analytics];
 [analytics cancel];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var analytics:BuiltAnalytics = builtApplication.analytics()
 analytics.cancel()

Declared In

BuiltAnalytics.h