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

Stats Traffic: Ensure deep links and widget routing work #22695

Conversation

staskus
Copy link
Contributor

@staskus staskus commented Feb 23, 2024

Ensure deep links and widget routing work

https://github.com/wordpress-mobile/jetpack-issue-repo/issues/16
https://github.com/wordpress-mobile/jetpack-issue-repo/issues/17

Problem

Routing is supported by setting StatsPeriodType in user preferences and then reading from it when determining which tab to display when opening Stats.

This solution worked well when /days /months /years /insights routes mapped well to tabs displayed on the Stats Dashboard.

However, with the introduction of Traffic tab, we need to separate the concept of the selected tab (Insights / Traffic), and the selected period unit (Days/Weeks/Months/Years) while at the same time keep supporting the previous configuration with feature flag disabled.

Solution

  1. Rename StatsPeriodType to StatsTabType to correctly reflect that this enum is used to represent tabs displayed on Stats Dashboard
  2. Aggregate all user preferences code in SiteStatsDashboardPreferences
  3. When setting StatsTabType during the routing process, also set StatsPeriodUnit, mapping /days to .day, /months to .month...
  4. When opening Stats Traffic, set the selected period unit to Traffic VC (getSelectedPeriodUnit) which was preselected during the routing process. When the feature flag is disabled, getSelectedPeriodUnit is not used since the selected tab is equal to the selected unit as well.

To test:

Widgets

  1. Enable the Stats Traffic feature flag
  2. Add all types of widgets for different sites
  3. Confirm that correct tab is opened with a correct period type

Links

  1. Enable the Stats Traffic feature flag
  2. Open WordPress.com/stats
  3. Switch between Traffic/Insights, and Day/Week/Month/Year data range
  4. Select Open Jetpack banner
  5. Confirm that correct tab is opened with a correct period type

Tab Switching regression

  1. Enable the Stats Traffic feature flag
  2. Open Stats
  3. Select Insights tab
  4. Leave Stats
  5. Re-enter Stats, confirm Insights tab is shown
  6. Change to Traffic
  7. Leave/come back to Stats
  8. Confirm Traffic tab is shown
  9. Add "This week" widget
  10. Tap on widget
  11. Confirm Traffic tab with Weekly chart is shown
  12. Leave/come back to Stats
  13. Confirm Traffic tab with Weekly chart is shown

Videos

Stats Traffic feature flag enabled

Routing.Stats.Traffic.mp4

Stats Traffic feature flag disabled

Routing.Before.mp4

Regression Notes

  1. Potential unintended areas of impact

Breaking existing routing functionality

  1. What I did to test those areas of impact (or what existing automated tests I relied on)
  • I tried to make the solution that doesn't change anything how routing or tab selection works
  • Did manual testing (see video)
  1. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • 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.
  • VoiceOver.
  • 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)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@staskus staskus added this to the 24.4 milestone Feb 23, 2024
@staskus staskus requested a review from guarani February 23, 2024 12:34
@staskus staskus self-assigned this Feb 23, 2024
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 23, 2024

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr22695-b58d8ce
Version24.3
Bundle IDorg.wordpress.alpha
Commitb58d8ce
App Center BuildWPiOS - One-Offs #8999
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 23, 2024

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr22695-b58d8ce
Version24.3
Bundle IDcom.jetpack.alpha
Commitb58d8ce
App Center Buildjetpack-installable-builds #8037
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@staskus staskus mentioned this pull request Feb 27, 2024
13 tasks
@staskus staskus force-pushed the task/stats-traffic-ensure-deep-links-notifications-widgets-work-with-traffic-tab branch from 55e3b72 to b58d8ce Compare February 27, 2024 17:31
@staskus
Copy link
Contributor Author

staskus commented Feb 27, 2024

@guarani ready for review after merging with the latest changes

Copy link
Contributor

@guarani guarani left a comment

Choose a reason for hiding this comment

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

Thanks @staskus!

I think this is ready to merge as-is.

Widgets
  • Home Screen Widgets
    • ✅ Today's Views
    • ✅ Today's Views, Visitors, Likes, and Comments
    • ✅ This Week's Views (Small)
    • ✅ This Week's Views (Large)
    • ✅ All-Time Views (Small)
  • Lock Screen Widgets
    • ✅ Today's Views
    • ✅ Today's Views & Visitors
    • ✅ Today's Likes & Comments
    • ✅ All-Time Views
    • ✅ All-Time Views & Visitors
    • ✅ All-Time Posts & Most Views

Links

@staskus
Copy link
Contributor Author

staskus commented Feb 28, 2024

https://wordpress.com/stats/day doesn't open "By day", it's opening the most recently opened period instead
This is an existing issue (tested with the current production version 24.2.1, I'll make a separate issue for it (update: #22714)

Yes, good observation. Looks like /stats/:domain and not /stats/day/:domain route is called in this case. Maybe even fixes from the web side are required. I'll take a look after we've done with other tasks of the feature.

@staskus staskus merged commit 972276e into trunk Feb 28, 2024
23 checks passed
@staskus staskus deleted the task/stats-traffic-ensure-deep-links-notifications-widgets-work-with-traffic-tab branch February 28, 2024 08:01
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.

3 participants