Event Management

What is an event?

Any action performed by the user in the application that is of interest for analytics and improving the app/user experience is an event. Every time such an action occurs, the details of this action is recorded in Upshot.ai as an event.

Examples of an event

Dispatch Frequency

Events are dispatched to the server within a time interval of 10secs to 120secs. You can choose the frequency at which events should be dispatched. By default, events are dispatched to the server once in every 60 secs

Sample Code:
[[BrandKinesis sharedInstance] setDispatchInterval:30 ];
BrandKinesis.sharedInstance(). dispatchInterval = 30

Dispatch Events

DispatchEventsWithTimedEvents method allows you to flush all events from your app to the Upshot.ai server immediately. You can use this method for any particular action in your application.

Sample Code:
[[BrandKinesis sharedInstance] dispatchEventsWithTimedEvents:YES completionBlock:^(BOOL dispatched) {
}];
BrandKinesis.sharedInstance(). dispatchEvents(withTimedEvents: true) { (status) in
}

Types of Event

Predefined Events

Upshot.ai defines a set of predefined events in the SDK.

Custom Events

Any event that could not be accommodated through predefined events, can be created through Custom Events. Custom Events in Upshot.ai are classified as timed and non-timed events.

Non-Timed Events

An event where the start time and the end time are the same is a non-timed event.

Example: Say a button tap. It does not matter how long the button was pressed for. This becomes a non-timed event, where you are only interested in the fact that the user tapped a button, time factor is not crucial.

Sample Code:
NSDictionary *payload = @{
@"ItemCost": [NSNumber numberWithInteger:10000],
@"ItemName":@"Mobile"
};
NSString *eventId = [[BrandKinesis sharedInstance] createEvent:@"Purchase" params: payload isTimed: NO];
let options = ["ItemCost" : 10000,
"ItemName" : "Mobile"] as [String : Any]
let *eventId = BrandKinesis.sharedInstance().createEvent("Purchase", params: options, isTimed:false)
Timed Events

An event where the end time is different from the start time is a timed event.

Example: A game level takes 30 seconds to finish. So a “game level played” event starts at X and ends at Y. There's a time component associated with the event here, hence it is considered as a timed event.

Note:

Sample Code:
NSDictionary *payload = @{
@"ItemCost": [NSNumber numberWithInteger:10000],
@"ItemName":@"Mobile"
};
NSString *eventId = [[BrandKinesis sharedInstance] createEvent:@"Purchase" params: payload isTimed: YES];
let options = ["ItemCost" : 10000,
"ItemName" : "Mobile"] as [String : Any]
let *eventId = BrandKinesis.sharedInstance().createEvent("Purchase", params: options, isTimed:true)

Note:

Sample Code to close event
[[BrandKinesis sharedInstance] closeEventForID:eventId];
BrandKinesis.sharedInstance(). closeEvent(forID: eventId)
Sample Code for Set Data And Close:
NSDictionary *payload = @{
@"ItemCost": [NSNumber numberWithInteger:10000],
@"ItemName":@"Mobile"
};
[[BrandKinesis sharedInstance] setValueAndClose:payload forEvent: eventId];
let payload = ["ItemCost" : 10000,
"ItemName" : "Mobile"] as [String : Any]
BrandKinesis.sharedInstance().setValueAndClose(options, forEvent: eventId)
You can check Events in Dashboard under Live Events section