0

Is there an efficient way to turn off Flurry while debugging?

Right now the best way I can think of is setting a DEBUG variable to true in one file, and in all of my activities

    super.onStart();
    if(PublicStuff.DEBUG != true) //if debug = false run this code
        FlurryAgent.onStartSession(this, "2C3QVVZMX8Q5M6KF3458");

do I also need to case out the Flurry logEvent methods?

is there a better way?

thanks

CQM
  • 42,592
  • 75
  • 224
  • 366

2 Answers2

2

Look at the isDebuggerConnected() method in the Debug class. That tells you exactly what you need to know.

SimonSays
  • 10,867
  • 7
  • 44
  • 59
  • okay that method is looking for a debugger, but what if the phone is not connected to a computer but still using a build that was created with a debug keystore, such as if you unplugged your device from a pc and walked away. – CQM Jun 06 '13 at 21:59
  • 4
    Use an invalid Flurry key (i'm using 'XXX') for development. Then build your app release with ant and during the build you can replace the key with the production key. This way you can have different keys for different builds (dev, test and prod). – SimonSays Jun 06 '13 at 23:18
0

This is how I went about achieving this. I create something like a UserEvents class that contains all analytics loggable events (in this case Flurry). Before I log an event, I check if the build is not in DEBUG mode. See code sample below:

public class UserEvents {
    public static final String CLICK_RATINGS = "click_ratings";
    public static final String CLICK_SHARE = "click_share";
    public static final String CLICK_CREDITS = "click_credits";
    public static final String CLICK_PRIVACY = "click_privacy";
    ...

    private static boolean isNotLoggable(){
        return BuildConfig.DEBUG;
    }

    public static void logEvent(String event) {
        if(isNotLoggable()) return;
        logEvent(event);
    }

    ...
}
karthiks
  • 7,049
  • 7
  • 47
  • 62