Skip to content

WOOA7S-1769: Premium Analytics: Add a Settings tab to the dashboard - #53357

Open
Nikschavan wants to merge 7 commits into
trunkfrom
wooa7s-1769-stats-settings-tab-chips
Open

Nikschavan wants to merge 7 commits into
trunkfrom
wooa7s-1769-stats-settings-tab-chips

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Part of WOOA7S-1769
Fixes STATS-511
Fixes WOOA7S-2037

Proposed changes

Site owners on the new Stats dashboard had nowhere to change the Stats settings or see how much of their plan they had used: both still lived only in the old Odyssey Stats screen. The team decided to put them in one Settings tab at the end of the dashboard, hardcoded in the dashboard stage rather than registered through the sections filter, so another plugin's section cannot push it out of last place. This replaces #52870, #52904 and #52906, which built the same surface as a drawer, a widget and a menu.

  • Add a Settings tab after the registered sections. It is selected with ?section=settings, it is disabled while the layout is being customized (a layout is arranged on a widget section), and Customize is not offered on it, so WidgetDashboard does not open edit mode over an empty first section behind it. The settings slug is now reserved in the section registry, so a registered section cannot take the same URL.
  • Show the plan usage on the tab: views against the plan limit, when the cycle restarts, the over-limit warning, and Upgrade. The usage widget's helpers moved to widgets-toolkit so the widget and the card share them.
  • Edit the Stats settings with a DataForm in card layout: the admin bar chart, who can view stats, which logged-in roles count, and whether the WordPress.com Reader shows view counts. The two role fields use SearchableChipSelectControl from @wordpress/ui through a small DataForm Edit, because DataForm's own array control still renders the legacy token field. Administrator is not offered as a chip: the Stats package always keeps it, and the help text says so. A saved role that the site no longer lists, for example one from a deactivated plugin, stays as a chip, so editing another role does not drop it.
  • Save each change as it is made through core's wp/v2/settings route and the root/site entity. stats_options and wpcom_reader_views_enabled are registered there and written through the existing Stats\Settings writer, which keeps the option's internal state. A write the writer refuses now answers with an error, because core ignores errors from rest_pre_update_setting. When a save fails, only the settings that change touched go back to their stored values, so a later change that already saved is kept.
  • Send the roles and their user counts in the dashboard's script data, only on the dashboard request and only for users who can manage options. Sites with a large user count get the roles without counts, because count_users() is slow there. Nothing is registered on WordPress.com Simple, where WordPress.com owns these settings.
  • Point the "Manage Stats settings" link in Jetpack › Settings › Traffic to the new tab when the new dashboard is on, and keep the old Odyssey link otherwise.
  • Link an Activation card to My Jetpack › Features filtered to Stats, shown only when the Jetpack plugin is active.

Follow-ups, not in this PR:

  • The usage bar uses ProgressBar from @wordpress/components. @wordpress/ui 0.24.0 (Update wordpress monorepo #53004) adds Meter, which matches a measured quantity against a limit better than Progress, and I will switch to it once that update lands.
  • The section tabs are Tabs, as before this PR. Moving them to the Page component's navigation prop is tracked separately.
  • DataForm has no loading state, and its toggle and array controls still render @wordpress/components. I want to raise both upstream.

Settings tab last, with the plan usage, Admin bar widget, Manage permissions, WordPress.com Reader and Activation cards

Related product discussion/links

  • p1790658521609109-slack-C06FSDTSN82 (Settings and usage as one tab)
  • p1791452703750719-slack-C06FSDTSN82 (chips for the role fields)
  • p1HpG7-yR6-p2#comment-78777 (Settings as a hardcoded last tab in the dashboard stage)
  • WOOA7S-2037 (plan usage), WOOA7S-2055 (configurations menu, superseded by the tab)

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

Yes. It adds two Tracks events. jetpack_premium_analytics_settings_changed records each changed setting, with setting, enabled and, for the role fields, the role added or removed, in the same shape as Odyssey Stats' jetpack_odyssey_stats_settings_changed. jetpack_premium_analytics_plan_upgrade_click records a click on the plan usage card's upgrade link.

Testing instructions

Use a Jurassic Ninja site, or any self-hosted site, with Jetpack and Premium Analytics from this branch (Jetpack Beta Tester pointed at wooa7s-1769-stats-settings-tab-chips), connected, with Stats on. Log in as an administrator and add a user with the Editor role.

  • Go to Stats v2. Settings is the last tab. Open it, and check that the URL carries section=settings.
  • "Your current plan" shows the views used against the limit and when the cycle restarts. On a site over its limit, the warning and Upgrade show.
  • Turn "Include a small chart in admin bar" off. A "Settings saved." snackbar shows. Reload: the toggle stays off, and the chart is gone from the admin bar.
  • In "Allow Jetpack Stats to be viewed by", add Editor. Administrator is not offered. Log in as the editor in another browser: Stats v2 opens. Remove Editor again: the editor loses access, and Administrator still has it.
  • Add a role to "Count logged in page views from", reload, and check that it stays. Do the same for "Show post views for this site".
  • Open Page options › Customize on Traffic. The Settings tab is disabled until you click Done or Cancel. On the Settings tab, Page options does not offer Customize.
  • "Jetpack features" in the Activation card opens My Jetpack › Features, filtered to Stats.
  • Go to Jetpack › Settings › Traffic. "Manage Stats settings" opens the new tab.
  • Log in as the editor with view access: the Settings tab does not show.

I checked saving, the role chips, the disabled tab and the Features link on my local Docker site. I did not test on WordPress.com Atomic or on a site over its plan limit.

@Nikschavan Nikschavan self-assigned this Oct 8, 2026
@github-actions github-actions Bot added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh [Tests] Includes Tests Admin Page React-powered dashboard under the Jetpack menu Docs labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 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.


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

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.

@github-actions

github-actions Bot commented Oct 8, 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 wooa7s-1769-stats-settings-tab-chips branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack wooa7s-1769-stats-settings-tab-chips

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

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

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 6 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/routes/dashboard/components/dashboard-sections/dashboard-sections.tsx 0/4 (0.00%) 0.00% 2 ❤️‍🩹
projects/packages/premium-analytics/routes/dashboard/config/sections.ts 9/9 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/routes/dashboard/stage.tsx 86/91 (94.51%) 0.53% 0 💚
projects/packages/premium-analytics/src/class-analytics.php 155/168 (92.26%) 0.05% 0 💚
projects/packages/premium-analytics/src/class-dashboard-section-registry.php 85/88 (96.59%) 0.16% 0 💚

8 files are newly checked for coverage. Only the first 5 are listed here.

File Coverage
projects/packages/premium-analytics/routes/dashboard/components/stats-settings/plan-usage-card.tsx 16/17 (94.12%) 💚
projects/packages/premium-analytics/routes/dashboard/components/stats-settings/stats-settings.tsx 38/40 (95.00%) 💚
projects/packages/premium-analytics/src/class-stats-settings.php 97/100 (97.00%) 💚
projects/packages/premium-analytics/packages/data/src/hooks/use-stats-settings.ts 26/26 (100.00%) 💚
projects/packages/premium-analytics/packages/widgets-toolkit/src/helpers/plan-usage.ts 9/9 (100.00%) 💚

Full summary · PHP report · JS report

@Nikschavan
Nikschavan marked this pull request as ready for review October 8, 2026 15:16
@Nikschavan
Nikschavan requested a review from a team as a code owner October 8, 2026 15:16
Copilot AI balanced review requested due to automatic review settings October 8, 2026 15:16
@Nikschavan
Nikschavan added this pull request to stack #53368 October 8, 2026 15:17
@Nikschavan Nikschavan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Oct 8, 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.

🟡 Changes recommended

Save rollback, Reader write failure reporting, and unavailable navigation destinations need correction.

4 open findings
What changed in this PR

Adds a Settings tab to Premium Analytics, bringing Stats configuration and plan usage into the new dashboard.

Changes:

  • Adds an admin-only Settings tab with role selectors, automatic saving, and plan usage.
  • Registers settings through WordPress’s settings API and shares usage helpers.
  • Updates navigation, tests, documentation, and changelogs.
File Description
projects/​plugins/​wpcomsh/​changelog/​wooa7s-1769-stats-settings-tab Records the Atomic-facing change.
projects/​plugins/​premium-analytics/​changelog/​wooa7s-1769-stats-settings-tab Records the standalone plugin change.
projects/​plugins/​jetpack/​changelog/​wooa7s-1769-stats-settings-tab Records the Jetpack-facing change.
projects/​plugins/​jetpack/​_inc/​shared/​analytics-url.ts Supports Settings URLs.
projects/​plugins/​jetpack/​_inc/​client/​traffic/​test/​site-stats.test.jsx Tests the updated Settings link.
projects/​plugins/​jetpack/​_inc/​client/​traffic/​site-stats.jsx Links to the new Settings tab.
projects/​packages/​premium-analytics/​widgets/​plan-usage/​render.tsx Reuses shared usage helpers.
projects/​packages/​premium-analytics/​tests/​php/​Stats_Settings_Test.php Tests settings persistence and script data.
projects/​packages/​premium-analytics/​tests/​php/​Dashboard_Section_Test.php Tests the reserved Settings slug.
projects/​packages/​premium-analytics/​src/​widget-type-support.php Updates the usage-placement comment.
projects/​packages/​premium-analytics/​src/​class-stats-settings.php Registers settings and role context.
projects/​packages/​premium-analytics/​src/​class-dashboard-section-registry.php Reserves the Settings slug.
projects/​packages/​premium-analytics/​src/​class-analytics.php Initializes settings integration.
projects/​packages/​premium-analytics/​routes/​dashboard/​stage.tsx Integrates Settings and customization guards.
projects/​packages/​premium-analytics/​routes/​dashboard/​stage.test.tsx Tests Settings customization restrictions.
projects/​packages/​premium-analytics/​routes/​dashboard/​package.json Adds the formatters dependency.
projects/​packages/​premium-analytics/​routes/​dashboard/​hooks/​use-active-section/​use-active-section.ts Accepts stage-owned tabs.
projects/​packages/​premium-analytics/​routes/​dashboard/​hooks/​use-active-section/​use-active-section.test.ts Tests Settings URL preservation.
projects/​packages/​premium-analytics/​routes/​dashboard/​config/​sections.ts Defines and resolves Settings.
projects/​packages/​premium-analytics/​routes/​dashboard/​config/​index.ts Exports the Settings constant.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​stats-settings.tsx Renders settings cards and save notices.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​stats-settings.test.tsx Tests errors and Activation visibility.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​stats-settings.module.scss Styles settings and usage cards.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​stats-settings-fields.tsx Defines editable settings fields.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​stats-settings-fields.test.ts Tests role-field behavior.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​plan-usage-card.tsx Displays usage and Upgrade.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​plan-usage-card.test.tsx Tests usage states and links.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​chip-select-edit.tsx Adds the role-chip editor.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​stats-settings/​chip-select-edit.test.tsx Tests retired-role preservation.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​index.ts Exports the Settings panel.
projects/​packages/​premium-analytics/​routes/​dashboard/​components/​dashboard-sections/​dashboard-sections.tsx Appends Settings as the last tab.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​index.ts Exports shared usage utilities.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​hooks/​use-plan-usage.ts Shares plan-usage state.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​hooks/​index.ts Exports the usage hook.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​helpers/​plan-usage.ts Shares warnings and purchase URLs.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​helpers/​index.ts Exports usage helpers.
projects/​packages/​premium-analytics/​packages/​ui/​src/​section-tabs/​section-tabs.tsx Supports disabled tabs.
projects/​packages/​premium-analytics/​packages/​site-sync/​src/​jetpack-script-data.d.ts Types settings script data.
projects/​packages/​premium-analytics/​packages/​externals/​src/​index.ts Exports required UI components.
projects/​packages/​premium-analytics/​packages/​data/​src/​hooks/​use-stats-settings.ts Implements automatic saves and rollback.
projects/​packages/​premium-analytics/​packages/​data/​src/​hooks/​index.ts Exports the settings hook.
projects/​packages/​premium-analytics/​packages/​data/​src/​hooks/​__tests__/​use-stats-settings.test.ts Tests save-failure rollback.
projects/​packages/​premium-analytics/​docs/​dashboard-sections.md Documents the reserved slug.
projects/​packages/​premium-analytics/​changelog/​wooa7s-1769-stats-settings-tab Records the package change.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread projects/packages/premium-analytics/src/class-stats-settings.php
Comment thread projects/packages/premium-analytics/src/class-stats-settings.php Outdated
@Nikschavan
Nikschavan force-pushed the wooa7s-1769-stats-settings-tab-chips branch 2 times, most recently from ee4a4b2 to e0bc2f5 Compare October 9, 2026 13:43
The tab shows the plan usage and edits the Stats settings (admin bar chart, who can view stats, which logged-in views count, Reader view counts) through core's wp/v2/settings route. Jetpack's Traffic settings link to it.
Cover each save rollback guard on its own, make the Settings tab stage tests set up their own section, and drop two PHP tests that only repeat the Stats package's behaviour.
Test the card's rules (meter capped at the limit, Upgrade link, over-limit warnings, VIP sites, no-limit state, Retry) and the panel's (the site's reason on a refused save, the load error, the Activation card only with a Features screen).
Roll back only the settings a failed save still owns, check that the Reader setting was stored, and link to Jetpack features only when My Jetpack's screen is registered.
@Nikschavan
Nikschavan force-pushed the wooa7s-1769-stats-settings-tab-chips branch from e0bc2f5 to 5014c7e Compare October 9, 2026 17:03

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

Admin Page React-powered dashboard under the Jetpack menu Docs [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh [Status] Needs Review This PR is ready for review. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants