Automattic / pocket-casts-android

Pocket Casts Android 🎧
https://forums.pocketcasts.com
Mozilla Public License 2.0
2.57k stars 218 forks source link

application_opened analytics event is delayed #338

Open mchowning opened 2 years ago

mchowning commented 2 years ago

The application_opened analytics event appears to be just a bit delayed resulting in it firing after the various screen shown events are fired. Seems like this could cause some difficulties with determining what the user's flow was through the app when they open the application.

2022-09-21 13:12:58.765 I  🔵 Tracked: podcast_tab_opened, Properties: {...}
2022-09-21 13:12:58.864 I  🔵 Tracked: podcasts_list_shown, Properties: {...}
2022-09-21 13:12:58.981  I  🔵 Tracked: application_opened, Properties: {...}

Actual Behavior

application_opened fires after the relevant screen_shown events are fired when opening the app

Expected Behavior

application_opened fires before the relevant screen_shown events are fired when opening the app

mchowning commented 2 years ago

Although less concerning, I've also noticed that the screen shown type of events events seem to be fired after the relevant tab_opened event. That feels backward to me as well and might be good to also fix.

ashiagr commented 2 years ago

The application_opened analytics event appears to be just a bit delayed resulting in it firing after the various screen shown events are fired.

Adding to it that it happens on the initial app launch. I can notice similar behavior for *_tab_opened events on iOS:

2022-09-29 17:35:11.521007+0530 podcasts[26417:327831] 🔵 Tracked: discover_tab_opened ["initial": true]
2022-09-29 17:35:12.361027+0530 podcasts[26417:327831] 🔵 Tracked: application_opened

I've also noticed that the screen shown type of events events seem to be fired after the relevant tab_opened event. That feels backward to me as well and might be good to also fix.

I can't seem to find any other way besides observing NavigatorAction.TabSwitched for tab changes. I tried moving screen shown type of events from fragment's onCreateView to onViewCreated/ onResume. It doesn't change the order and looks tricky to resolve.