Skip to content

PA - VideoPress: register the video stats proxy on connection's Proxy_Controller - #52941

Draft
retrofox wants to merge 1 commit into
trunkfrom
update/videopress-wpcom-proxy
Draft

retrofox wants to merge 1 commit into
trunkfrom
update/videopress-wpcom-proxy

Conversation

@retrofox

@retrofox retrofox commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes WOOA7S-2231

Proposed changes

Second consumer of connection's Proxy_Controller (#53098), and the first step of VideoPress stage 2 (WOOA7S-2234): the package serves the data of its dashboard widgets from its own route, so it does not depend on the analytics dashboard for transport.

The Top videos widget reads stats/video-plays through the dashboard's proxy, /jetpack-premium-analytics/v1/proxy/v1.1/stats/video-plays. This PR gives VideoPress 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 VideoPress declares

Api_Proxy_Controller is a table and two hooks. The table exposes stats/video-plays and stats/video/<id> on view_stats, with manage_options always accepted. init() runs on rest_api_init and builds the package's Proxy_Controller for /jetpack/v4/videopress/proxy/v<version>/<endpoint>, so the package class loads on REST requests only. The cache prefix joins jetpack_stats_transient_cleanup_prefixes from the Initializer, where cron can see it.

Allowlist, capability check, blog-signed forward, five-minute cache, force_refresh and the error shapes come from connection and are tested there. The VideoPress 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

The existing /jetpack/v4/videopress/stats/video-plays route and the Overview screen that reads it. No client calls the new route yet: the widget moves to it in a later step (WOOA7S-2233).

Sites without the Stats module

The proxy forces no flags. On a site without the Stats module, stats/video-plays needs check_stats_module=false in the query. stats/video/<id> does not read that flag on WordPress.com, so it answers 404 there.

Related product discussion/links

Linear: WOOA7S-2247 for the package, WOOA7S-2234 for the stage, WOOA7S-2231 for this step. Stacked on #53098.

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

No.

Testing instructions

jp test php packages/videopress

On a site connected to WordPress.com, with VideoPress active and some video plays, open the VideoPress dashboard and run in the browser console:

wp.apiFetch( {
	path: '/jetpack/v4/videopress/proxy/v1.1/stats/video-plays?period=day&num=7',
} ).then( console.log );
  • It resolves with the days of the last seven days.
  • With the analytics dashboard active, the same query on /jetpack-premium-analytics/v1/proxy/v1.1/stats/video-plays resolves with the same payload.
  • /jetpack/v4/videopress/proxy/v1.1/stats/video/<attachment id>?statType=all&period=day&num=7 resolves with the fields and data of that video.
  • /jetpack/v4/videopress/proxy/v1.1/stats/top-posts is rejected with rest_no_route.

For the cache, run the first request twice and list the transients:

wp transient list --search='jetpack_videopress_proxy_*'

One entry per distinct query. Adding force_refresh=1 to the query creates none.

For the capability, repeat the first request as a user who holds view_stats and is not an administrator: it resolves. As a user who holds neither, it is rejected with a 403.

cached, blog-signed forward for the video stats endpoints
@retrofox retrofox added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress labels Sep 29, 2026
@retrofox retrofox self-assigned this Sep 29, 2026
@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!

@github-actions

github-actions Bot commented Sep 29, 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 update/videopress-wpcom-proxy branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/videopress-wpcom-proxy

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

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/videopress/src/class-initializer.php 485/542 (89.48%) 0.04% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/videopress/src/class-api-proxy-controller.php 89/89 (100.00%) 💚

Full summary · PHP report · JS report

@retrofox retrofox changed the title PA - VideoPress: add a WordPress.com proxy route to the package PA - VideoPress: register the video stats proxy on jetpack-wpcom-proxy Oct 2, 2026
@retrofox retrofox changed the title PA - VideoPress: register the video stats proxy on jetpack-wpcom-proxy PA - VideoPress: register the video stats proxy on connection's Proxy_Controller Oct 2, 2026

This branch has not been deployed

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

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Package] VideoPress [Status] In Progress [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant