Skip to content

WOOA7S-2037: Premium Analytics: Add a plan Usage drawer to the page options menu - #52906

Closed
Nikschavan wants to merge 3 commits into
wooa7s-2037-page-drawer-refactorfrom
wooa7s-2037-plan-usage-drawer
Closed

Nikschavan wants to merge 3 commits into
wooa7s-2037-page-drawer-refactorfrom
wooa7s-2037-plan-usage-drawer

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Part of WOOA7S-2037

Proposed changes

  • Stats v2 has no place for plan usage. The jpa/plan-usage widget was held back on every site in Premium Analytics: hold the Plan usage widget back from Stats v2 #51834 until the paid plan is settled (STATS-459), and the configurations design (WOOA7S-2055) moves usage out of the page content into the page options menu. This adds a Usage item to that menu, which opens a drawer with the current cycle's billable views against the plan limit, the days until the cycle restarts, the over-limit warning, and an Upgrade button to the same Stats purchase flow the widget linked to.
  • The item stays hidden behind the new premium-analytics-usage-drawer feature flag, off by default, so nothing changes for customers until the plan question is settled. With the flag on, only users with manage_options see it, the same as Settings, since Upgrade leads to a purchase.
  • The drawer is built on the shell from WOOA7S-2037: Premium Analytics: Share one drawer shell across the page options panels #52904, and the widget and the drawer now share one meter, one data hook (usePlanUsage(), which keeps the VIP exception for the over-limit warning), the upgrade URL and the over-limit message, so the two cannot show different numbers. The meter follows the prototype: the figures above a thin bar in the brand color, which follows the admin color scheme, and the error color once the site is over its limit. The widget picks up the same meter, and it stays hidden.
  • The menu keeps one open drawer at a time. ?usage=1 opens Usage from a link the same way ?settings=1 opens Settings, and the param is removed on close.
  • wp-admin colors every link outside a cascade layer, which turned the Upgrade text link blue on the button. The drawer sets the button's own foreground color back on that link.
Page options menu Usage drawer
Page options menu with Customize, Settings, Any feedback? and Switch off the preview Page options menu with a new Usage item between Customize and Settings
The menu on #52904 The same menu with the flag on

The Usage drawer open over the dimmed Stats v2 dashboard, below the admin bar, with 5,085 / 100,000 views, Restarts in 1 day, a thin bar in the admin color, the billable views note with Learn more, and an Upgrade button

Related product discussion/links

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

Yes. It adds three Tracks events, all from the Usage drawer and all carrying only the usual Tracks user and blog_id:

  • jetpack_premium_analytics_usage_open, when the drawer opens, with source set to menu or url (the ?usage=1 link).
  • jetpack_premium_analytics_usage_upgrade_click, when Upgrade is clicked.
  • jetpack_premium_analytics_usage_learn_more_click, when Learn more is clicked.

The events need to be registered in Tracks before they record.

Testing instructions

Use a site with this branch and the Stats v2 preview switched on: a Jurassic Ninja site with the branch synced, or the Jetpack Beta Tester plugin pointed at this branch. The site needs a Stats plan with a views limit to show the meter.

  • Open Stats v2 and the page options menu (the three dots at the top right). Usage is not in the menu.
  • Turn the flag on, for example with add_filter( 'jetpack_feature_flag_enabled_premium-analytics-usage-drawer', '__return_true' ); in a mu-plugin, or wp companion feature-flag on Jurassic Ninja. Reload: Usage is now between Customize and Settings.
  • Pick Usage. The drawer slides in from the right with the views used against the limit and the days until the cycle restarts, and the figures match the Plan usage section in classic Stats.
  • Click Upgrade. It goes to the Stats purchase screen for this site.
  • Open /wp-admin/admin.php?page=jetpack-premium-analytics-wp-admin&p=%2F%3Fusage%3D1. The drawer opens on load, and closing it removes usage=1 from the URL.
  • With Tracks debugging on (localStorage.debug = 'dops:analytics*'), opening the drawer and clicking Upgrade or Learn more each log their event.
  • Log in as an Editor with access to Stats. Usage is not in the menu, flag or not.

I tested the menu, the drawer, Upgrade, the ?usage=1 link and the three events on my local site, with the flag on through a mu-plugin, and checked the events as Tracks pixel requests rather than in the debug log. I did not test the Editor step, the classic Stats comparison, wp companion, a site over its limit, or a plan without a limit; the drawer tests cover the last two.

@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 wooa7s-2037-plan-usage-drawer branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack wooa7s-2037-plan-usage-drawer

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!

@Nikschavan
Nikschavan force-pushed the wooa7s-2037-page-drawer-refactor branch from bb9bc5b to 36fb0f9 Compare September 29, 2026 06:41
@Nikschavan
Nikschavan force-pushed the wooa7s-2037-plan-usage-drawer branch from 405a20d to 2d7225d Compare September 29, 2026 06:41
@jp-launch-control

jp-launch-control Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

No summary data is available for parent commit 10a67c8, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for 10a67c8 is available.

Full summary · PHP report · JS report

…menu

Usage opens a drawer with the current cycle's billable views against the plan limit, the over-limit warning, and an Upgrade button to the existing Stats purchase flow. It stays hidden behind the premium-analytics-usage-drawer flag until the paid plan is settled (STATS-459), and only users with manage_options see it.

The plan-usage widget and the drawer now share one meter, data hook, upgrade URL and over-limit message from the toolkit, with the meter styled after the configurations design. The menu keeps one open drawer, opened from the menu or from ?usage=1, and the drawer reports its opening, Upgrade clicks and Learn more clicks to Tracks.
…lear only its param

A link on the same page that adds ?usage=1 now opens the Usage drawer, since the open drawer is read from the URL on every render, with a drawer picked from the menu taking precedence. Closing a drawer removes only its own param, so closing Usage no longer drops ?settings.
…grade link

LinkButton keeps the button colors in wp-admin, so the drawer's own link color override goes. The Tracks tests now count each event, across a data refresh and for keyboard activation.
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.

1 participant