-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Reader] Add subscribed sites and followed tags to analytics #20303
Conversation
…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.
…Reader-analytics-events
📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
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. |
Thanks for the PR, @daniloercoli . The followed tags is working as expected. I'm getting this in the logcat:
Before reviewing the code I wanted to ask about the 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 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. On the Web reader, a call to
The total number of sites subscribed is also returned at the bottom of the JSON document from 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. |
Good point! Actually Subscribed sites analytics are tracked only if there's an addition or deletion, as indicated by if |
@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. |
There was a problem hiding this 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.
// 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); | ||
} |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
Fixes #19836
To Test:
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:
RELEASE-NOTES.txt
if necessary.Testing Checklist: