androidgoogle-analyticsgoogle-analytics-firebaseamazon-fire-os

Google Analytics V4 setDryRun(true) doesn't work in Amazon Fire Phone


I want to disable logging Google Analytics (GA) events when the app is running in Debug mode. So, I implemented the following:

if (BuildConfig.DEBUG) {
    //Disables reporting when app runs on debug
    GoogleAnalytics.getInstance(context).setDryRun(true);
}

It works fine with every "Google" Android phone I tested (i.e., does NOT report events while debugging app), but it does NOT work with the Amazon Fire Phone (i.e., Fire Phone still reports events while debugging - perhaps because it doesn't have Google Play Services installed?).

All events are properly reported to GA, so GA in general is working on the Fire Phone- but, GoogleAnalytics.setDryRun(true) does not have any effect.

This issue has also been posted to the Google Product Forum for Google Analytics: https://productforums.google.com/forum/#!topic/analytics/1zAmZCu1Bx4

Here is Google Analytics Logs:

 V/GAV4﹕ Thread[main,5,main]: [Tracker] trackingId loaded: UA-XXXXXXXX
 V/GAV4﹕ Thread[main,5,main]: [Tracker] sample frequency loaded:
 W/GAV4﹕ Thread[main,5,main]: bool configuration name not recognized:  ga_dryRun
 W/GAV4﹕ Thread[main,5,main]: bool configuration name not recognized:  ga_dryRun

Here is the open-source project:

https://github.com/OneBusAway/onebusaway-android


Solution

  • It looks like you are also setting ga_dryRun in your xml configuration. Setting dry run from code has precedence over the xml configuration. In your code snippet you only set dry-run in debug mode. Try setting it always:

    GoogleAnalytics.getInstance(context).setDryRun(BuildConfig.DEBUG); //Disables reporting when app runs on debug

    Also remove any XML configuration setting dry run mode. You don't need it if you are going to set it from code (code overwrites it anyway)