Sunday, July 15, 2018

iOS Mobile App Analytics Debugging

Back in 2008, I wrote about debugging web analytics code. Mobile App Analytics testing, on the other hand has always been a mixed bag for me. I've primarily leveraged Charles Proxy to setup a connection between my device and my computer outlined in the instructions here but I've never been able to set it up without a glitch. Given that I mostly use Apple devices, I'm going to cover how to test iOS Apps in this post.

Charles Proxy iOS App

The new Charles iOS App is a godsend if you're looking to validate Analytics calls on an iPhone or iPad. This App costs only $8.99 for a single device and the best thing about is the simple setup which is what makes it a steal in my opinion given all the time it'll save you in configuration. I highly recommend this app if you want to save yourself the hassle of setting up Charles proxy on your Mac or desktop as this App works both on 4G/LTE and Wifi. Note that this method is recommended when you want to test an App downloaded on your iOS device. Here's a link to the iTunes Store to buy it.

Below are some screenshots and a quick walkthrough of how to set it up on iOS.

  • Download the App and "Trust" the App by going to Settings -> General -> Profiles & Device Management on your iPhone.

  • Now that the app is successfully installed , let's take a look at how to set it up to start recording traffic. The first step is to toggle the Status option to "Active". You will see an icon showing "VPN" appear next the cellular and Wifi icons. Next, click on the Gear icon highlighted in Red to go into the Settings screen.

  • The next step is to click the "SSL Proxying" menu to enable SSL tracking which is a very important step. Install the SSL certificate to capture secure packets.

  • Now that the certificate is installed and proxying enabled, we'll have to enable SSL proxying for individual host names. Click the "Disable SSL Proxying" link and again click on the "Enable SSL Proxying" link to enable SSL tracking for a particular host name. You will have to restart the App for it to take effect.

  • You should end up with a list of all host names that will be displayed when you download the Charles log (covered in the next few bullets). You can also manually add hostnames by clicking on the "+" icon.

  • Once SSL proxying is enabled, let's take a look at how to review the logs by going to the main screen and clicking into the "CURRENT SESSION" menu. 

  • Once on this screen, filter for the host name you want to analyze as shown in the two screenshots.

  • You can now review the analytics request by clicking on the "View body" option under REQUEST BODY.

  • The issue with the Response header is that it's not easily legible so it makes sense to share the analytics requests by clicking on the icon highlighted in Green. To clear all requests, click on the icon highlighted in Red. Note that you can share the Charles session via Slack, email or text. This is now my preferred method of testing App analytics requests.

  • You can finally view the output in the desktop app for Charles proxy to see it more clearly as well as share it with others.

Enable Debugging in XCode

Finally, I highly recommend that you enable setDebugLogging in XCode to validate your test App for your own QA.

Please feel free to share other tools or methods by which you perform your own mobile App validation.

No comments: