Skip to content

Premium Analytics: drop the widget modules that carry nothing live - #53833

Merged
retrofox merged 33 commits into
trunkfrom
refactor/record-only-widgets
Oct 20, 2026
Merged

retrofox merged 33 commits into
trunkfrom
refactor/record-only-widgets

Conversation

@retrofox

@retrofox retrofox commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Part of WOOA7S-2174 (task D4).

Builds on #53778, now on trunk.

Proposed changes

Fifty-seven widgets ship without a widget.ts

Their module exported {}, or attributes: [] with an empty example, which is what the dashboard builds from the record alone: useWidgetTypes has a branch for a record without widget_module, wp-build marks the folder has_widget: false, the generated manifest leaves widget_module null, and the i18n lane skips the metadata bundle while still installing the render catalog.

Twenty-nine Premium Analytics widgets and twenty-eight WooCommerce Stats widgets lose their module. The 23 that keep one carry either attribute behavior JSON cannot express (computed elements or values, a helper-built field) or an example, which the build does not read from widget.json yet. Their static attributes move to widget.json in a follow-up.

The attribute type moves into render.tsx

render.tsx imported the widget's own shape from the module and composed the render-only type over it. Without a module, the shape is declared, and exported, in render.tsx, where stories and tests import it. All-time stats takes its metrics table along; the render catalog is installed before the module imports, so the labels translate as before.

Stories pass the manifest alone

createStoryWidgetType() takes the module as an optional second argument; the 28 stories of widgets without one drop the import. The all-time stats suite loses the test that asserted the module's empty attribute list.

Docs

.agents/rules/widgets.md and AGENTS.md state the split: an attribute is declared in widget.json whenever its field is static, and widget.ts carries only what JSON cannot express, plus example until it can move too. They describe widget.ts as optional and say where the attribute type lives in each case.

Not in this PR: the 18 modules whose example seeds inserted instances (chartType: 'bar', metric: 'opens', …) stay until example can be declared in widget.json.

Related product discussion/links

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

No.

Testing instructions

Build with dependencies

jetpack build --deps packages/premium-analytics
jetpack build packages/woocommerce-stats

GET /wp-json/wpcom/v2/widget-modules

The 57 records carry widget_module: null and keep their attributes, title and icon.

Screenshot 2026-10-20 at 10 43 46 AM

On the dashboard

Every section renders as before, and the inserter offers the same widgets with the same titles and icons. The WooCommerce chart widgets keep their line/bar toggle, whose attribute lives in widget.json.

Storybook

The WidgetDashboardWithWidget story of a widget without a module (Tags, Referrers, Total views, …) renders the widget inside the dashboard.

Tests

pnpm run test --testPathPatterns=tests/groups/widgets- in projects/packages/premium-analytics, and pnpm run test in projects/packages/woocommerce-stats.

retrofox and others added 30 commits October 19, 2026 09:02
jpa/toggle-group takes jpa/<name> icons; drops the chart-line copies
mirrors gutenberg#82485; an element keeps its icon reference
…type-attribute-json

# Conflicts:
#	projects/packages/premium-analytics/docs/dashboard-widgets.md
the module keeps only what JSON cannot carry; CHART_TYPE_ELEMENTS goes
the manifest orders the settings; a module-only one is listed by id
…-attributes-registry

Co-authored-by: louwie17 <lourensschep@gmail.com>
mirrors gutenberg#82485; an element keeps its icon reference
…-attributes-registry

Co-authored-by: louwie17 <lourensschep@gmail.com>
…stry' into update/chart-type-attribute-json

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

# Conflicts:
#	projects/packages/premium-analytics/docs/dashboard-widgets.md
…tribute-json

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

# Conflicts:
#	projects/packages/premium-analytics/docs/dashboard-widgets.md
…icon-references

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

# Conflicts:
#	projects/packages/premium-analytics/docs/dashboard-widgets.md
the icon-reference form ships with the field alone; widgets move to widget.json in the follow-up, and the contract takes 1.15.0 after the registry landed at 1.14.0
…e-attribute-json

# Conflicts:
#	projects/packages/ads/widgets/wordads-chart-tabs/widget.ts
#	projects/packages/premium-analytics/docs/dashboard-widgets.md
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/helpers/chart-display-attribute-fields.ts
#	projects/packages/woocommerce-stats/widgets/average-items-per-order/widget.ts
#	projects/packages/woocommerce-stats/widgets/average-order-value/widget.ts
#	projects/packages/woocommerce-stats/widgets/bookings-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/gross-sales-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/net-sales-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/orders-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/total-sales-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/visitors-over-time/widget.ts
…type-attribute-json

# Conflicts:
#	projects/packages/premium-analytics/packages/fields/src/field-toggle-group/__tests__/toggle-group-field.test.tsx
#	projects/packages/premium-analytics/packages/fields/src/field-toggle-group/stories/toggle-group-field.stories.tsx
@github-actions

github-actions Bot commented Oct 20, 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), and enable the refactor/record-only-widgets branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack refactor/record-only-widgets

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!

@jp-launch-control

jp-launch-control Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/widgets/all-time-stats/render.tsx 9/9 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

Base automatically changed from update/chart-type-attribute-json to trunk October 20, 2026 09:21
…-widgets

# Conflicts:
#	projects/packages/premium-analytics/widgets/stories/create-story-widget-type.ts
#	projects/packages/woocommerce-stats/widgets/average-items-per-order/widget.ts
#	projects/packages/woocommerce-stats/widgets/average-order-value/widget.ts
#	projects/packages/woocommerce-stats/widgets/bookings-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/gross-sales-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/net-sales-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/orders-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/total-sales-over-time/widget.ts
#	projects/packages/woocommerce-stats/widgets/visitors-over-time/widget.ts
@retrofox retrofox added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Oct 20, 2026
@retrofox
retrofox marked this pull request as ready for review October 20, 2026 09:46
@retrofox
retrofox requested a review from a team as a code owner October 20, 2026 09:46
louwie17
louwie17 previously approved these changes Oct 20, 2026

@louwie17 louwie17 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.

Thanks @retrofox, this tested well and code looks good! I checked all the tabs and the inserter on my local Docker site, plus the line/bar toggle on the Woo chart widgets, and everything rendered the same as before.

I did leave two small inline comments on the docs, neither is a blocker and both can be a quick fix before merging or a follow up. LGTM 🚀

but it must not re-declare the widget's own attributes. A widget with no own attributes
The widget's own attribute shape is declared and exported once: in `widget.ts` when the widget
has one, alongside the `attributes`/`example` schema it describes, and imported by `render.tsx`;
otherwise in `render.tsx` itself, where stories and tests import it. `render.tsx` may compose a

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.

A small nitpick, none of the stories or tests import these types right now, they all only import the default component. Maybe we can drop the "where stories and tests import it" part, or drop the export on the types until something needs them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, nothing imports them yet. Dropped the claim and kept the export: a type export costs nothing and keeps the name reachable for a story or test. Pushed to #53840 (4aebf0a) so this diff stays as reviewed.

Co-authored-by: louwie17 <lourensschep@gmail.com>
@retrofox
retrofox merged commit fa6fe58 into trunk Oct 20, 2026
106 of 110 checks passed
@retrofox
retrofox deleted the refactor/record-only-widgets branch October 20, 2026 11:22
@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] In Progress [Status] Needs Review This PR is ready for review. labels Oct 20, 2026
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.

2 participants