-
Notifications
You must be signed in to change notification settings - Fork 2k
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: Improve shortcuts for date range picker #98160
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~149 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~90 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
{ | ||
id: 'year_to_date', | ||
label: translate( 'Year to date' ), | ||
startDate: siteToday.clone().startOf( 'year' ).format( DATE_FORMAT ), |
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.
Year to date
would be the same range as Month to date
when today is in the year's first month, which is not selectable by the current shortcut-finding mechanism.
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.
Could filter those items whose startDate and endDate are duplicated at the stage? Otherwise it'll look too buggy to ship.
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.
In follow up PRs, we could then probably test the id of the shortcuts before matching the dates.
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.
Maybe initially we could just hide the YTD option? Then we can follow up with any necessary fixes to allow it to be properly selected. As it currently stands, attempting to select it results in the MTD shortcut being highlighted and applied.
I do think it's worth keeping as a visible option when the two periods match though, as we store that as a persistent view state.
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.
Kevin's suggest sound pretty pragmatic 👍
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.
Sounds good to me!
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.
Updated in d61c082.
@@ -147,8 +149,9 @@ const basicStats = [ | |||
// Paid stats | |||
STAT_TYPE_REFERRERS, | |||
STAT_TYPE_CLICKS, | |||
STATS_FEATURE_DATE_CONTROL_LAST_90_DAYS, | |||
STATS_FEATURE_DATE_CONTROL_LAST_YEAR, | |||
STATS_FEATURE_DATE_CONTROL_LAST_12_MONTHS, |
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.
Do we also need to gate Month to date
for legacy sites?
@@ -154,6 +157,8 @@ const StatsDateControl = ( { | |||
|
|||
if ( appliedShortcut && appliedShortcut.id ) { | |||
localStorage.setItem( 'jetpack_stats_stored_date_range_shortcut_id', appliedShortcut.id ); | |||
// Apply the period from the found shortcut. | |||
period = appliedShortcut.period; |
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.
Love this!
@@ -57,13 +56,6 @@ export const getShortcuts = createSelector( | |||
endDate: siteTodayStr, | |||
period: DATERANGE_PERIOD.DAY, |
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.
Are we able to change the period to hour
and drop the force redirection 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.
Nice catch! 👍🏼
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.
Updated in 0069379.
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.
We may still need to keep the redirection for choosing a single day on the date range picker.
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.
This tests well for me excluding the comments on the YTD shortcut. If we're fine hiding the YTD shortcut initially, we could probably ship this and iterate. cc: @kangzj
Nice work, @dognose24!
{ | ||
id: 'year_to_date', | ||
label: translate( 'Year to date' ), | ||
startDate: siteToday.clone().startOf( 'year' ).format( DATE_FORMAT ), |
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.
Maybe initially we could just hide the YTD option? Then we can follow up with any necessary fixes to allow it to be properly selected. As it currently stands, attempting to select it results in the MTD shortcut being highlighted and applied.
I do think it's worth keeping as a visible option when the two periods match though, as we store that as a persistent view state.
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.
LGTM! Nice one 👍
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/17193169 Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday. Thank you @dognose24 for including a screenshot in the description! This is really helpful for our translators. |
Related to https://github.com/Automattic/red-team/issues/281
Proposed Changes
Yesterday
,Last 90 Days
, andLast Year
.Month to date
,Last 12 months
,Year to date
, andLast 3 years
.Why are these changes being made?
Testing Instructions
WPCOM free sites created before 2024-12-12
WPCOM free sites created after 2024-12-12
Pre-merge Checklist