2

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

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
cagryInside
  • 790
  • 2
  • 15
  • 41

1 Answers1

3

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)

djabi
  • 5,601
  • 18
  • 25
  • thanks, now I am not getting the "bool configuration name not recognized: ga_dryRun" error. But, still on Amazon fire phone, it keeps pushing events – cagryInside Mar 12 '15 at 03:29
  • Can you please enable verbose logging and post GAV4 logs for dispatching the hits too? From the logs one can tell what hits are being uploaded to Analytics and that is usually enough to validate that your app is working correctly. – djabi Mar 13 '15 at 14:36
  • @djabi To clarify - we want to disable event reporting when running the app in debug config. But, setting `setDryRun(true)` on Fire Phone doesn't have the desired effect of disabling events. Also note that we've added a link to our open-source project on Github in the original question if you want to try it yourself. – Sean Barbeau Mar 13 '15 at 18:15