KeenClient-iOS
KeenClient-iOS copied to clipboard
Duplicate Upload with events not being cleared from local data store
Details of Customer Keen IO Integration:
We are using Keen Library v3.5.5. We are not overriding keen.timestamp and are calling self.keenClient.uploadWithFinishedBlock when our app enters background mode.
Customer reports seeing duplicates around 25-35%. We can confirm that events with the exact same payload are being 'generated' twice i.e. with different values for keen.created_at.
This may be similar to Issue #156, but unsure whether uploadWithFinishedBlock is being called successively.
Opening the issue here so that we can collect more information in terms of trying to replicate the problem.
Code block provided:
Keen Upload
func uploadToDataKeen() {
let application = UIApplication.sharedApplication()
let backgroundTaskID = application.beginBackgroundTaskWithExpirationHandler { () -> Voidin
print("Upload task for keen is expiring")
}
self.keenClient.uploadWithFinishedBlock { () -> Voidin
application.endBackgroundTask(backgroundTaskID)
}
}
And the function is called via Observer callback:
@objcprivatefunc didEnterBackground() {
trackPotentialOldSavedSession()
saveCurrentSession()
uploadToDataKeen()
}
The observer is registered as follows:
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(TrackingService.didEnterBackground), name: UIApplicationDidEnterBackgroundNotification, object: nil)
@subbuthepeaceful thanks for sending the code snippets, I'm sorry this is happening. :(
Looking at the code, nothing comes to mind on why this may be happening... I'm going to take a closer look at this later today and update you here.
Thank you very much @heitortsergent Please let me know if we can provide any additional information that would help diagnose
@subbuthepeaceful I still don't see anything in the code snippets that could be causing the error...
Could you please ask the customer the code block where they're calling the last line:
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(TrackingService.didEnterBackground), name: UIApplicationDidEnterBackgroundNotification, object: nil)
Hi, @heitortsergent. We add this observer in the init
of our TrackingService
class. This class is a singleton and responsible for creating our keen events and calling the uploadWithFinishBlock
method.
Hi all,
Has there been any progress on this? I've been running into the same issues.
FYI, @schwmi @heitortsergent @subbuthepeaceful
Hi, is there any news on this issue?