WordPress-iOS
WordPress-iOS copied to clipboard
Stats Traffic: Ensure deep links and widget routing work
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
- Rename
StatsPeriodType
toStatsTabType
to correctly reflect that thisenum
is used to represent tabs displayed on Stats Dashboard - Aggregate all user preferences code in
SiteStatsDashboardPreferences
- When setting
StatsTabType
during the routing process, also setStatsPeriodUnit
, mapping/days to .day
,/months to .month
... - 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
- Enable the Stats Traffic feature flag
- Add all types of widgets for different sites
- Confirm that correct tab is opened with a correct period type
Links
- Enable the Stats Traffic feature flag
- Open WordPress.com/stats
- Switch between Traffic/Insights, and Day/Week/Month/Year data range
- Select Open Jetpack banner
- Confirm that correct tab is opened with a correct period type
Tab Switching regression
- Enable the Stats Traffic feature flag
- Open Stats
- Select Insights tab
- Leave Stats
- Re-enter Stats, confirm Insights tab is shown
- Change to Traffic
- Leave/come back to Stats
- Confirm Traffic tab is shown
- Add "This week" widget
- Tap on widget
- Confirm Traffic tab with Weekly chart is shown
- Leave/come back to Stats
- 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
- Potential unintended areas of impact
Breaking existing routing functionality
- 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)
- 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)
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App Name | ![]() |
|
Configuration | Release-Alpha | |
Build Number | pr22695-b58d8ce | |
Version | 24.3 | |
Bundle ID | org.wordpress.alpha | |
Commit | b58d8ce6442ababd219a835523c400b9fc34c290 | |
App Center Build | WPiOS - One-Offs #8999 |
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App Name | ![]() |
|
Configuration | Release-Alpha | |
Build Number | pr22695-b58d8ce | |
Version | 24.3 | |
Bundle ID | com.jetpack.alpha | |
Commit | b58d8ce6442ababd219a835523c400b9fc34c290 | |
App Center Build | jetpack-installable-builds #8037 |
@guarani ready for review after merging with the latest changes
❌ 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.