Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log events Firebase Analytics for Android

I'm trying to implement the Firebase Analytics for Android and it's not working.

So far what I have done is this https://firebase.google.com/docs/analytics/android/start/

private FirebaseAnalytics mFirebaseAnalytics;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //...
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    mFirebaseAnalytics.setUserProperty("dev", "TEST");

    // [START custom_event]
    Bundle params = new Bundle();
    params.putString("dev_name", "dev_name_test");
    params.putString("dev_description", "Testing log events");
    mFirebaseAnalytics.logEvent("dev_test", params);
    // ....

Also I have disabled the disable Instant Run:

To disable Instant Run: Open the Settings or Preferences dialog. Navigate to Build, Execution, Deployment > Instant Run. Uncheck the box next to Enable Instant Run

Any idea why is not working? I can't see anything in my firebase dashboard.

like image 954
gon250 Avatar asked May 25 '16 13:05

gon250


2 Answers

The fastest way to validate that events are recorded and uploaded is to enable debug logging: View events in the Android Studio debug log

In summary run this from command line with the device/emulator connected:

adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC

You should see messages when you log events or set properties and when the data is uploaded.

like image 178
djabi Avatar answered Sep 21 '22 20:09

djabi


It takes around 2-4 hours in my experiences for any events to appear in the console. Also, note that the default view in the console is the past 30 days, you may want to switch this to Today. Something to consider also is that in the console for custom events you will only be able to view the event dev_test and not the strings you have added as custom parameters. You must export the events to BigQuery to view the custom parameters you have added dev_name abd dev_description. See my similar question here which may also help.

like image 33
ez4nick Avatar answered Sep 20 '22 20:09

ez4nick