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. Mu Wpcom plugin:
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 SummaryCoverage changed in 4 files.
2 files are newly checked for coverage.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
builds wordads/* with wp-build and registers the Ads section and widget types; module and mu-wpcom call it
b928f5d to
71a25d5
Compare
PA's internal packages join the workspace; the Ads package depends on them through aliases, with no ../ paths
widgets doc: translations per record and the Ads package as the real consumer; README extension entry point
71a25d5 to
74d24a7
Compare
|
All subtasks have been addressed. Closing this PR. |
Linear: WOOA7S-2183
Proposed changes
This is the umbrella pull request for a four-step stack that lets another plugin register widget types on the Premium Analytics dashboard, from its own build and with its own translations, and moves the first real widgets out of the package.
Each step is its own pull request, based on the previous one, and each carries
docs/dashboard-widgets.mdas it stands after that step. This umbrella stays open as the reference for the whole arc and for the decisions it records, and closes once the last step lands.The steps
Step 1: a registration moment (#52568, merged)
The widget type registry hydrates on its first read after
initand firesjetpack_premium_analytics_register_widget_typesonce. A plugin with awidgets/folder callsregister_widget_types_from_manifest()with the manifest wp-build generates.register_widget_type()is the primitive, andWIDGET_API_VERSIONis the contract a consumer checks before registering.Step 2: translations per record (#52634, merged)
Every widget module record says where its catalogs live, through
textdomainandi18n_manifest. The client loads each module's catalog under its own domain before importing it, whatever plugin built it.Step 3: the first real consumer (#52635)
A new
wordads-analyticspackage owns the Ads section and its three widgets. It builds them with wp-build against the dashboard's shared modules, which it depends on by name through workspace aliases. The WordAds module calls it outside WordPress.com, andjetpack-mu-wpcomcalls it on Simple and Atomic.Step 4: documentation (#52636)
The widgets and sections docs describe the contract after steps 2 and 3, and the README gains an entry point for extending the dashboard from another plugin.
Why
The sections stack (#52448) gave sections a registration moment, a helper and a first consumer. Widget types had the registry, the REST route and the import map, but no public registration and no moment a plugin could hook. The client loaded translations only for the package's own bundles, and nothing told a widget built against one toolkit version which package it landed on.
The rule is the one the sections follow: the package owns the dashboard, not the features. A section and its widgets belong to the code that knows the feature is there.
The first consumer is a package rather than the WordAds module because WordAds comes with Premium and higher on WordPress.com, where most sites are Simple and run no Jetpack module. A package vendored by both plugins serves the widgets everywhere the section exists.
How a plugin registers widget types
The plugin's build keeps
@jetpack-premium-analytics/*external (wpPlugin.externalNamespaces), so the shared modules resolve through the page import map to the single copy the dashboard registers. wp-build does that only when it finds each package installed under its name, so a plugin in this monorepo declares them through workspace aliases:📸 Screenshot placeholder: the page import map with the dashboard modules and a plugin's widget modules
Decisions recorded here
Global registration
Widget types register globally, like block types, with no provider field. The name's namespace and the text domain are the provenance.
Helper first
Like core's Abilities API,
register_widget_types_from_manifest()andregister_widget_type()write to the main registry, and the action hands the registry over for lookups.The version constant
WIDGET_API_VERSIONships with step 1. The core-shaped form,apiVersioninwidget.json, is an upstream ask.Translations per record
Translations travel with each record rather than with each build, because a record is what the client has when it imports.
Renamed widget types
The Ads widgets are
wordads/*. A layout persisted with the oldjpa/wordads-*names shows its tiles as unavailable until it is reset. Ads is outside the customer preview, so only internal sites carry such layouts.Dashboard context later
The widget-type reads take no dashboard argument yet. The route is global and the hook hangs off the package's page, and both can gain the argument later without breaking a consumer.
Dependencies by name
The dashboard's internal packages become workspace members where they are, so consumers depend on them by name instead of reaching into the package's folders. Package names must be
@automattic/*, so the module ids point to them through aliases. Moving them toprojects/js-packageslater keeps the same dependency lines.Follow-ups, outside this stack
The mirror repository
Automattic/jetpack-wordads-analyticsand its Packagist entry have to exist before step 3 merges.The moved widgets need stories and JS tests again, since theirs depended on the dashboard package's harness. Renamed widget types need an alias in persisted layouts, tracked in WOOA7S-2200.
The generated registration drops a widget's classic script dependencies, so a consumer widget relies on the dashboard page loading them.
A consumer outside the monorepo, such as a Store section owned by WooCommerce, needs the dashboard's JS API published, which means moving it to
projects/js-packages.A dashboard registry and per-dashboard persistence can wait for a second dashboard. The preview allow-list is still a list inside the package, and the owner of a section should hold that key.
Related product discussion/links
The sections stack this continues: #52448. Linear: WOOA7S-2183.
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Each step has its own. For the whole arc, use a connected site with the WordAds module active and the Ads section opened out of the preview scope:
GET /wp-json/wpcom/v2/widget-moduleslists the threewordads/*types, with modules underjetpack-wordads-analytics/widgets/and the text domainjetpack-wordads-analytics-pkg. The page import map carries those ids, and the Ads section renders the three widgets from the package's build.📸 Screenshot placeholder: the Ads section rendered from the package's build