|
|
@ -124,6 +124,7 @@ const int kOWSAnalytics_DiscardFrequency = 0;
|
|
|
|
|
|
|
|
|
|
|
|
- (void)tryToSyncEvents
|
|
|
|
- (void)tryToSyncEvents
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
// Don't try to sync if:
|
|
|
|
// Don't try to sync if:
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// * There's no network available.
|
|
|
|
// * There's no network available.
|
|
|
@ -132,7 +133,6 @@ const int kOWSAnalytics_DiscardFrequency = 0;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
|
|
|
|
__block NSString *firstEventKey = nil;
|
|
|
|
__block NSString *firstEventKey = nil;
|
|
|
|
__block NSDictionary *firstEventDictionary = nil;
|
|
|
|
__block NSDictionary *firstEventDictionary = nil;
|
|
|
|
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
@ -157,6 +157,12 @@ const int kOWSAnalytics_DiscardFrequency = 0;
|
|
|
|
|
|
|
|
|
|
|
|
DDLogDebug(@"%@ trying to deliver event: %@", self.tag, firstEventKey);
|
|
|
|
DDLogDebug(@"%@ trying to deliver event: %@", self.tag, firstEventKey);
|
|
|
|
self.hasRequestInFlight = YES;
|
|
|
|
self.hasRequestInFlight = YES;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__block UIBackgroundTaskIdentifier task;
|
|
|
|
|
|
|
|
task = [UIApplication.sharedApplication beginBackgroundTaskWithExpirationHandler:^{
|
|
|
|
|
|
|
|
[UIApplication.sharedApplication endBackgroundTask:task];
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
// Until we integrate with an analytics platform, behave as though all event delivery succeeds.
|
|
|
|
// Until we integrate with an analytics platform, behave as though all event delivery succeeds.
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
self.hasRequestInFlight = NO;
|
|
|
|
self.hasRequestInFlight = NO;
|
|
|
@ -169,6 +175,8 @@ const int kOWSAnalytics_DiscardFrequency = 0;
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[UIApplication.sharedApplication endBackgroundTask:task];
|
|
|
|
|
|
|
|
|
|
|
|
// Wait a second between network requests / retries.
|
|
|
|
// Wait a second between network requests / retries.
|
|
|
|
dispatch_after(
|
|
|
|
dispatch_after(
|
|
|
|
dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|