Page MenuHomePhabricator

Implement NetworkManager in MEP
Closed, ResolvedPublic


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.

Event Timeline

LGoto triaged this task as Medium priority.Jul 30 2020, 7:35 PM

NetworkManager is implemented in PR, in analytics' court for end-to-end testing.

Marking as resolved. For record-keeping: we decided to remove some of the functionality for the initial release, namely persisting outgoing requests. There are still some open questions around specifics of desired behavior, so for the version 1 release and the pilot we are going with a simpler version of network manager that can download data and that can POST requests in a fire-and-forget fashion.