Issue
My app is using Firebase Analytics and linked with BigQuery. I found in BigQuery log that sometimes my app kept logging engagement time event when the app seems to be inactive. The behavior can be divided into 2 patterns:
Pattern 1: App keeps sending user_engagement
event every one hour after app inactive.
Pattern 2: App was inactive for a long time (>1 hour). But when user come back, my app sent the first screen_view
event with incorrect engagement_time_msec
= ~amount of time since app last active.
Anyone has any idea what I could do wrong in my app. Since Firebase Analytics is not open source, I have no idea how this behavior could happen.
Solution
I finally found the root cause of incorrect engagement time. I found that Firebase Android SDK is not logging engagement time correctly when disable screen view tracking. I filed an issue here.
If you really need to disable auto screen tracking, you can use workaround I found below.
Warning This workaround may have side effect. Use it at your own risk.
I removed the following line from AndroidManifest.xml.
<meta-data android:name="google_analytics_automatic_screen_reporting_enabled" android:value="false" />
Then, use the following code in Activity's onResume for disabling automatic screen reporting instead.
override fun onResume() {
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(false)
super.onResume()
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(true)
}
Answered By - Chalermpong Satayavibul
Answer Checked By - David Goodson (JavaFixing Volunteer)