Learn to use DebugView to see Analytics events in real time.
- [Narrator] In order to conserve battery life and bandwidth usage of your device, Google Analytics for Firebase does not transmit data in real time as it is recorded in your app. Instead it badges the data together and sends it all at once, usually every hour or so. And even then the console view itself is updated daily. Of course this makes it harder to debug your analytics events and to help with this process you can use the debug view in the Firebase console. So let's take a quick look at the debug view.
So here in my console, I'm going to open up my project and go to the Analytics Tab and then I'm going to choose these debug view item that's under the Stream View menu and that will take me to debug view. So the debug view is divided into a few different areas. This middle card here is the seconds stream. The seconds stream shows events as they come in from a testing device during the last 60 seconds. You can click on individual events to see the parameters that were logged along with that event.
The minutes stream over here shows groups of events that have occurred within the last 30 minutes. On the right side, the top events section shows how many general conversion and error events have happened and the user property sections shows the currently set user properties. Now, some of these topics like conversion events and user properties we'll cover later in the course. What's important for the moment is that this feature gives you a way to see events happening in real time as you're testing your app.
And what's really nice about this feature is that is also works with the Android emulator. So, you don't need to use a physical device, although you can of course if you want to. So I'm going to demonstrate this using the finished version of the app. Now, you're not going to be able to do this with your copy of the finished app because it's not connected to the Firebase server. So you can either just relax and enjoy the demo or you can try this with your current progress in the start version of the project that you've been working on.
So here in Android Studio I have opened up the finished version of the project because that's the version of the project that has all of the analytics already finished. And I've also got my emulator running. So here's my virtual device with my emulator running. So what we need to do is use ADB to set the analytics debugging property on the emulator. So to do that I'll open the terminal through Android Studio and I'll make sure that the Android emulator is connected. And it is, you can see that it's right there.
So the way that we do this is we type ADB Shell and then Set Prop to set a property. The property we need to set is called Debug.Firebase.Analytics.App. And then we give it the package name of the app that we want to enable real time event logging for. In this case, it's com.joemarini.dieroller. Now if you've renamed the package obviously you'll use a different package name but I'm going to use the default that came with the project. Alright, now to unset this, it's worth noting that this property is sticky.
In other words, once you set it, it's going to stay set for the device or emulator you set it on. So if you want to turn this off, the way that you turn it off is by typing ADBShellSetProp and then once again Debug.Firebase.Analytics.App and then .none. and that will turn it off. So I'm not going to do that because we need to demonstrate this but that's how you turn it off for the emulator or the device that you set the property on.
Alright, so now that we got real time debugging enabled, I can go ahead and hide this. Alright, so let's try this out. I'm going to start this up in the emulator. So I'll hit the debug and choose the emulator and we'll wait for the app to appear. Alright, so there's our app. So let's go over to the console and let's bring up the emulator so we can see it. Alright, now I'll position the emulator over here. Alright, and you can see that the screen view has already started and there's the session start.
So I'll go ahead and interact with the app a little bit. I'll roll the dice a couple times and I will change the number of dice. And you can see that events are streaming in as I'm doing them. You can see that the click events are being registered. So let's click on an individual event. Let's go ahead and click on this guy right here and you can see that for this roll 4 event the die size was 6 and it gives me some information about the event, what the origin was and the name of the screen, it's my main activity.
So debug view is a very useful feature when you're developing your app. And I highly recommend that you become familiar with it. It will probably also be useful as you go through the rest of the course so you won't need to wait for the daily refreshes of the console data, so you might want to use it as you complete the rest of the exercises in the course so you can see your events in real time.
- Why use analytics?
- Reviewing the Google Analytics for Firebase feature set
- Adding Analytics support to an application
- Using DebugView to see Analytics events in real time
- Logging events to Firebase using a set of predefined event types
- Event collection
- Gaining insight into the behaviors of specific types of users