Skip to content

Premium Analytics: add metrics attribute to Traffic and Subscribers charts#50390

Open
retrofox wants to merge 1 commit into
trunkfrom
update/chart-widgets-metrics-attribute
Open

Premium Analytics: add metrics attribute to Traffic and Subscribers charts#50390
retrofox wants to merge 1 commit into
trunkfrom
update/chart-widgets-metrics-attribute

Conversation

@retrofox

Copy link
Copy Markdown
Contributor

Fixes WOOA7S-1685

Proposed changes

  • Declare a metrics array attribute (Edit: ArrayCheckboxField, relevance: 'high') on the two MetricTabsChart widgets, alongside their existing granularity attribute. example.attributes doubles as the defaults for new instances (all metrics enabled).
  • Traffic chart: the tab definitions (views, visitors, likes, comments) move from use-traffic-chart.ts into widget.ts as the single source for the settings checkboxes and the chart tabs. The hook filters the tabs by the selected ids and skips a pair's request entirely (enabled: false) while neither of its fields is selected.
  • Subscribers chart: the tab definitions (subscribers, paid) move from render.tsx into widget.ts; buildMetrics filters by the selected ids, and the Paid subscribers tab keeps rendering only when the site has paid subscribers.
  • Both widgets show a "No metric selected" message when the selection is empty, and both stories expose a metrics check control plus the real attribute schema in the dashboard story's settings drawer.
  • Drop the redundant description from both widget.ts files: widget.json is the source of truth for static widget metadata.

Related product discussion/links

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

No.

Testing instructions

  1. Build Premium Analytics with dependencies: jp build packages/premium-analytics --deps
  2. Open the Premium Analytics dashboard and add or edit a Traffic widget.
  3. In the widget header, confirm the Metrics control appears inline as a compact menu with checkboxes for Views, Visitors, Likes, and Comments, next to the existing Group by control.
  4. Toggle metrics and verify the chart tabs/dropdown only offer the selected metrics.
  5. Uncheck Views and Visitors and confirm (network tab) that the views,visitors request is not sent; uncheck everything and confirm the "No metric selected" message.
  6. Repeat with a Subscribers widget: checkboxes for Subscribers and Paid subscribers; on a site without paid subscribers the Paid tab stays hidden even while selected.
  7. Add new instances of both widgets and confirm all metrics are selected by default.

traffic and subscribers charts filter their tabs via ArrayCheckboxField
@retrofox retrofox requested review from a team as code owners July 10, 2026 08:12
@retrofox retrofox added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress labels Jul 10, 2026
@retrofox retrofox self-assigned this Jul 10, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report

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

@retrofox retrofox added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Package] Premium Analytics [Status] Needs Review This PR is ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant