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

[Reader] Add subscribed sites and followed tags to analytics #20303

Conversation

daniloercoli
Copy link
Contributor

Fixes #19836


To Test:

  • Install Jetpack and sign-in
  • Open Reader
  • 🔍 Tags followed are correctly tracked
  • 🔍 Sites subscribed analytics are tracked

To check analytics you can use the Track Live view tool, use logcat and filter by Reader events, or set few breakpoints in the Reader Tracker.

Note: The FollowedTagsFetched event is triggered multiple times during the normal operation of the Reader, a known issue. To avoid excessive analytics tracking, I've implemented a 1-hour guard. While not ideal—since we might want to track changes in the number of tags and only update when there's a difference—this approach may miss tracking for users who don't often change their tag count, especially if the original tag-followed event occurs outside the analysed timespan. Nonetheless, I'm open to suggestions, though I believe this is a reasonable compromise without having to track both the last event time, and the number of blogs subscribed to in the app settings.


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:

  • 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)

…t is fired

Note that we're aware of an underlying issue with the FollowedTagsChanged event being fired excessively, even when the tags have not changed. To address this, I've implemented a guard to prevent excessive analytics tracking, currently set to 1 hour. This guard does not verify the previous number of tags sent to analytics. Considering the frequent triggering of "tags changed," this seems to be a reasonable compromise.
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 27, 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
Versionpr20303-ee22402
Commitee22402
Direct Downloadwordpress-prototype-build-pr20303-ee22402.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 27, 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
Versionpr20303-ee22402
Commitee22402
Direct Downloadjetpack-prototype-build-pr20303-ee22402.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

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

Project coverage is 40.23%. Comparing base (f831640) to head (ee22402).
Report is 15 commits behind head on trunk.

Files Patch % Lines
...rdpress/android/ui/reader/tracker/ReaderTracker.kt 0.00% 6 Missing ⚠️
.../java/org/wordpress/android/ui/prefs/AppPrefs.java 0.00% 3 Missing ⚠️
.../org/wordpress/android/ui/reader/ReaderEvents.java 0.00% 3 Missing ⚠️
...d/ui/reader/services/update/ReaderUpdateLogic.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #20303      +/-   ##
==========================================
- Coverage   40.24%   40.23%   -0.01%     
==========================================
  Files        1472     1472              
  Lines       67920    67932      +12     
  Branches    11248    11249       +1     
==========================================
  Hits        27334    27334              
- Misses      38086    38098      +12     
  Partials     2500     2500              

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

@RenanLukas RenanLukas self-assigned this Feb 27, 2024
@RenanLukas
Copy link
Contributor

RenanLukas commented Feb 27, 2024

Thanks for the PR, @daniloercoli . The followed tags is working as expected. I'm getting this in the logcat:

🔵 Tracked: reader_following_fetched, Properties: {"count":"3","type":"tags"}

Before reviewing the code I wanted to ask about the reader_following_fetched blogs event: it seems like it's not being tracked when we have 0 blogs. I suppose the FollowedBlogsChanged event is not triggered when user has 0 blogs? I wanted to confirm we really don't want to track the 0.

Besides that, I'm not understanding where the number of blogs is coming from. In the blogs chip and bottom sheet list I'm getting 14 blogs. When I tap "Edit" in the bottom sheet I'm getting 48 blogs and in the reader_following_fetched event it's 57. I think we had a discussion about this number in the past, but I wasn't able to find it. Perhaps this is being tracked in another issue.

According to web it's really 57, so something's probably off with the Android Reader (not related to your PR)
image

@daniloercoli
Copy link
Contributor Author

daniloercoli commented Feb 28, 2024

Besides that, I'm not understanding where the number of blogs is coming from. In the blogs chip and bottom sheet list I'm getting 14 blogs. When I tap "Edit" in the bottom sheet I'm getting 48 blogs and in the reader_following_fetched event it's 57. I think we had a discussion about this number in the past, but I wasn't able to find it. Perhaps this is being tracked in another issue.

According to web it's really 57, so something's probably off with the Android Reader (not related to your PR)

The value '57' represents the total number of sites you're subscribed to, including P2s, A8C internal sites, and RSS feeds, aligning with what you see on the web.
It seems the list of sites displayed on Android both on the bottom sheet is missing a subset of your subscribed sites.

On the Web reader, a call to https://public-api.wordpress.com/rest/v1.1/read/subscriptions-count retrieves the total subscriptions, including comments.

{
    "code": 200,
    "headers": [
        {
            "name": "Content-Type",
            "value": "application\/json"
        }
    ],
    "body": {
        "blogs": 302,
        "comments": 2096,
        "pending": 0
    }
}

The total number of sites subscribed is also returned at the bottom of the JSON document from https://public-api.wordpress.com/rest/v1.2/read/following/mine?number=100&page=1, in the total_subscriptions property, which matches the value from the other endpoint.

There appears to be an issue with the way the Filter bottom sheet works on the Android Reader, in addition to the already reported pagination issue. However, i think that the ticket here #20218 does recap both of the problems.

@daniloercoli
Copy link
Contributor Author

Before reviewing the code I wanted to ask about the reader_following_fetched blogs event: it seems like it's not being tracked when we have 0 blogs. I suppose the FollowedBlogsChanged event is not triggered when user has 0 blogs? I wanted to confirm we really don't want to track the 0.

Good point! Actually Subscribed sites analytics are tracked only if there's an addition or deletion, as indicated by if (!localBlogs.isSameList(serverBlogs)) {.
Perhaps we should consider setting a timer that by-passes the count check, similar to what we implemented for the other event, to ensure bumping analytics for people that doesn't change the list often?

@RenanLukas
Copy link
Contributor

Perhaps we should consider setting a timer that by-passes the count check, similar to what we implemented for the other event, to ensure bumping analytics for people that doesn't change the list often?

@daniloercoli makes sense to me 👍 should we have a separate issue and PR for that?

@daniloercoli
Copy link
Contributor Author

Perhaps we should consider setting a timer that by-passes the count check, similar to what we implemented for the other event, to ensure bumping analytics for people that doesn't change the list often?

@daniloercoli makes sense to me 👍 should we have a separate issue and PR for that?

@RenanLukas Yes, it would probably be better to include the improvements in a separate PR.

Copy link
Contributor

@RenanLukas RenanLukas left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @daniloercoli ! I'm approving because it's working as expected, but I've left a couple of suggestions.

Comment on lines +953 to +960
// Check last time we've bumped tags followed analytics for this user,
// and bumping again if > 1 hrs
long tagsUpdatedTimestamp = AppPrefs.getReaderAnalyticsCountTagsTimestamp();
long now = new DateProvider().getCurrentDate().getTime();
if (now - tagsUpdatedTimestamp > 1000 * 60 * 60) { // 1 hr
ReaderTracker.trackFollowedTagsCount(ReaderTagTable.getFollowedTags().size());
AppPrefs.setReaderAnalyticsCountTagsTimestamp(now);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Would it make sense to move this logic to ReaderPostListViewModel so we can unit test this and keep this logic away from the View? The ViewModel even has an instance of the ReaderTracker injected so we could even avoid the static call.

@@ -959,6 +969,8 @@ && hasCurrentTag()
&& (getCurrentTag().isFollowedSites() || getCurrentTag().isDefaultInMemoryTag())) {
refreshPosts();
}

ReaderTracker.trackSubscribedSitesCount(event.getTotalSubscriptions());
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Same question about moving it to the ViewModel so it's testable.

AnalyticsTracker.track(Stat.READER_FOLLOWING_FETCHED, props)
}

@JvmStatic
Copy link
Contributor

Choose a reason for hiding this comment

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

If the idea of moving it to the ViewModel makes sense, maybe we can remove the @JvmStatic annotation from here and line 481.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @RenanLukas Thank you for your review! Your suggestions are valuable, and I will work on the PR to enhance site tracking and transfer the logic to the ViewModel within that PR.

@daniloercoli daniloercoli merged commit eadd3de into trunk Mar 1, 2024
19 checks passed
@daniloercoli daniloercoli deleted the issue-19836-Add-followed-sites-and-tags-to-Reader-analytics-events branch March 1, 2024 09:56
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.

[Reader IA] Add number of followed sites and tags to Reader analytics events
3 participants