Skip to content

Premium Analytics: gate the video surfaces on VideoPress availability - #51243

Merged
chihsuan merged 6 commits into
trunkfrom
change/gate-videos-on-videopress
Aug 18, 2026
Merged

chihsuan merged 6 commits into
trunkfrom
change/gate-videos-on-videopress

Conversation

@chihsuan

@chihsuan chihsuan commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Fixes WOOA7S-1718

Proposed changes

  • Hide the Top videos widget, the Videos report, and the video detail page on sites without VideoPress — Calypso Stats gates its Videos module the same way, and this was the last video surface still shown unconditionally.
  • Add is_videopress_available(): the videopress plan feature on the WPCOM platform, Simple and Atomic alike (what Calypso reads), the Jetpack VideoPress module or the standalone VideoPress plugin everywhere else, all behind a jetpack_premium_analytics_videopress_available filter.
  • Publish the result as premium_analytics.has_videopress script data so the client routes can read it. The client can't use siteHasFeature( 'videopress' ) from @automattic/jetpack-script-data here: site.plan.features is only populated when the Publicize package is loaded, which the standalone Premium Analytics plugin never loads.
  • Widget-level gating reuses the existing support-context policy, so both the widget registry and the default layout pick it up — the same shape as the File downloads gate in Premium Analytics: show File downloads only on WPCOM Simple sites #50732.
  • Preserve saved layouts. A previously saved Top videos widget remains as a removable unavailable widget rather than silently rewriting the user's preferences.

Atomic is deliberately grouped with Simple rather than with self-hosted: wpcom_site_has_feature() is available there through wpcomsh, the VideoPress module carries no Auto Activate header, so a plan that includes VideoPress routinely comes with the module off. Initial_State::has_videopress_access() in the VideoPress package draws the same boundary.

Current_Plan::supports( 'videopress' ) is not used as the single entry point. On the WPCOM platform it already delegates to the same wpcom_site_has_feature() call, but off-platform it falls back to returning true for every plan because of the VideoPress free tier.

Related product discussion/links

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

No.

Testing instructions

On a self-hosted Jetpack site with Premium Analytics, with VideoPress off wp jetpack module deactivate videopress:

  • Reset the Traffic layout. Confirm the "Top videos" widget is absent from the default dashboard and is not offered in the widget picker.
  • If the site has a layout saved before this branch with Top videos, confirm it appears as a removable unavailable widget. Enter Customize mode and remove it.
  • Go to /reports/videos directly — it redirects to the dashboard, as an unknown report does.
  • Go to a video detail URL directly (/video/<attachment id>) — it redirects to the dashboard.
Screen.Recording.2026-08-14.at.6.11.11.PM.mov

Then activate VideoPress (wp jetpack module activate videopress, or the standalone Jetpack VideoPress plugin) and reload:

  • "Top videos" is back in the default layout, /reports/videos loads, and a video row still drills into the detail page.
Screen.Recording.2026-08-14.at.6.12.43.PM.mov

On WordPress.com Simple and Atomic the gate follows the videopress plan feature instead, matching Calypso.

@github-actions

github-actions Bot commented Aug 13, 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 change/gate-videos-on-videopress branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack change/gate-videos-on-videopress
bin/jetpack-downloader test jetpack-mu-wpcom-plugin change/gate-videos-on-videopress

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 Aug 13, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/src/widget-type-support.php 23/25 (92.00%) -8.00% 2 ❤️‍🩹
projects/packages/premium-analytics/src/class-analytics.php 119/138 (86.23%) -0.43% 1 ❤️‍🩹
projects/packages/premium-analytics/routes/site-readiness.ts 3/3 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/routes/video-detail/route.ts 20/20 (100.00%) 0.00% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/premium-analytics/src/videopress-availability.php 10/10 (100.00%) 💚

Full summary · PHP report · JS report

@chihsuan
chihsuan marked this pull request as ready for review August 14, 2026 09:32
@chihsuan
chihsuan requested a review from a team as a code owner August 14, 2026 09:32
@chihsuan chihsuan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Aug 14, 2026
* never looks at the module and counts the paid storage tiers instead.
*
* `Current_Plan::supports( 'videopress' )` is avoided because off-platform it
* returns true for every plan, thanks to the VideoPress free tier.

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.

Non-blocking; nothing in the logic needs to change. One ask: on the is_videopress_available() docblock.

The off-platform branch is VideoPress\Status::is_active(), the same two signals and the gate four places in the VideoPress package already use. The platform branch is the WPCOM hijack inside Current_Plan::supports(). Neither is reachable: jetpack-plans and jetpack-videopress aren't in this package's dependency graph, so local detection is the only option today.

The docblock rules out Current_Plan::supports() on semantic grounds, which is right, but doesn't mention Status::is_active(), which is semantically this branch and only out of reach. Worth naming it plus the boundary, so the next person finds the trail instead of writing a fifth detector.

Also worth stating: the platform branch never fires on Atomic, since wpcomsh grants videopress to WPCOM_BUSINESS_AND_HIGHER_PLANS and WoA only exists there. I don't think that's wrong (hosting is service-level on WPCOM, so the module is a false negative), but the effective coverage is Simple plus self-hosted, and an Atomic site with the module off and no videos keeps both empty surfaces.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch. I've named it in the docblock along with why it's out of reach.

retrofox
retrofox previously approved these changes Aug 17, 2026

@retrofox retrofox 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, Chi 🙇‍♂️

Approving. It solves the immediate problem, the tests are thorough, and it follows the gating pattern the package already established for File downloads, Shares, and the Subscribers section.

Same note I left on #50736, though. This is the third instance: structurally, I don't think this scales, and it's getting harder, not easier.
Each gate adds another foreign domain PA has to know how to detect, and the canonical answer usually already exists in the package that owns that domain, out of PA's reach.

Nothing to resolve in this PR. I'd like to follow up separately on the model I think we should move to.

// WooCommerce stubs for the TEMPORARY interim sync module port (WOOA7S-1550).
// WooCommerce is a runtime, not composer, dependency; these let Phan resolve WC symbols.
'+stubs' => array( 'woocommerce', 'woocommerce-internal' ),
// The wpcom stubs cover the Simple-only symbols this package branches on.

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.

Small thing: the symbol doesn't come from the generated wpcom stubs; it arrives because the wpcom stub set also pulls in wpcomsh's functions-wpcom-features.php (.phan/config.base.php:116).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed

* Defaults to false, unlike the sibling `csv_exports_enabled` flag: showing the
* video surfaces on a site that cannot produce play data is the empty report
* this gate exists to remove. Safe to default that way because every path that
* renders the dashboard runs `Analytics::load_dashboard_surface()`, which is

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.

load_dashboard_surface() calls it, but the filter is registered in load_dashboard_components(). Worth pointing to the one that does the injecting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed

@chihsuan

Copy link
Copy Markdown
Member Author

Approving. It solves the immediate problem, the tests are thorough, and it follows the gating pattern the package already established for File downloads, Shares, and the Subscribers section.

Thanks!

Same note I left on #50736, though. This is the third instance: structurally, I don't think this scales, and it's getting harder, not easier. Each gate adds another foreign domain PA has to know how to detect, and the canonical answer usually already exists in the package that owns that domain, out of PA's reach.

Fair concern! Opened WOOA7S-1958 to track the model.

@chihsuan
chihsuan merged commit 5620dd6 into trunk Aug 18, 2026
84 checks passed
@chihsuan
chihsuan deleted the change/gate-videos-on-videopress branch August 18, 2026 06:56
@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 Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants