Repository navigation
Conversation
wordads earnings and stats as a table; mechanics come from the package
|
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: 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. |
Fixes WOOA7S-2275
Proposed changes
Third consumer of connection's
Proxy_Controller(#53098), after VideoPress (#52941): the Ads package gets its own route for the WordPress.com endpoints its widgets read, so the data of the Ads section can leave the dashboard's proxy.The three Ads widgets read
wordads/earningsandwordads/statsthrough/jetpack-premium-analytics/v1/proxy/v1.1/wordads/.... This PR gives the package the same kind of route, so a client moves from one to the other by changing the base of the URL: same WordPress.com endpoint, same query params, same response.What Ads declares
Api_Proxy_Controlleris a table and two hooks. The table exposeswordads/earningsandwordads/statsonmanage_options, the capability the dashboard asks for the Ads section (Capabilities::current_user_can_view_ad_reports()). The dashboard's ownwordadsgroup namesactivate_wordads, which no code grants, so admins-only is what it already enforces.Analytics_Dashboard::init()hooksApi_Proxy_Controller::init()onrest_api_initat priority 0, as class-name callbacks, so the package class loads on REST requests only, and the cache prefix onjetpack_stats_transient_cleanup_prefixes, where cron can see it. Simple is skipped: it runs no Jetpack plugin and holds no blog token, and its clients reach WordPress.com directly. Atomic gets the route through the sameinit(), called by jetpack-mu-wpcom.Allowlist, capability check, blog-signed forward, five-minute cache,
force_refreshand the error shapes come from connection and are tested there. The Ads tests cover what the table declares and nothing the package already tests: which endpoints route, who reads them, and the cache prefix.What does not change
No client calls the new route yet: the widgets move to it when the SDK exposes the host query engine (WOOA7S-2230), as the Top videos widget does. The dashboard keeps its
wordadsgroup until then.Related product discussion/links
Linear: WOOA7S-2247. Stacked on #53098.
Does this pull request change what data or activity we track or use?
No.
Testing instructions
jp test php packages/adsOn a site connected to WordPress.com with the WordAds module active and the dashboard built, open any wp-admin page that loads
wp.apiFetchand run in the browser console:/jetpack-premium-analytics/v1/proxy/v1.1/wordads/earnings./jetpack/v4/wordads/proxy/v1.1/wordads/stats?unit=day&quantity=7resolves with the daily stats./jetpack/v4/wordads/proxy/v1.1/wordads/settingsis rejected withrest_no_route.For the cache, run the first request twice and list the transients:
wp transient list --search='jetpack_wordads_proxy_*'One entry per distinct query. Adding
force_refresh=1to the query creates none.