dimanche 29 mai 2016

iOS better approach for sending in-app exceptions, crashes, network request data and display data

I need to add to an existing iOS app the capability to send three different type of statistics by issuing GET requests to a web-server, and I would like to know the best approach to satisfy all of these requirements:

  • error statistic: send this GET request anytime there is an exception or app crash.

  • screen load statistic: this GET request has one parameter in the query string that expresses the amount of time taken (in ms) from when the user initiated a request that show the screen to the point where the screen has finished drawing.

  • network statistic: send this GET request anytime there is a network request in the app. This request has one parameter in the query string that expresses the amount of time taken (in ms) for the complete request.

For the network statistic my own idea is generating a NSMutableArray somewhere used to store any Stat instances. To grab the amount of time taken for each network complete request I thought I can simply create an instance of networkStatistic before each network request, and using closure of the complete block of the network request to refer to the same instance and determine the amount of time taken from its creation. Finally, the instance can be pushed in the array and consume any instance inside it with ease.

About screen statistics, I thought about the following method valid only when the user interacts with the Navigation: I create an instance of screenStatistic in each viewWillAppear of each VC, and use viewDidAppear to grab the previously created instance and set the amount of time taken from its creation (similarly to the previous method). After I can add it into the Stat Array and the job is done. How can I solve the problem in the other cases, for example when the user click to a button that fetches new data from the server which is used to update the screen?

About error statistics, I really have no idea how I can catch app crashes. About exceptions, can you confirm that network errors are not considered exception, but errors that have to be displayed to the user (like an alert box)?

Thank you all, and sorry for being a bit verbose.

Aucun commentaire:

Enregistrer un commentaire