Question

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

Was it helpful?

Solution

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

OTHER TIPS

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);
    }

    ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top