Skip to content

Premium Analytics: add date range picker to the dashboard#49572

Draft
Nikschavan wants to merge 9 commits into
update/pa-introduce-customize-dashboardfrom
add/pa-date-range-picker
Draft

Premium Analytics: add date range picker to the dashboard#49572
Nikschavan wants to merge 9 commits into
update/pa-introduce-customize-dashboardfrom
add/pa-date-range-picker

Conversation

@Nikschavan

Copy link
Copy Markdown
Member

Fixes #

Proposed changes

Ports the date range picker from the next-woocommerce-analytics dashboard into the Premium Analytics dashboard, syncing the selected range to URL search params so every widget picks it up.

  • dashboard route: renders the DateFiltersPanel (already vendored in packages/ui) at the top of the dashboard, wired to useStagedSearch from @jetpack-premium-analytics/routing. Date range and preset edits are staged locally and committed atomically to the URL search params on Apply (from, to, preset); the to date is adjusted to end-of-day since the calendar component returns midnight. Comparison changes (compare_from, compare_to, compare_preset, comp) commit immediately, matching the original dashboard behavior.
  • widgets-toolkit: points WidgetRoot's default search source at / (the premium-analytics dashboard route) instead of the WooCommerce Analytics route path, so widgets resolve their report params from the dashboard URL via normalizeReportParams. No widget changes needed — they already read params through useWidgetRootContext().
  • package.json: adds link:packages/* deps for the data/datetime/formatters/routing/ui internal packages so wp-build can resolve them from the route bundle; documents the new deps in the dashboard route's package.json; updates pnpm-lock.yaml accordingly.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • Set up a site with the Premium Analytics plugin active.
  • Go to the Analytics dashboard.
  • Verify the date range picker and the Compare to dropdown render above the widgets.
  • Open the picker, choose a preset (e.g. Last 7 days), and click Apply.
  • Verify the URL updates (from, to and preset search params inside the p param) and widgets re-fetch for the new range.
  • Pick a custom range via the calendar or the From/To inputs and verify Apply/Cancel stage and revert correctly.
  • Enable comparison via the Compare to dropdown and verify the compare_from/compare_to/compare_preset/comp params commit immediately without pressing Apply.
  • Reload the page with the params in the URL and verify the picker restores the selected range.

retrofox and others added 9 commits June 12, 2026 11:38
Private, source-consumed copy of @wordpress/grid until core publishes it.
Private, source-consumed copy of @wordpress/widget-primitives until core publishes it.
Private, source-consumed dashboard engine; depends on jetpack-widget-primitives and jetpack-grid.
Renders the WidgetDashboard engine via wp-build, bundling the grid/primitives/dashboard packages.
useWidgetTypes drives discovery via /wp/v2/widget-modules; hello-world builds as a lazy-loaded script module.
Hook the page boot-dependencies filter so widget modules reach the import map; move the endpoint to the jetpack/v4 namespace.
@wordpress/grid and widget-primitives references in widget-dashboard JSDoc/comments/README, per the faithful-source sync policy.
Stages from/to and comparison params via useStagedSearch and commits them to URL search params so widgets re-fetch on apply. Fixes the widget-root default search source to the page root.
Copilot AI review requested due to automatic review settings June 12, 2026 02:48
@Nikschavan Nikschavan self-assigned this Jun 12, 2026
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/pa-date-range-picker branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/pa-date-range-picker
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/pa-date-range-picker

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports the Premium Analytics dashboard to support a shared date range picker (with comparison), syncing date state through URL search params so all widgets resolve consistent report parameters.

Changes:

  • Render DateFiltersPanel in the Premium Analytics dashboard route and wire it to staged URL search params with an Apply/Cancel flow.
  • Update widgets-toolkit WidgetRoot to default its search param source to / (the Premium Analytics dashboard route).
  • Add/adjust internal package dependencies and lockfile entries to ensure route bundling can resolve shared packages.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
projects/packages/premium-analytics/routes/dashboard/stage.tsx Adds the date range + comparison UI and stages/commits selected values to URL search params.
projects/packages/premium-analytics/routes/dashboard/package.json Adds required internal deps and date-fns for the dashboard route bundle.
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/widget-root/widget-root.tsx Changes default search-param source route to / for report param normalization.
projects/packages/premium-analytics/package.json Adds link:packages/* deps so wp-build can resolve internal packages for the route bundle.
projects/packages/premium-analytics/changelog/add-pa-date-range-picker Changelog entry for the new dashboard date range picker.
pnpm-lock.yaml Lockfile updates for the new link dependencies.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment on lines +64 to +68
const range = useMemo( () => {
return {
from: effective.from ? localTZDate( effective.from ) : undefined,
to: effective.to ? localTZDate( effective.to ) : undefined,
};
Comment on lines +104 to +115
const onComparisonChange = useCallback(
( nextComparisonRange: DateRange | undefined, nextComparisonPresetId?: ComparisonPresetId ) => {
stage( {
compare_from: encodeDateToSearchParam( nextComparisonRange?.from ),
compare_to: encodeDateToSearchParam( nextComparisonRange?.to ),
compare_preset: nextComparisonPresetId ?? undefined,
comp: nextComparisonRange ? '1' : undefined,
} );

commit();
},
[ stage, commit ]
*/
stage( {
from: encodeDateToSearchParam( nextRange.from ),
to: encodeDateToSearchParam( endOfDay( nextRange.to ) ),
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

No summary data is available for parent commit d060b2d, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for d060b2d is available.

Full summary · PHP report · JS report

@Nikschavan Nikschavan marked this pull request as draft June 12, 2026 07:10
@nerrad nerrad force-pushed the update/pa-introduce-customize-dashboard branch from d060b2d to 5bb6dd9 Compare June 12, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants