Skip to content

Premium Analytics: port Stats Search Terms widget#49985

Open
dognose24 wants to merge 6 commits into
trunkfrom
add/wooa7s-1496-port-stats-module-search-terms
Open

Premium Analytics: port Stats Search Terms widget#49985
dognose24 wants to merge 6 commits into
trunkfrom
add/wooa7s-1496-port-stats-module-search-terms

Conversation

@dognose24

@dognose24 dognose24 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Why

Port the Jetpack Stats Search Terms module into Premium Analytics as a standalone widget (`jpa/search-terms`), closing WOOA7S-1496.

The data layer (`useStatsSearchTerms`, `sanitizeStatsSearchTermsResponse`, fixtures, tests) was already complete on trunk. This PR adds only the widget UI layer.

What

  • `widgets/search-terms/` — new widget folder following the standard contract:
    • `widget.json` / `widget.ts` — static + live metadata, `jpa/search-terms` name, `search` icon
    • `render.tsx` — `WidgetRoot` + `LeaderboardChart` with `itemLabel` wrapper (mirrors top-platforms pattern for correct bar height), three states (loading / error / empty)
    • `use-search-term-views.ts` — maps `StatsSearchTermsItem[]` → `SearchTermView[]`
    • `style.module.css` — WPDS tokens, container queries
    • `stories/search-terms-widget.stories.tsx` — Default, WithComparison, WidgetDashboardWithWidget
  • `src/dashboard-layout.php` — adds `jpa/search-terms` to the default layout at 1×2, order 2

Notes

Search terms data requires organic search traffic from indexed sites. On sites with no search traffic for the selected period, the widget correctly shows an empty state. Selecting a longer date range (e.g. last year) will surface terms if the site has historical search data.

Test plan

  • Build: `jetpack build packages/premium-analytics`
  • Widget appears in the dashboard widget picker
  • With a site that has search terms data: rows render with correct bar proportions
  • Empty state shows when no data for the selected period
  • Storybook: `Default`, `WithComparison`, `WidgetDashboardWithWidget` stories render
截圖 2026-06-26 下午2 19 01

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jun 26, 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 🤖


🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so:

## Testing instructions:

* Go to '..'
*

🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

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

My PR adds *x* and *y*.

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!


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 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 Jun 26, 2026
@jp-launch-control

jp-launch-control Bot commented Jun 26, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/src/dashboard-layout.php 0/84 (0.00%) 0.00% 13 💔

Full summary · PHP report

Coverage check overridden by Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code .

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@dognose24 dognose24 force-pushed the add/wooa7s-1496-port-stats-module-search-terms branch from ec5da44 to ea30566 Compare June 26, 2026 05:59
Add itemLabel wrapper with padding (mirrors top-platforms pattern) so
the overlay bar gets its height from the label element. Pass loading
prop and use chart's built-in emptyStateText.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@dognose24 dognose24 changed the title Premium Analytics: add jpa/search-terms widget Premium Analytics: port Stats Search Terms widget Jun 26, 2026
@dognose24 dognose24 added Docs [Status] Needs Review This PR is ready for review. [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code [Plugin] Premium Analytics labels Jun 26, 2026
- widget.ts: add `as const` to attributes type field so it narrows to
  literal 'integer' rather than string (fixes StoryWidgetMetadata mismatch)
- use-search-term-views: cast reportParams to StatsReportParams (same
  pattern as use-location-views)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Jun 26, 2026
@dognose24 dognose24 marked this pull request as ready for review June 26, 2026 06:28
@dognose24 dognose24 requested review from a team as code owners June 26, 2026 06:28
@dognose24 dognose24 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. [Status] In Progress labels Jun 26, 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. and removed [Status] Needs Review This PR is ready for review. labels Jun 26, 2026
@dognose24 dognose24 self-assigned this Jun 26, 2026
dognose24 and others added 3 commits June 26, 2026 14:35
…is source of truth)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…empty state

Remove manual empty/loading early returns that bypassed the header.
Use WidgetLoadingOverlay for initial load, and LeaderboardChart's
built-in emptyStateText for no-data state (same pattern as top-platforms).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Docs [Package] Premium Analytics [Plugin] Premium Analytics [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. [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.

1 participant