We need to implement the networking layer of the new Event Platform Client library.
Interface thoughts
class NetworkManager init(storageManager: StorageManager) let storageManager: StorageManager func httpDownload(url: String, completion: (Data?) -> Void) func httpPost(url: String, body: String) func httpTryPost()
- httpDownload is a simple download method that retries if there's an error, except if response is 404. Log error.
- httpPost calls StorageManager's savePostItem method
- httpTryPost is akin to EventLoggingService's tryPostEvents. This will call StorageManager's fetchPostItemsToPost and post them. If it succeeded or failed, mark those events via StorageManager's updatePostItem.
- AppViewController will call NetworkManager's httpTryPost as a periodic worker and a background fetcher, like how EventLoggingService is set up.
- We need to restore the ability to log an event from anywhere via singleton.
- We need to hook up EventPlatformClientLibrary's loggingEnabled up with the permissions in the welcome screen and settings. We also need the ability to reset the session and appInstallID when that value is toggled off and back on.
Known deltas with old library
EventLoggingService posts only on Wifi. It keeps track of when last successful post was made, and if that value gets too large it turns the wifi-only posting off. Should we keep this? Seems like yes.
There's some persisted lastLoggedSnapshot logic used in UserHistoryFunnel. Doesn't seem like we need this yet.
There's a persisted appInstallDate and loggedDaysInstall that we use in WMFDailyStatsLoggingFunnel. Doesn't seem like we need this.
The old library doesn't seem to disable logging when the app moves to the background like the new library.