Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tags Feed] Fix duplicate tracking in Reader subfilter #20844

Merged

Conversation

thomashorta
Copy link
Contributor

@thomashorta thomashorta commented May 17, 2024

Fixes #20814

  • Keep a consistent reference to the SubFilterViewModel observers to leverage the existing Observable APIs, which handle duplicate observation, removal, and re-observation in case of multiple observe call and lifecycle state changes
  • Fix sending the reader_filter_sheet_item_selected when selecting a filterable feed (e.g.: Subscriptions and Your Tags)

To Test:

  1. Install Jetpack
  2. Make sure App Setting -> Privacy -> Collect Information is enabled
  3. Make sure reader_tags_feed Feature config is enabled (Debug Settings -> Remote Features
  4. Go to Reader
  5. Go to Subscriptions
  6. Verify reader_filter_sheet_item_selected is not tracked
  7. Tap the subfilter pill
  8. Verify appropriate events are tracked ONLY ONCE
  9. Tap a Site
  10. Verify reader_filter_sheet_item_selected is tracked ONLY ONCE
  11. Tap the pill again
  12. Repeat 9-11 multiple times making sure events are tracked ONLY ONCE per trigger
  13. Go to Your Tags
  14. Repeat 6-12

Regression Notes

  1. Potential unintended areas of impact

    • N/A
  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    • N/A
  3. What automated tests I added (or what prevented me from doing so)

    • Unit tests not added for the one-time initialization mechanism since it is done completely in Fragment and ViewModel non-exposed APIs (onCleared)
    • Unit tests updated for bug fix related to sending reader_filter_sheet_item_selected when opening a filterable feed

PR Submission Checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing Checklist (strike-out the not-applying and unnecessary ones):

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

Also making sure it works for Fragment recreation by the system (such as screen
rotation) and ViewModel destruction due to owner being destroyed.
@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 17, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20844-12e9ef7
Commit12e9ef7
Direct Downloadwordpress-prototype-build-pr20844-12e9ef7.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 17, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20844-12e9ef7
Commit12e9ef7
Direct Downloadjetpack-prototype-build-pr20844-12e9ef7.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented May 17, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 40.88%. Comparing base (06d79f6) to head (12e9ef7).

Files Patch % Lines
.../android/ui/reader/subfilter/SubFilterViewModel.kt 76.92% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           feature/tags-ia   #20844      +/-   ##
===================================================
+ Coverage            40.84%   40.88%   +0.04%     
===================================================
  Files                 1493     1493              
  Lines                68766    68770       +4     
  Branches             11350    11350              
===================================================
+ Hits                 28087    28117      +30     
+ Misses               38131    38098      -33     
- Partials              2548     2555       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@daniloercoli daniloercoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
While testing this PR i've found a bug in the top menu. We will discuss it on Slack before opening a new ticket for it.

@thomashorta thomashorta changed the title Issue/20814 reader subfilter tracking bug [Tags Feed] Fix duplicate tracking in Reader subfilter May 20, 2024
@thomashorta
Copy link
Contributor Author

I tested the scenarios we discussed on Slack and indeed the solution here doesn't seem to be working correctly for some of them. I'm marking the PR as Not Ready for Merge and Not Ready for Review while I think of a different solution. Thanks for the review @daniloercoli !

This makes sure that the Lifecycle and ViewModel Owners handle everything
correctly when observing LiveData, which avoids duplicate observers and allows
for correct auto removal/re-observation due to lifecycle and owner state change.
@thomashorta
Copy link
Contributor Author

@daniloercoli, to fix the issue I needed to radically change the solution. The new solution properly uses the observable mechanism by creating a local reference to the Observers, which prevents duplicate observation by default (thanks to the "Observer, LifecycleOwner" tuple being stable and consistent now), and also handles lifecycle and view model state changes automatically.

Please review again with the new changes!

@daniloercoli
Copy link
Contributor

which prevents duplicate observation by default (thanks to the "Observer, LifecycleOwner" tuple being stable and consistent now), and also handles lifecycle and view model state changes automatically.

Tested and cannot replicate the issue anymore! Code looks robust, and adheres to good practices with regard to ViewModel and lifecycle management. LGTM!

@daniloercoli daniloercoli self-requested a review May 20, 2024 15:46
@daniloercoli
Copy link
Contributor

Feel free to merge this PR, once the problems with testes are resolved.

Copy link

sonarcloud bot commented May 20, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@thomashorta thomashorta merged commit 5bbddf0 into feature/tags-ia May 20, 2024
20 checks passed
@thomashorta thomashorta deleted the issue/20814-reader-subfilter-tracking-bug branch May 20, 2024 19:37
Copy link

sentry-io bot commented May 29, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ IllegalArgumentException: Tried to schedule job for non-existent component: ComponentInfo{com.jetpack.android/org.wordpress... org.wordpress.android.ui.reader.services.update... View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants