firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.25k stars 572 forks source link

Engagement Time is logged incorrectly when disable screen view tracking #3240

Open chalermpong opened 2 years ago

chalermpong commented 2 years ago

[READ] Step 1: Are you in the right place?

Yes.

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

This issue is related to my previous issue #3039 Firebase Analytics logs incorrect engagement time. As shown in Log below

2021-12-14 13:42:21.554 16014-16064/my.app.package I/FA: App measurement initialized, version: 46000
2021-12-14 13:42:21.554 16014-16064/my.app.package I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2021-12-14 13:42:21.554 16014-16064/my.app.package I/FA: Faster debug mode event logging enabled. To disable, run:
adb shell setprop debug.firebase.analytics.app .none.
2021-12-14 13:42:21.554 16014-16064/my.app.package D/FA: Debug-level message logging enabled
2021-12-14 13:42:21.580 16014-16064/my.app.package V/FA: Connecting to remote service
2021-12-14 13:42:21.590 16014-16064/my.app.package V/FA: Connection attempt already in progress
2021-12-14 13:42:21.595 16014-16064/my.app.package V/FA: Connection attempt already in progress
2021-12-14 13:42:21.596 16014-16064/my.app.package D/FA: Connected to remote service
2021-12-14 13:42:21.596 16014-16064/my.app.package V/FA: Processing queued up service tasks: 3
2021-12-14 13:42:26.625 16014-16064/my.app.package V/FA: Inactivity, disconnecting from the service
2021-12-14 13:42:50.656 16014-16055/my.app.package V/FA: onActivityCreated
2021-12-14 13:42:50.700 16014-16064/my.app.package V/FA: Activity resumed, time: 246386362
2021-12-14 13:42:50.701 16014-16055/my.app.package V/FA: Logging screen view with name, class: main, MainActivity1
2021-12-14 13:42:50.705 16014-16064/my.app.package I/FA: Tag Manager is not found and thus will not be used
2021-12-14 13:42:50.728 16014-16064/my.app.package V/FA: Connecting to remote service
2021-12-14 13:42:50.745 16014-16064/my.app.package V/FA: Connection attempt already in progress
2021-12-14 13:42:50.799 16014-16064/my.app.package D/FA: Connected to remote service
2021-12-14 13:42:50.802 16014-16064/my.app.package V/FA: Processing queued up service tasks: 2
2021-12-14 13:42:55.810 16014-16064/my.app.package V/FA: Inactivity, disconnecting from the service
2021-12-14 13:42:56.270 16014-16064/my.app.package V/FA: Activity paused, time: 246391932
2021-12-14 13:42:58.272 16014-16064/my.app.package D/FA: Application going to the background
2021-12-14 13:42:58.283 16014-16064/my.app.package V/FA: Recording user engagement, ms: 34745

Explanation for the log above

I kill the app before start of the log above.
13:42:21.554 <-- I sent a data message to the app
13:42:50.700 <-- I started the app
13:42:56.270 <-- I left the app using Android home button

The engagement time should be around 6 seconds, but Firebase Analytics logged 34745 milliseconds. Seems like FA started logging engagement time when app received a data message.

Steps to reproduce:

Prerequisite: The app must disable screen view tracking, and be able to receive data message

  1. Start app and kill the app quickly before FA logs engagement time (explanation in note below).
  2. Send a data message to the app
  3. Open app again
  4. Stay in the first screen for a few seconds then leave the app. FA will log engagement time = time since it received the data message instead of time since app open.

Note: When disable screen view tracking, there will be ~2 seconds delay before FA logs engagement time. So it is possible to kill the app quickly before Recording user engagement happens.

2021-12-14 13:42:56.270 16014-16064/my.app.package V/FA: Activity paused, time: 246391932
2021-12-14 13:42:58.272 16014-16064/my.app.package D/FA: Application going to the background
2021-12-14 13:42:58.283 16014-16064/my.app.package V/FA: Recording user engagement, ms: 34745

If the app is not disable screen view tracking, the Recording user engagement, ms: ... will happen before Activity paused, time: ...

lbarrettanderson commented 4 months ago

@michalnovacek96

Almost same issue here. But we did NOT disable automatic screen_view tracking, but beyond automatic screen_view tracking we are tracking manually screen views.

Snímek obrazovky 2024-01-16 v 15 33 29

Since you haven't disabled automatic screen views, your issue might be different. By chance did you either: 1.) Implement consent mode or 2.) start calling the resetAnalyticsData method?

We discovered another engagement-related bug around those two features. If you implemented consent mode, you should see an improvement next week. If you're manually calling resetAnalyticsData, a fix for that issue is coming (timeframe not known, but likely in the next 6 weeks).

woodii commented 4 months ago

@lbarrettanderson thank you so much! A first glance at the stats looks promising. image

michalnovacek96 commented 4 months ago

@lbarrettanderson It seems that stats are starting to look ok. But still Android is way much higher than iOS. Avereage time per session on iOS is 46 seconds, on Android 55 minutes. This can't be real.

My setup is:

lbarrettanderson commented 4 months ago

@lbarrettanderson It seems that stats are starting to look ok. But still Android is way much higher than iOS. Avereage time per session on iOS is 46 seconds, on Android 55 minutes. This can't be real.

My setup is:

  • I have not disabled automatic screen view tracking
  • I have setup Google Consent Mode v1. I am populating only analytics_storage. Snímek obrazovky 2024-05-21 v 10 34 36

This issue has also been recently fixed, but the recovery time might take longer due to the nature of the bug.

Do you by chance ever call resetAnalyticsData?

michalnovacek96 commented 4 months ago

@lbarrettanderson No, we don't call resetAnalyticsData

lbarrettanderson commented 4 months ago

@lbarrettanderson No, we don't call resetAnalyticsData

Do you distribute to non-Google Play devices? If so, an SDK update will be required to fix this. The SDK version with this fix (firebase-analytics 22.0.1) will be available soon.

michalnovacek96 commented 4 months ago

@lbarrettanderson No we only distribute Android on Google Play.

lbarrettanderson commented 3 months ago

If you're not seeing as much improvement as expected, I recommend updating your firebase-analytics SDK to version 22.0.1 or newer. This should help any users who for whatever reason are not getting the updated version of google play services.

lbarrettanderson commented 2 months ago

Has anyone who was hoping for more of a reduction in engagement times tried upgrading to firebase-analytics 22.0.1? Did it help?

cahyoardhi commented 1 week ago

Any update to this issue?