Premium Analytics: add the Month to date and Year to date periods - #52088
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Premium Analytics plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 2 files.
|
chihsuan
left a comment
There was a problem hiding this comment.
Thanks for this @louwie17! These feel worth having for v1, the prototype has them. approving. 👍
I did notice that on 30 June, Year to date steps back a day short and hides the forward arrow. #52108 removes the arrows entirely though, so probably no need to address.
Separately, Claude Code found that Year to date with Same period in <year> does not start on 1 January around leap years. Read in 2028 it starts on 31 December 2026, and the label reads Same period in 2026. 2026 and 2027 are clean, so nothing shows today. Pre-existing and untouched here, so I filed it as follow-up (UNI-767), but the description says year over year is unaffected.
| export const PRESET_LAST_365_DAYS = 'last-365-days' as const; | ||
| export const PRESET_MONTH_TO_DATE = 'month-to-date' as const; | ||
| export const PRESET_LAST_MONTH = 'last-month' as const; | ||
| export const PRESET_YEAR_TO_DATE = 'year-to-date' as const; |
There was a problem hiding this comment.
nit: just for consistency, should these two be re-exported from the package barrels too? The other presets are.
There was a problem hiding this comment.
Good catch — done in c6a7ec4. Both now sit in presets/index.ts and datetime/src/index.ts in their menu positions, next to PRESET_LAST_MONTH and PRESET_LAST_12_MONTHS.
Both sit in the design's period menu and neither had been built on any surface. Each joins the group of the window it pairs with — Month to date beside Last month, Year to date beside Last 12 months. Neither completes its running unit the way `last-12-months` does, so `completeToDateRange` is untouched. Completed, each shifts onto a unit of another length and its previous period stops mirroring the selection: month to date read on 8 March came back three days shorter than the eight days it covers, and year to date read on 1 January 2028 came back inverted, its start after its end. Read as they stand, both shift by their own day count and stay equal; Previous year still compares against the same days a year earlier either way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015eDqAWndvFNBrBRdKcsYus
…panel The seam is drawn as the calendar's inline-start border, and the panel aligned both halves to its start, so the border only ever spanned the calendar. Two more periods make the list the taller half for the first time, leaving Custom range with no seam beside it. Stretching both halves gives the border the panel's height whichever side is taller. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015eDqAWndvFNBrBRdKcsYus
76bec02 to
c6a7ec4
Compare
Proposed changes
Adds the two periods the revised date-picker design lists and we have never shipped: Month to date and Year to date. Each joins the group of the window it pairs with — Month to date beside Last month, Year to date beside Last 12 months — on every surface the period menu serves.
#51835 flagged both under "Deliberately not here": "Month to date and Year to date appear in the design but are not presets we ship." That was a statement about what was built, not a decision against them, and no Linear issue asks for or rejects either. The prototype on UNI-754 shows both, which is what prompted this.
Worth a product opinion: nobody has explicitly asked for these two, and this puts them on the dashboard as well as the detail pages. Happy to drop it if the answer is "not for v1".
Neither one completes its running unit
last-12-monthsruns from the first of a month to the end of today, so anything measuring it in whole units — its length, the previous period — measures the completed window instead (completeToDateRange). Giving the two new to-date periods the same treatment is the obvious move and is wrong for both, soto-date-range.tsends up untouched:fromafterto— and on 1 January 2025 it put three days against one.Read as they stand, both shift by their own day count and stay equal. Year over year is unaffected either way:
previous-yearshifts the dates as read, so Year to date still compares against the same days a year earlier. Both failures have regression tests.A seam that stopped short
The panel's seam is the calendar's
border-inline-start, and the panel aligned both halves to its start, so the border only ever spanned the calendar. Two more rows make the list the taller half for the first time (483px against the calendar's 460px), leaving Custom range with no seam beside it. Stretching both halves gives the border the panel's height whichever side is taller.This is not reachable on trunk — the calendar is always at least as tall as today's list, at wide and narrow viewports alike — so there is no changelog entry for it.
Screenshots
Period menu, against trunk:
The seam, with Custom range open (note the divider stopping above the bottom-left corner):
Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Build the dashboard:
jetpack build --deps packages/premium-analytics, then open Premium Analytics (wp-admin/admin.php?page=jetpack-premium-analytics-wp-admin).pnpm run testinprojects/packages/premium-analyticspasses (3184 tests), as doespnpm run test-tz(the Tokyo / Los Angeles matrix).🤖 Generated with Claude Code
https://claude.ai/code/session_015eDqAWndvFNBrBRdKcsYus