[Android] Session Duration returns 0 and has no event (Ghost Session)

Hi Countly team,

I am facing an issue that some sessions are returns no duration value and no event. My current version is 22.06.0

After investigation, I think the root cause is beginSessionInternal function is called 2 times in the row when opening app in the first time.

1. When setting up the Consents -> onConsentChanged() func is called -> beginSessionInternal() is called.

2. When starting an activity -> countly.onStart(activity) is called -> beginSessionInternal() is called.

After that, the app works fine without any ghost sessions.

Can you help me how to resolve this problem?

Thank you in advance.

0

Comments

5 comments
  • Official comment

    Hello, could you share your SDK initialization code that reproduces the issue?

    Comment actions Permalink
  • Note that there is no ghost session on Countly version 20.11.11

    0
    Comment actions Permalink
  • Yes, sure

    val countlyConfig = CountlyConfig(appContext, analyticsKey, serverUrl).apply {
    setHttpPostForced(false)
    setEventQueueSizeToSend(2)
    setRequiresConsent(true)
    setLoggingEnabled(false)
    setAutoTrackingUseShortName(false)
    setConsentEnabled(emptyArray())
    enableCrashReporting()
    setParameterTamperingProtectionSalt(saltKey)
    }
    Countly.sharedInstance().init(countlyConfig)
    Countly.sharedInstance().consent().giveConsent(
    arrayOf(
    Countly.CountlyFeatureNames.events,
    Countly.CountlyFeatureNames.sessions,
    Countly.CountlyFeatureNames.users,
    Countly.CountlyFeatureNames.views,
    Countly.CountlyFeatureNames.attribution,
    Countly.CountlyFeatureNames.location,
    Countly.CountlyFeatureNames.crashes,
    Countly.CountlyFeatureNames.push,
    Countly.CountlyFeatureNames.feedback

    And I also call 

    Countly.sharedInstance().onStart(activity) and Countly.sharedInstance().onStop()

    every time going to the onStart() and onStop() of an activity.

    0
    Comment actions Permalink
  • Hello, in this case the issue should be fixed if you would give the consent as part of the config object and not with a separate call right after init. Something like this:
    https://github.com/Countly/countly-sdk-android/blob/master/app/src/main/java/ly/count/android/demo/App.java#L195-L200

    0
    Comment actions Permalink
  • yes, It works perfectly. Thanks for your support.

    0
    Comment actions Permalink

Please sign in to leave a comment.