Skip to content

Premium Analytics: update widget packages and promote in-body controls to widget attributes - #50271

Merged
chihsuan merged 34 commits into
trunkfrom
update/premium-analytics-widget-packages
Jul 8, 2026
Merged

Premium Analytics: update widget packages and promote in-body controls to widget attributes#50271
chihsuan merged 34 commits into
trunkfrom
update/premium-analytics-widget-packages

Conversation

@retrofox

@retrofox retrofox commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Closes WOOA7S-1667

What

Updates Premium Analytics to the current @wordpress/widget-primitives / @wordpress/widget-dashboard / @wordpress/build development snapshots and migrates the widgets to the attribute model those versions introduce:

  • In-body selectors are replaced with high-relevance widget attributes rendered by the widget host

    • locations view mode (geoGranularity)
    • top platforms mode (platformDimension)
    • UTM Insights param (utmDimension)
    • Emails metric (metric)
    • and the Group by selectors in the Subscribers and Traffic charts (granularity).
  • Commerce widgets declare presentation: framed in widget.json.

  • Widget attribute shapes are typed and exported once from widget.ts
    Render components compose host fields (ReportParamsFieldAttributes) instead of re-declaring them, and the widget-audit rule covers the new conventions.

  • Package pins
    widget-primitives / widget-dashboard 0.3.1-next.v.202607070741.0 and build 0.19.1-next.v.202607070741.0 in the package root; unit manifests (routes and widgets) keep declaring the 0.2.0 stable floor.

  • Bundled deps needed by the new stack
    Scoped to this package: admin-ui 2.5.0, dataviews 17.1.0, icons ^15, theme / ui 0.17.0, plus the design-token migration to the renamed @wordpress/theme 0.17 groups (fgforeground, bgbackground). PA's tokens are ahead of the repo-wide token list, so a scoped override in the shared stylelint base config exempts projects/packages/premium-analytics/** from the plugin-wpds/no-unknown-ds-tokens rule; tools/js-tools keeps its @wordpress/theme on the repo's stable 0.15.1, so every other project lints unchanged.

  • Carries the @wordpress/dataviews/wp pnpmfile rework from the renovate group branch, which dataviews 17 requires.

Why

The widget features this migration relies on (high-relevance attributes with DataViews-compatible types, framed presentation, render-attribute composition) exist today only in Gutenberg trunk.

They are published as development snapshots (-next.v.<timestamp>), so the team can build on them now instead of waiting for the next stable release cycle.

The versioning strategy is deliberate:

  • Now:
    Pin the published snapshots, exact versions, scoped to premium-analytics only.
    Installs are reproducible from npm for every developer and CI.

  • While on snapshots
    Newer trunk features are adopted by publishing a fresh development release and bumping the three pins together (same timestamp, so their transitive -next dependencies resolve to a single tree).

  • Exit: automatic.
    Once stable releases ship with these changes (widget-* ≥ 0.3.1, build ≥ 0.19.1), the Bundled @wordpress/* monorepo renovate group proposes them, since a stable release always supersedes a prerelease pin.
    Renovate never downgrades the pins to older stables and never moves other projects onto the snapshots.

Other consumers of @wordpress/build (backup, forms, jetpack-mu-wpcom, newsletter, podcast, publicize, scan, seo, videopress, wp-build-polyfills) are unaffected: each project pins its own version and keeps building with it.

How

  • Every in-body SelectControl replaced by an attribute is declared in widget.ts with relevance: 'high' and a DataViews-compatible text type, so the host renders the control and persists the value.

  • render.tsx components default attributes and pass them through <WidgetRoot>, composing the widget's own attribute type with Partial<ReportParamsFieldAttributes>.

  • The dependency bumps mirror the pending Bundled @wordpress/* monorepo renovate group, applied only within premium-analytics so this package can move ahead of the repo-wide update.

  • Mid-branch commits temporarily linked a local Gutenberg checkout; the final commit replaces those links with the published snapshots and regenerates the lockfile, so the diff only ever ships registry versions.

Testing

  1. Install dependencies — the lockfile applies cleanly (CI validates it with a frozen install):
nvm use
pnpm install
  1. Build the package and its monorepo dependencies:
jetpack build --deps packages/premium-analytics
  1. Open the Premium Analytics dashboard in wp-admin and confirm it loads without console or PHP errors.

  2. Locations, Top platforms, UTM Insights, Emails, Subscribers chart, and Traffic chart: the old in-body selectors are gone; the equivalent controls now appear as widget attributes on the widget host, and switching them updates the widget data.

Screen.Recording.2026-07-07.at.10.50.00.AM.mov
  1. Date range and comparison state still reach the widgets (Subscribers list reflects the picker).

  2. Storybook — the widget stories render with the dashboard controls:

cd projects/js-packages/storybook
pnpm run storybook

Verifying that each project keeps its own package versions

The snapshot pins are scoped to premium-analytics; every other consumer of @wordpress/build keeps building with its own pinned version. Three checks, from declared to executed.

Declared — what each project pins in git:

git grep -n '"@wordpress/build"' -- '*package.json'
projects/packages/backup/package.json:72:		"@wordpress/build": "0.16.1",
projects/packages/forms/package.json:116:		"@wordpress/build": "0.16.1",
projects/packages/premium-analytics/package.json:94:		"@wordpress/build": "0.19.1-next.v.202607070741.0",
projects/packages/videopress/package.json:94:		"@wordpress/build": "0.16.1",
…

Installed — the copy pnpm materialized in each project's node_modules:

node -p "require('./projects/packages/forms/node_modules/@wordpress/build/package.json').version"
node -p "require('./projects/packages/premium-analytics/node_modules/@wordpress/build/package.json').version"
node -p "require('./projects/packages/premium-analytics/node_modules/@wordpress/widget-primitives/package.json').version"
0.16.1
0.19.1-next.v.202607070741.0+a51d59513
0.3.1-next.v.202607070741.0+a51d59513

The +a51d59513 build metadata identifies the Gutenberg trunk commit the snapshots were published from — the three pinned packages come from the same commit.

Executedpnpm exec resolves the binary from the current project's node_modules, so each build runs its own pinned copy:

cd projects/packages/forms && pnpm exec wp-build
cd projects/packages/premium-analytics && pnpm exec wp-build
🎉 All packages built successfully! (1492ms total)
🎉 All packages built successfully! (4921ms total)

The lockfile is validated with a frozen install in CI, so these resolutions cannot drift silently.

Follow-ups

  • Return widget-primitives / widget-dashboard / build to stable pins via the Bundled @wordpress/* monorepo renovate PR once stables ship with these changes.
  • Remove the scoped no-unknown-ds-tokens exemption for premium-analytics (and bump tools/js-tools back to @wordpress/theme 0.17) once the repo-wide token renames land, so PA's tokens are validated again.
  • The repo-wide 0.17 stack update (with the Forms/VideoPress compat fixes and the WPDS token renames for other projects) lands separately in Update Bundled @wordpress/* monorepo #49272; if repo-wide stylelint flags legacy token names in projects this PR doesn't touch, they are covered there.

retrofox and others added 22 commits July 7, 2026 09:19
routes and widgets metadata now declare stable 0.2.0 instead of next snapshots
fg->foreground, bg->background; replace removed base and invalid names
lint token list must match the renamed design token groups
temporary wiring until a new next snapshot is published
geoGranularity field (relevance high) replaces the inline SelectControl
WidgetAttributeField casts, exported attribute types, single typed param tags
platformDimension field (relevance high) replaces the inline SelectControl
the content class was removed from the css with the inline select
single typed tag with field docs on the type; widget-audit rule extended
There's now an indirect dep, sigh.
admin-ui 2.5.0, dataviews 17.1.0, icons ^15, theme/ui 0.17.0 from the bundled renovate group
…mension attribute

The UTM dimension is now a widget attribute with elements and relevance: 'high',
so the widget host renders the control (same pattern as Locations and Top
Platforms). Drops the in-body SelectControl, local state, and setAttributes
wiring; renames the attribute from utmParam to utmDimension (the data-layer
useStatsUtm arg keeps its endpoint-oriented name).

Co-authored-by: Cursor <cursoragent@cursor.com>
The widget root already provides the column flex layout and, via its
container-type, acts as containing block for the absolutely positioned
loading overlay — same layout approach as Top Platforms. The chart takes
the remaining space through a .leaderboard class instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
… metric attribute

The open/click rate switch is now a `metric` widget attribute with elements
and relevance: 'high', so the widget host renders the control (same pattern
as Locations, Top Platforms, and UTM Insights). This makes the whole custom
header workaround unnecessary: the widget moves from full-bleed back to
framed presentation, dropping the hand-rolled title row, the in-body
SelectControl with its local state, and the header/select CSS.

Co-authored-by: Cursor <cursoragent@cursor.com>
…nce granularity attribute

The bucket-size switch is now a `granularity` widget attribute with elements
and relevance: 'high', so the widget host renders the control (same pattern
as the other converted widgets). An `auto` option replaces the previous
local-state null: it keeps following the dashboard range until the user picks
an explicit granularity, which then persists per widget instance. Drops the
SelectControl in the MetricTabsChart controls slot and its local state.

Co-authored-by: Cursor <cursoragent@cursor.com>
…granularity attribute

The bucket-size switch is now a `granularity` widget attribute with elements
and relevance: 'high', so the widget host renders the control (same pattern
as subscribers-chart). An `auto` option replaces the previous local-state
null override. Drops the SelectControl in the MetricTabsChart controls slot.

Co-authored-by: Cursor <cursoragent@cursor.com>
…h-relevance attributes

Replace attribute type 'string' with 'text' in locations, top-platforms,
utm-insights, and emails so the WidgetAttributeField cast matches FieldTypeName.

Co-authored-by: Cursor <cursoragent@cursor.com>
…dget.json

Add the missing presentation field to 29 WooCommerce and commerce widget
manifests so the widget host renders the standard card chrome.

Co-authored-by: Cursor <cursoragent@cursor.com>
…e imports

Remove unused @wordpress/components, @wordpress/ui, date-fns, and react
entries left over from refactors; add missing @wordpress/element where
hooks import it. Scans each widget's non-story source files, not stories.

Co-authored-by: Cursor <cursoragent@cursor.com>
Align with the widget contract so injected attributes reach WidgetRoot,
matching the other Stats widgets even though this widget does not use
reportParams.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ributes

Fixes the WidgetRoot attributes pass for TypeScript: host attributes may
include reportParams even though this widget ignores the date range.

Co-authored-by: Cursor <cursoragent@cursor.com>
wp-build 0.19.1-next, widget-* 0.3.1-next replace the local gutenberg links
@retrofox
retrofox requested review from a team as code owners July 7, 2026 09:53
@retrofox retrofox self-assigned this Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 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 update/premium-analytics-widget-packages branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/premium-analytics-widget-packages
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/premium-analytics-widget-packages

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

github-actions Bot commented Jul 7, 2026

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 🤖


🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so:

## Testing instructions:

* Go to '..'
*

🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

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

My PR adds *x* and *y*.

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!

@jp-launch-control

jp-launch-control Bot commented Jul 7, 2026

Copy link
Copy Markdown

Code Coverage Summary

This 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. 🤷

Full summary · PHP report · JS report

retrofox added 7 commits July 7, 2026 11:14
PA uses theme 0.17 token names ahead of the repo; the rename ships with the bundled renovate group
restore brace-expansion for minimatch; changelog now describes -next pins
remove dropped onGridSettingsChange, exempt icons from token lint, fix comma
Host owns identity; drop custom in-widget title, keep year stepper as body chrome.
Stylelint disables rules with null, not false; the invalid false value aborted the pre-commit linter on any CSS commit.
dognose24 and others added 5 commits July 7, 2026 21:27
…ve-trunk

# Conflicts:
#	pnpm-lock.yaml
#	projects/packages/premium-analytics/package.json
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-empty-state/stories/chart-empty-state.stories.tsx
#	projects/packages/premium-analytics/widgets/all-time-stats/package.json
#	projects/packages/premium-analytics/widgets/annual-highlights/package.json
#	projects/packages/premium-analytics/widgets/authors/package.json
#	projects/packages/premium-analytics/widgets/average-items-per-order/package.json
#	projects/packages/premium-analytics/widgets/average-order-value/package.json
#	projects/packages/premium-analytics/widgets/bookings-by-device/package.json
#	projects/packages/premium-analytics/widgets/bookings-by-status/package.json
#	projects/packages/premium-analytics/widgets/bookings-over-time/package.json
#	projects/packages/premium-analytics/widgets/bookings-revenue-by-customer-type/package.json
#	projects/packages/premium-analytics/widgets/clicks/package.json
#	projects/packages/premium-analytics/widgets/conversion-rate/package.json
#	projects/packages/premium-analytics/widgets/coupon-usage-over-time/package.json
#	projects/packages/premium-analytics/widgets/devices/package.json
#	projects/packages/premium-analytics/widgets/emails/package.json
#	projects/packages/premium-analytics/widgets/file-downloads/package.json
#	projects/packages/premium-analytics/widgets/gross-sales-over-time/package.json
#	projects/packages/premium-analytics/widgets/hello-world/package.json
#	projects/packages/premium-analytics/widgets/latest-post/package.json
#	projects/packages/premium-analytics/widgets/locations/package.json
#	projects/packages/premium-analytics/widgets/most-popular-day/package.json
#	projects/packages/premium-analytics/widgets/most-popular-time/package.json
#	projects/packages/premium-analytics/widgets/net-sales-over-time/package.json
#	projects/packages/premium-analytics/widgets/new-vs-returning-customer/package.json
#	projects/packages/premium-analytics/widgets/orders-fulfillment/package.json
#	projects/packages/premium-analytics/widgets/orders-over-time/package.json
#	projects/packages/premium-analytics/widgets/payment-status/package.json
#	projects/packages/premium-analytics/widgets/posting-activity/package.json
#	projects/packages/premium-analytics/widgets/react-query-dev-tool/package.json
#	projects/packages/premium-analytics/widgets/revenue-by-customer-type/package.json
#	projects/packages/premium-analytics/widgets/sales-by-coupon-usage/package.json
#	projects/packages/premium-analytics/widgets/sales-by-coupon/package.json
#	projects/packages/premium-analytics/widgets/sales-by-device/package.json
#	projects/packages/premium-analytics/widgets/sales-by-utm-campaign/package.json
#	projects/packages/premium-analytics/widgets/sales-by-utm-channel/package.json
#	projects/packages/premium-analytics/widgets/sales-by-utm-source/package.json
#	projects/packages/premium-analytics/widgets/search-terms/package.json
#	projects/packages/premium-analytics/widgets/sessions-by-device/package.json
#	projects/packages/premium-analytics/widgets/store-conversion-rate-bookings/package.json
#	projects/packages/premium-analytics/widgets/subscribers-chart/package.json
#	projects/packages/premium-analytics/widgets/subscribers-list/package.json
#	projects/packages/premium-analytics/widgets/top-performing-bookings/package.json
#	projects/packages/premium-analytics/widgets/top-performing-products/package.json
#	projects/packages/premium-analytics/widgets/top-platforms/package.json
#	projects/packages/premium-analytics/widgets/top-posts/package.json
#	projects/packages/premium-analytics/widgets/total-returns/package.json
#	projects/packages/premium-analytics/widgets/total-sales-over-time/package.json
#	projects/packages/premium-analytics/widgets/traffic-chart/package.json
#	projects/packages/premium-analytics/widgets/utm-insights/package.json
#	projects/packages/premium-analytics/widgets/videos/package.json
#	projects/packages/premium-analytics/widgets/visitors-by-location/package.json
#	projects/packages/premium-analytics/widgets/visitors-over-time/package.json
trunk theme 0.17 validates PA tokens; fix store-performance fg->foreground (matches #50277)
@retrofox retrofox added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jul 7, 2026
@github-actions github-actions Bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Jul 7, 2026

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tested well and looks good to me.

Approving. I'm going to go ahead and merge this so we can keep moving on the other tasks. Thanks @retrofox! 🚀

@chihsuan
chihsuan merged commit e52d540 into trunk Jul 8, 2026
97 of 98 checks passed
@chihsuan
chihsuan deleted the update/premium-analytics-widget-packages branch July 8, 2026 02:18
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 8, 2026
@retrofox

retrofox commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Approving. I'm going to go ahead and merge this

Thanks, Chi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs [Package] Premium Analytics [Status] UI Changes Add this to PRs that change the UI so documentation can be updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants