WordPress-iOS icon indicating copy to clipboard operation
WordPress-iOS copied to clipboard

Stats Traffic: Ensure deep links and widget routing work

Open staskus opened this issue 1 year ago • 2 comments

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

https://github.com/wordpress-mobile/WordPress-iOS/assets/4062343/11bbc3a2-27fe-4c51-91eb-d23a26cecd1a

Stats Traffic feature flag disabled

https://github.com/wordpress-mobile/WordPress-iOS/assets/4062343/65703dbc-ae6c-4950-acf9-56616c3c1459

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:

  • [x] I have completed the Regression Notes.
  • [x] I have considered adding unit tests for my changes.
  • [x] I have considered adding accessibility improvements for my changes.
  • [x] 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 avatar Feb 23 '24 12:02 staskus

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
Commitb58d8ce6442ababd219a835523c400b9fc34c290
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 avatar Feb 23 '24 12:02 wpmobilebot

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
Commitb58d8ce6442ababd219a835523c400b9fc34c290
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.

wpmobilebot avatar Feb 23 '24 12:02 wpmobilebot

@guarani ready for review after merging with the latest changes

staskus avatar Feb 27 '24 17:02 staskus

❌ 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: https://github.com/wordpress-mobile/WordPress-iOS/issues/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 avatar Feb 28 '24 08:02 staskus