Inherits from NSObject
Declared in KiiAnalytics.h

Overview

The main SDK class

This class allows the application to make some high-level user calls and access some application-wide data at any time using static methods.

Class Methods

getResultSynchronousWithID:andQuery:andError:

Get a result set of analytics based on a specific query.

+ (nullable KAGroupedResult *)getResultSynchronousWithID:(NSString *)aggregationRuleID andQuery:(nullable KAResultQuery *)query andError:(NSError *_Nullable *_Nullable)error

Parameters

aggregationRuleID

The aggregation rule to slice data by

query

The query object to use for retrieving data

error

An NSError object, set to nil, to test for errors

Return Value

A result object with the segmented data broken into manageable data structures. Usually KAGroupedSnapShots.

Discussion

Get a result set of analytics based on a specific query.

This method allows you to use analytics results within your application. This method is blocking. Here is a sample snippet that get analytics data and output it to console log.

If you want to know more information of this analytics data, please see the GroupedResult item in Flex analytics Guide

NSError *error = nil;
KAGroupedResult *results = [KiiAnalytics getResultSynchronousWithID:@"my-aggregation-rule" andQuery:myQuery andError:&error];
if (error != nil) {
    // There is something wrong...
    return;
}
NSLog(@"Got results: %@", results);

// Get snapshots array
NSArray *snapshotArray = results.snapshots;
for (KAGroupedSnapShot *snapshot in snapshotArray) {
    // Get the label of the dimension/grouping key.
    NSLog(@"Name : %@", snapshot.name);
    // Get the date in which the data starts.
    NSLog(@"PointStart : %f", snapshot.pointStart);
    // Get interval between data points.
    NSLog(@"PointInterval : %f", snapshot.pointInterval);
    // Get the JSON Array that contains the data retrieved by the query.
    for (NSNumber *data in snapshot.data) {
        NSLog(@"Data : %@", data);
    }
}

Declared In

KiiAnalytics.h

getResultWithID:andQuery:andBlock:

Get a result set of analytics based on a specific query.

+ (void)getResultWithID:(NSString *)aggregationRuleID andQuery:(nullable KAResultQuery *)query andBlock:(KAResultBlock)block

Parameters

aggregationRuleID

The aggregation rule to slice data by

query

The query object to use for retrieving data

block

The block to be called upon method completion. See example

Discussion

Get a result set of analytics based on a specific query.

This method allows you to use analytics results within your application. This method is non-blocking. Here is a sample snippet that get analytics data and output it to console log.

If you want to know more information of this analytics data, please see the GroupedResult item in Flex analytics Guide

[KiiAnalytics getResultWithID:@"my-aggregation-rule"
                     andQuery:myQuery
                     andBlock:^(KAGroupedResult *results, NSError *error) {
    if (error != nil) {
        // There is something wrong...
        return;
    }
    NSLog(@"Got results: %@", results);

    // Get snapshots array
    NSArray *snapshotArray = results.snapshots;
    for (KAGroupedSnapShot *snapshot in snapshotArray) {
        // Get the label of the dimension/grouping key.
        NSLog(@"Name : %@", snapshot.name);
        // Get the date in which the data starts.
        NSLog(@"PointStart : %f", snapshot.pointStart);
        // Get interval between data points.
        NSLog(@"PointInterval : %f", snapshot.pointInterval);
        // Get the JSON Array that contains the data retrieved by the query.
        for (NSNumber *data in snapshot.data) {
            NSLog(@"Data : %@", data);
        }
    }

Declared In

KiiAnalytics.h

trackEvent:

Log a single event to be uploaded to KiiAnalytics

+ (BOOL)trackEvent:(NSString *)event

Parameters

event

A string representing the event name for later tracking. This must not nil or empty, and length must be less than or equals 128bytes in UTF-8.

Return Value

TRUE if the event was added properly, FALSE otherwise

Discussion

Log a single event to be uploaded to KiiAnalytics

Use this method if you’d like to track an event by name only. If you’d like to track other attributes/dimensions, please use trackEvent:withExtras: Will return TRUE every time unless there was an error writing to the cache.

Declared In

KiiAnalytics.h

trackEvent:withExtras:

Log a single event to be uploaded to KiiAnalytics

+ (BOOL)trackEvent:(NSString *)event withExtras:(nullable NSDictionary *)extras

Parameters

event

A string representing the event name for later tracking. This must not nil or empty, and length must be less than or equals 128bytes in UTF-8.

extras

A dictionary of JSON-encodable key/value pairs to be attached to the event

Return Value

TRUE if the event was added properly, FALSE otherwise

Discussion

Log a single event to be uploaded to KiiAnalytics

Use this method if you’d like to track an event by name and add extra information to the event. Will return TRUE every time unless there was an error writing to the cache OR if one of the extra key/value pairs was not JSON-encodable.

Declared In

KiiAnalytics.h