Repository navigation
Premium Analytics: drop the grouping control from the WordAds chart - #52483
Conversation
drop the grouping control and add a line or bar toggle
|
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. Wpcomsh plugin:
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 SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
louwie17
left a comment
There was a problem hiding this comment.
Thanks @retrofox, this tested well and code looks good! Checked each period on the local Docker site, the unit follows the window as described, the bar toggle sticks after a reload, and an instance saved on trunk with Last 30 days by weeks loads fine and draws by day.
I did leave three inline comments. The main one is around the date dropdown in the header, it's noticeably taller than the chart type toggle next to it and the other header dropdowns. The other two are small clean ups around the now unused interval control and two of the new test cases. None of them are blockers, happy if they are follow ups 🚀
| withIntervalControl: true, | ||
| grain: WORDADS_GRAIN, | ||
| } ), | ||
| reportParamsAttributeField< WordAdsChartTabsAttributes >( { grain: WORDADS_GRAIN } ), |
There was a problem hiding this comment.
The date dropdown looks quite a bit bigger than the chart type toggle next to it, and the other widget header dropdowns (like Metrics on the highlights widget above it).
As far as I can tell this is because it's the page-level DatePeriodDropdown, which gets its 40px height from the menu trigger mixin ( _menu-trigger.scss ), while the header fields use size="compact" ( select-field.tsx ), so 32px. It was already like this on trunk, but it stands out more now that the toggle sits right next to it. Maybe we can scope a compact height for the widget header, similar to what date-year-filter.scss does with --wp-ui-button-height? Fine as a follow up.
There was a problem hiding this comment.
Good catch, and thanks for tracing it to the menu trigger mixin. It predates this PR and affects every widget-owned date control (the Subscribers chart in #52421 gets the same header), so I'd take it as a follow-up: the mixin hardcodes --wpds-dimension-size-lg, so it needs a compact variant the widget header can opt into rather than a local override. I'll link it here.
|
|
||
| type ReportParamsFieldOptions = { | ||
| /** | ||
| * Whether to offer the chart bucket control. |
There was a problem hiding this comment.
With WordAds dropping it, no widget passes withIntervalControl: true anymore, so the interval options and changeInterval in ReportParamsControl are computed for a control nobody renders. Should we remove the option, or do we expect another widget to pick it up soon? The fields README also still uses it as the example. Can be a follow up.
There was a problem hiding this comment.
I'd keep it. It's the widget-owned side of the same bucket control DateFiltersPanel still renders in the dashboard header (routes/dashboard/stage.tsx), and WOOA7S-2158 leaves room to bring the grouping back to this chart if people ask for weekly revenue after launch; this option is how it would come back.
The README example documents the option itself, so it still holds. The interval options are computed on every render but only read when the control renders; gating them behind the option is a two-line change if you'd prefer.
| [ 'a day-long window', { from: '2026-06-29', to: '2026-06-30', interval: 'hour' }, 'day' ], | ||
| [ 'two months', { from: '2026-05-01', to: '2026-06-30', interval: 'week' }, 'day' ], | ||
| [ 'four months', { from: '2026-03-02', to: '2026-06-30', interval: 'month' }, 'week' ], | ||
| [ 'over a year', { from: '2025-05-27', to: '2026-06-30', interval: 'year' }, 'month' ], |
There was a problem hiding this comment.
Codex pointed out that "a day-long window" and "over a year" also pass against trunk's widget code, I checked and it's right. The saved interval was never allowed for those ranges, so trunk already clamped them to the same unit. year is only on offer from 1095 days, so should we stretch this range past three years so it covers the case this PR actually changes? With the range below it fails on trunk ( requests unit=year ) and passes here.
| [ 'over a year', { from: '2025-05-27', to: '2026-06-30', interval: 'year' }, 'month' ], | |
| [ 'over three years', { from: '2023-01-01', to: '2026-06-30', interval: 'year' }, 'month' ], |
There was a problem hiding this comment.
Good catch, confirmed: against trunk's widget code the one-year case clamps to month on its own, and so does the day-long one.
Applied your range in 4124b46: the table now keeps the three windows where trunk would honor the saved interval (two months by week, four by month, over three years by year), and all three fail against trunk's render.tsx and pass here.
The day-long window moved to its own test, since it only covers that the chart never asks for hours.
the one-year and day-long cases passed on trunk too
Fixes WOOA7S-2158
Proposed changes
The WordAds chart on the Ads tab now offers the same header controls as the Subscribers chart: the period, then a line or bar toggle.
Out of scope: the
wordads/statsendpoint anchors monthly windows to today, which may add leading months to Last 12 months. That predates this PR and is tracked on WOOA7S-2158.Related product discussion/links
widgets/wordads-chart-tabs/widget.ts, so whichever lands second resolves a one-line conflict.Does this pull request change what data or activity we track or use?
No.
Testing instructions
Setup
jetpack build --deps packages/premium-analytics.Header
Grouping
wordads/statsrequest:unit=day.unit=month.unit=week; of more than a year:unit=month.Saved grouping
Screen.Recording.2026-09-18.at.12.46.25.PM.mov