Skip to content

WOOA7S-2038: Premium Analytics: Show a notice when the site nears or passes its views limit - #53401

Merged
Nikschavan merged 11 commits into
trunkfrom
wooa7s-2038-notifications-for-approaching-and-exceeding-the-plan-limit
Oct 14, 2026
Merged

Nikschavan merged 11 commits into
trunkfrom
wooa7s-2038-notifications-for-approaching-and-exceeding-the-plan-limit

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Fixes WOOA7S-2038

Proposed changes

  • Stats v1 warns a site when it gets close to, or goes past, the monthly billable views limit of its plan, but the new dashboard had no such notice. This adds one below the section header on every dashboard section, where the other dashboard notices sit, using the same thresholds as Calypso: 90% of views_limit for "approaching" and 100% for "over".
  • Near the limit, the notice is an info notice that can be dismissed. Dismissing it postpones the tier_upgrade notice for a week through the existing notices endpoint, the same way Stats does, so the two dashboards share the state.
  • Over the limit, the notice is a warning and cannot be dismissed.
  • The notice is not shown on WordPress.com Simple sites, where Stats does not show it either, or on VIP sites, which are exempt from the limit. Sites with no limit (views_limit is null) never see it.
  • The upgrade link comes from getPlanUpgradeUrl(), the same builder the plan usage card on the Settings tab uses. It now takes the from value, so the notice reports its own source to the checkout.

Related product discussion/links

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

Yes. The notice records three new Tracks events: jetpack_premium_analytics_plan_limit_notice_view (once per page load, with status set to near or over), jetpack_premium_analytics_plan_limit_notice_upgrade_click (with status) and jetpack_premium_analytics_plan_limit_notice_dismiss. The upgrade link also keeps its own from value, so purchase completion can be tied to it later.

Testing instructions

The notice needs a site with a views limit. The easiest way to test is to fake the plan usage reply with the mu-plugin attached to WOOA7S-2038.

  1. Set up a Jurassic Ninja site with Jetpack Beta and switch the Premium Analytics plugin to this branch, or build the plugin from this branch on your own test site.
  2. Add the mu-plugin from WOOA7S-2038 to wp-content/mu-plugins/. It replaces the reply of the plan usage endpoint while a cookie is set, and the cookie is set from a URL parameter.
  3. Open wp-admin/admin.php?page=jetpack-premium-analytics-wp-admin&pa_fake_usage=near. A blue notice says "You are nearing your monthly limit", with an "Upgrade now" link and a close button.
  4. Check that "Upgrade now" opens the Stats purchase screen with from=jetpack-premium-analytics-plan-limit-notice.
  5. Open the same page with pa_fake_usage=over. A yellow notice says "You have reached your views limit", and there is no close button.
  6. Switch to another tab, such as Insights. The notice shows there too. Open the options menu and choose Customize: the notice goes away while customizing.
  7. Go back to pa_fake_usage=near and close the notice, then reload: it stays hidden. This postpones the real tier_upgrade notice for the site for a week, in Stats v1 too.
  8. Open the page with pa_fake_usage=off to see the real data again. A site under 90% of its limit, or without a limit, shows no notice.
Approaching the limit Over the limit
Info notice titled "You are nearing your monthly limit" with an Upgrade now link and a close button Warning notice titled "You have reached your views limit" with an Upgrade now link and no close button
Info notice, can be dismissed Warning notice, cannot be dismissed

I tested both states on a local site with that mu-plugin. I did not dismiss the notice in the browser, because that postpones the real notice for a week; the unit tests cover the dismissal.

@Nikschavan Nikschavan added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress labels Oct 9, 2026
@Nikschavan Nikschavan self-assigned this Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 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-2038-notifications-for-approaching-and-exceeding-the-plan-limit branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack wooa7s-2038-notifications-for-approaching-and-exceeding-the-plan-limit

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 added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 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!


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.


Premium Analytics 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.

@jp-launch-control

jp-launch-control Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/data/src/queries/stats-app-notices-query.ts 6/6 (100.00%) 16.67% -1 💚
projects/packages/premium-analytics/packages/data/src/hooks/use-stats-app-notices.ts 14/14 (100.00%) 100.00% -5 💚

2 files are newly checked for coverage.

File Coverage
projects/packages/premium-analytics/routes/dashboard/components/plan-limit-notice/plan-limit-notice.tsx 40/40 (100.00%) 💚
projects/packages/premium-analytics/routes/dashboard/components/plan-limit-notice/index.ts 0/0 (—%) 🤷

Full summary · PHP report · JS report

@Nikschavan
Nikschavan marked this pull request as ready for review October 9, 2026 11:57
@Nikschavan
Nikschavan requested a review from a team as a code owner October 9, 2026 11:57
Copilot AI balanced review requested due to automatic review settings October 9, 2026 11:57
@Nikschavan Nikschavan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Oct 9, 2026

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Nikschavan
Nikschavan force-pushed the wooa7s-2038-notifications-for-approaching-and-exceeding-the-plan-limit branch from 670a47a to 202082a Compare October 9, 2026 12:31
@Nikschavan
Nikschavan requested review from a team and retrofox October 12, 2026 05:32
chihsuan
chihsuan previously approved these changes Oct 13, 2026

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work bringing the limit notice over to v2! @Nikschavan I tested the near and over states, and both look great. 👍 I left a few small inline notes.

Comment thread projects/packages/premium-analytics/routes/dashboard/stage.tsx Outdated
…ews limit

Carries over the Stats tier upgrade notice: an info notice at 90% of the plan's billable views limit, which the reader can postpone for a week (shared with Stats through the tier_upgrade notice), and a warning past the limit that cannot be dismissed. The plan-usage widget and the notice now share one Stats purchase URL helper.
…plan limit notice

The view event fires once per page load and status, since every section tab mounts its own copy of the notice. Upgrade clicks are recorded here because the Stats purchase page only tracks the from values it knows.
…s sections

The dismissal now lands in the shared notices cache before the request finishes, so a section that mounts during the save reads it as dismissed. A failed save restores the cache and shows an error snackbar, so the notice is not left hidden although nothing was saved. The tests now sit on the exact 90% and 100% boundaries.
@Nikschavan
Nikschavan force-pushed the wooa7s-2038-notifications-for-approaching-and-exceeding-the-plan-limit branch from 202082a to a069dff Compare October 13, 2026 06:57
The notice builds its link with getPlanUpgradeUrl(), which now takes the from value, so widgets-toolkit no longer exports a second builder.

The dismissal error is reported from the mutation hook's own onError, so it still shows when the reader switches section before the request fails. The stage renders the notice only outside customize mode, which replaces the enabled prop.
Views past the limit are still counted, so the notice no longer says they are not. It carries the wording of the Stats tier upgrade notice instead, and drops the usage sentence.
The plan limit notice reads plan usage on every dashboard load, and the helper blocked that request, so the proxy answered 500 and the specs failed. Fixtures now sit in one table of API path to builder, and usage answers a plan with no views limit.
The fixture table passed the query to every builder through call_user_func(), and Phan rejects that for the plan usage builder, which takes none. A switch on the path calls each builder directly.
@Nikschavan
Nikschavan requested a review from chihsuan October 13, 2026 10:14
dognose24
dognose24 previously approved these changes Oct 14, 2026

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

Approving. I traced the data path and it holds: jetpack-stats/usage through the allowlisted jetpack-stats prefix, the 90% and 100% thresholds matching Calypso's use-plan-usage-query (8999 stays quiet, 9000 shows), the Simple and VIP gates, the 7-day postpone through the shared notices endpoint with the optimistic update keyed on the right query prefix, no notice while the usage or notices request is unresolved, and the Settings card and the notice now sharing getPlanUpgradeUrl(). Changelog set is right, with Simple correctly left out.

Two notes below, neither blocking.

chihsuan
chihsuan previously approved these changes Oct 14, 2026

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, LGTM!

Nikschavan added a commit that referenced this pull request Oct 14, 2026
The empty Traffic widgets now ask for the all-time views in /stats, and the helper blocked that path because it only matched paths under /stats/. The proxy returned 500 and the dashboard fixture failed the specs.

The helper now looks fixtures up per path, in the same shape as #53401, and answers the summary with views so the widgets keep the period text.
…stponement

Past the limit the notice stays for the cycle, as the design asks, so it does not read the tier_upgrade postponement that Stats v1 can set from either state. The comment now says so, since the two dashboards can disagree for up to a week.
@Nikschavan
Nikschavan dismissed stale reviews from chihsuan and dognose24 via 59f0194 October 14, 2026 04:50
@Nikschavan
Nikschavan merged commit 2610609 into trunk Oct 14, 2026
90 checks passed
@Nikschavan
Nikschavan deleted the wooa7s-2038-notifications-for-approaching-and-exceeding-the-plan-limit branch October 14, 2026 05:13
@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] Needs Review This PR is ready for review. labels Oct 14, 2026
Nikschavan added a commit that referenced this pull request Oct 14, 2026
The empty Traffic widgets now ask for the all-time views in /stats, and the helper blocked that path because it only matched paths under /stats/. The proxy returned 500 and the dashboard fixture failed the specs.

The helper now looks fixtures up per path, in the same shape as #53401, and answers the summary with views so the widgets keep the period text.
Nikschavan added a commit that referenced this pull request Oct 15, 2026
The empty Traffic widgets now ask for the all-time views in /stats, and the helper blocked that path because it only matched paths under /stats/. The proxy returned 500 and the dashboard fixture failed the specs.

The helper now looks fixtures up per path, in the same shape as #53401, and answers the summary with views so the widgets keep the period text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

E2E Tests Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] 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.

5 participants