#1595 - Adding App User count event to be triggered and immediately sent when Access Token is set.

This commit is contained in:
Brad Leege
2015-05-19 17:02:54 -05:00
parent f74fe69cb8
commit f3d7212137
3 changed files with 6 additions and 1 deletions

View File

@@ -53,6 +53,9 @@
// Update MGLMapboxEvents
// NOTE: This is (likely) the initial setup of MGLMapboxEvents
[MGLMapboxEvents sharedManager];
// Count App Users
[MGLMapboxEvents pushEvent:MGLEventTypeAppUserCount withAttributes:nil];
}
+ (NSString *) accessToken {

View File

@@ -1,5 +1,6 @@
#import <Foundation/Foundation.h>
extern NSString *const MGLEventTypeAppUserCount;
extern NSString *const MGLEventTypeMapLoad;
extern NSString *const MGLEventTypeMapTap;
extern NSString *const MGLEventTypeMapDragEnd;

View File

@@ -16,6 +16,7 @@
static NSString *const MGLMapboxEventsUserAgent = @"MapboxEventsiOS/1.0";
static NSString *MGLMapboxEventsAPIBase = @"https://api.tiles.mapbox.com";
NSString *const MGLEventTypeAppUserCount = @"appUserCount";
NSString *const MGLEventTypeMapLoad = @"map.load";
NSString *const MGLEventTypeMapTap = @"map.click";
NSString *const MGLEventTypeMapDragEnd = @"map.dragend";
@@ -481,7 +482,7 @@ const NSTimeInterval MGLFlushInterval = 60;
[_eventQueue addObject:finalEvent];
// Has Flush Limit Been Reached?
if (_eventQueue.count >= MGLMaximumEventsPerFlush) {
if (_eventQueue.count >= MGLMaximumEventsPerFlush || [MGLEventTypeAppUserCount isEqualToString:event]) {
[strongSelf flush];
} else if (_eventQueue.count == 1) {
// If this is first new event on queue start timer,