Search code examples
androidflurry

Logging events in Flurry outside an active session


Does Flurry only log custom events if a session is active? or does it also log custom events outside the scope of a session? I ask this because we let the user decide to enable/disable data tracking, and I would like to know if encapsulating the Sessions around an if-statement is sufficient, or if I should place if-statements around each FlurryAgent.logEvent(...) call.


Solution

  • From my usage of Flurry, you need to make logEvent calls within the scope of a session. So failing to call the session will prevent the logEvent from working.

    In my case I was simply trying to track when a user enabled or disable an app widget which I didn't want tracked as a session because it would skew my stats as these "sessions" would not even last a second.

    In your case it would represent desired behaviour.

    But considering the Flurry library is not transparent, I wouldn't trust the current behaviour. Since the call is static, it really wouldn't be that taxing to surround with static call.

    public static void logEvent(Context context){
        boolean userWantsPrivacy = PreferenceManager bla bla...
        if(!userWantsPrivacy){
            FlurryAgent.logEvent(...)
        }
    }
    

    If the access to the sharedpreference causes some kind of perceived performance hit, consider storing the preference in some sort of singleton.