Skip to content

Premium Analytics: show File downloads only on WPCOM Simple sites#50732

Open
chihsuan wants to merge 1 commit into
trunkfrom
add/wooa7s-1717-hide-file-downloads-on-self-hosted
Open

Premium Analytics: show File downloads only on WPCOM Simple sites#50732
chihsuan wants to merge 1 commit into
trunkfrom
add/wooa7s-1717-hide-file-downloads-on-self-hosted

Conversation

@chihsuan

@chihsuan chihsuan commented Jul 22, 2026

Copy link
Copy Markdown
Member

Fixes WOOA7S-1717
Fixes WOOA7S-1709

Proposed changes

File download tracking is provided only for WordPress.com Simple sites. The endpoint returns 404 elsewhere, but Premium Analytics registered and rendered the widget on every site.

  • Treat jpa/file-downloads as unsupported outside WordPress.com Simple.
  • Apply the same type-level policy to the widget registry and default layouts, keeping the REST list, import map, widget picker, and defaults consistent.
  • Preserve saved layouts. Gutenberg intentionally renders missing types as removable ghost widgets, so availability changes do not silently rewrite user preferences (WordPress/gutenberg#78502).
  • Keep environment, plugin/category, and shared type-level policies separate and composable. Future permanent type restrictions have one shared resolver; temporary plan or capability restrictions remain runtime concerns.
  • Preserve non-array records supplied through the public default-layout filter so third-party callbacks remain compatible.
  • Hide the /reports/downloads route outside WordPress.com Simple.
  • Remove the widget's obsolete 404-specific UI.

Related product discussion/links

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

No.

Testing instructions

Self-hosted Jetpack or another non-Simple site

  1. Build the package: jetpack build packages/premium-analytics --deps.
  2. Open Premium Analytics in wp-admin.
  3. Reset the Traffic layout and confirm File downloads is not included.
  4. Confirm File downloads is absent from the Add widget picker.
  5. Confirm no stats/file-downloads requests are made.
  6. Visit admin.php?page=jetpack-premium-analytics-wp-admin&p=%2Freports%2Fdownloads and confirm it redirects to the dashboard.
  7. If the site has a layout saved before this branch with File downloads, confirm it appears as a removable unavailable widget. Enter Customize mode and remove it.
Screenshot 2026-07-23 at 3 44 30 PM Screenshot 2026-07-23 at 3 43 42 PM

WordPress.com Simple

  1. On a sandbox, fetch this branch's build: bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/wooa7s-1717-hide-file-downloads-on-self-hosted.

  2. Sandbox the test site and public-api.wordpress.com in /etc/hosts.

  3. Open Premium Analytics on a Simple site with the jetpack-premium-analytics sticker. To add the sticker, run this on the sandbox:

    wp blog-stickers add --sticker=jetpack-premium-analytics --who=<your_wpcom_login> --blog_id=<blog_id>
    
  4. Confirm File downloads remains in the Traffic default and widget picker.

  5. Confirm its request returns data and /reports/downloads still renders.

Screenshot 2026-07-23 at 4 42 54 PM Screenshot 2026-07-23 at 4 43 26 PM

@github-actions

github-actions Bot commented Jul 22, 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 (WordPress.com Site Helper), and enable the add/wooa7s-1717-hide-file-downloads-on-self-hosted branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/wooa7s-1717-hide-file-downloads-on-self-hosted

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

github-actions Bot commented Jul 22, 2026

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 added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 22, 2026
@jp-launch-control

jp-launch-control Bot commented Jul 22, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/src/widget-availability.php 34/41 (82.93%) -4.95% 3 ❤️‍🩹
projects/packages/premium-analytics/src/dashboard-layout.php 384/390 (98.46%) -0.24% 1 ❤️‍🩹

1 file is newly checked for coverage.

File Coverage
projects/packages/premium-analytics/src/widget-type-support.php 19/19 (100.00%) 💚

Full summary · PHP report · JS report

@chihsuan chihsuan self-assigned this Jul 22, 2026
@chihsuan chihsuan changed the title Premium Analytics: hide File downloads on self-hosted Jetpack sites Premium Analytics: show File downloads only on WPCOM Simple sites Jul 23, 2026
@chihsuan
chihsuan force-pushed the add/wooa7s-1717-hide-file-downloads-on-self-hosted branch 2 times, most recently from 82112b1 to 6d8139a Compare July 23, 2026 08:53
@chihsuan chihsuan closed this Jul 23, 2026
@chihsuan
chihsuan force-pushed the add/wooa7s-1717-hide-file-downloads-on-self-hosted branch from 6d8139a to 4eae208 Compare July 23, 2026 08:59
@github-actions github-actions Bot removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Jul 23, 2026
@chihsuan chihsuan reopened this Jul 23, 2026
@github-actions github-actions Bot added [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 23, 2026
@chihsuan chihsuan added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 23, 2026
@chihsuan
chihsuan force-pushed the add/wooa7s-1717-hide-file-downloads-on-self-hosted branch from da23ee4 to e6c62e0 Compare July 23, 2026 09:15
@chihsuan
chihsuan marked this pull request as ready for review July 23, 2026 09:28
@chihsuan
chihsuan requested review from a team as code owners July 23, 2026 09:28

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

This looks good and tested well both on simple and self hosted.

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