Debugging Events in Firebase Analytics

One of the key challenges for mobile app tracking is debugging the output of the tracking tool. Firebase has recently presented a DebugView feature in their Analytics product which shows tracking data being sent in near real time. Let’s check why it is useful, how it works, and build a sample Android app.

Why?

As soon as you start to implement tracking (check my blog post if you are new to this topic) there is one thing you learn fast: testing and debugging the tracking output is extremely annoying. This happens because you need to capture and examine the large sets of data being sent to analytics servers.

Existing solutions

Of course, in some cases you can simply print logs or check the dashboard of your analytics tool. But these methods have many trade-offs: you may not be able to access logs in some situations such as for a release app build, and your analytics dashboards might show data with 1–24 hour delays.

Another way is to setup a proxy on your machine, install an appropriate SSL certificate for your test device and implement black box testing by intercepting all network traffic. In this way it is possible to read all data being sent to analytics. However, this requires some effort to parse all this data, and in some cases it could be messy and sent with delays because of the batching configuration of your tracking tool.

DebugView to the rescue!

A great Firebase Analytics Dashboard extension — Firebase DebugView — has recently become available. It has one simple goal: show a timeline of tracking events on a selected debug device in a near real-time mode.

For my test app, it received updates from the device almost immediately — in less than 3 seconds. You can press on one of logged events and check specific parameters that your app has passed to the analytics system.

The device selector at the top-left corner allows you to pick your test device. This allows several developers of your app to debug their tracking output streams independently with different devices.

Useful features

Below I highlighted three more useful features of DebugView you may like:

  1. As you may know, Firebase Analytics provides basic screen tracking out of the box. It also indicates the amount of engagement time that occurred for each screen in your app. This “screen” can either be the screen class (Activity on Android, View Controller on iOS) or any logical screen entity that a developer identifies manually through API. You can see these parameters by clicking on the user_engagement event that shows in the timeline.
  2. DebugView also indicates changes in user properties, so that developers can see — within the sequence of events — when a user property value changes from X to Y.
  3. DebugView output can be used as breadcrumb information together with Firebase Crash Reporting. As such, every crash of your debugged app will be reported in a timeline that you can see, and this allows one to trace possible steps to reproduce the reported app crash or custom error events. Currently, DebugView keeps a log of events for 30 minutes for each configured device.

Test device setup

To enable sending of DebugView data on a connected Android test device for a configured Firebase Analytics app, execute the following command:

adb shell setprop debug.firebase.analytics.app <package_name>

This behavior persists until you explicitly disable it by executing the following command:

adb shell setprop debug.firebase.analytics.app .none.

iOS test device setup is as easy as Android, just use there Xcode command line arguments correspondingly:

 –FIRDebugEnabled 

and

FIRDebugDisabled

Demo project

To try out Firebase Analytics and DebugView you can checkout my Android App tracking demo repository on GitHub. Follow Google Services setup instructions and don’t forget to put your configuration file in the proper project directory.

Instead of a conclusion

The Firebase team did a great job of introducing real-time analytics output with DebugView. Looking forward to seeing this pattern as an industry standard and this functionality being added to other tracking tools. If you know any analogs of DebugView available already — please post the url in comments.

Thanks for reading and please press a “heart” icon if you like this post.

Engineering Manager @ Facebook, Founder @ ProAndroidDev.com