Skip to content

Premium Analytics: port Stats Referrers widget#50172

Draft
Nikschavan wants to merge 1 commit into
trunkfrom
wooa7s-1490-port-jetpack-stats-module-referrers
Draft

Premium Analytics: port Stats Referrers widget#50172
Nikschavan wants to merge 1 commit into
trunkfrom
wooa7s-1490-port-jetpack-stats-module-referrers

Conversation

@Nikschavan

Copy link
Copy Markdown
Member

Fixes WOOA7S-1490

Proposed changes

Ports the Jetpack Stats Referrers module into Premium Analytics as the jpa/referrers widget.

  • Adds the Referrers widget: a ranked leaderboard of websites and search engines referring visitors, backed by the Jetpack Stats API via the existing useStatsReferrers data hook.
  • Supports two-level drill-down (e.g. Search Engines → Google Search → google.com), with scoped row keys so same-named rows at different levels don't collide.
  • Adds a shared WidgetBackLink component and useDrillDown hook to widgets-toolkit for nested leaderboard widgets; the back link renders in the widget body while the host frame keeps the title static.
  • Merges comparison-period values by scoped key before slicing primary rows, so deltas survive ordering differences between periods.
  • Renders childless referrers as plain rows without outbound links.
  • Handles max = 0 as "all rows", plus loading, empty, and error states per the widget guidelines.
  • Adds Stats referrers fixtures to the Storybook mocks (register-stats-mocks.ts).
  • Adds Default, WithComparison, and WidgetDashboardWithWidget stories.
  • Adds JS unit coverage for drill-down navigation, childless rows, comparison merging, max semantics, and the new useDrillDown hook.

Related product discussion/links

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

No. This reads existing Jetpack Stats referrers data through the existing Premium Analytics stats data layer.

Testing instructions

Run focused checks:

pnpm --dir projects/packages/premium-analytics exec jest --config=tests/jest.config.cjs widgets/referrers/__tests__/referrers.test.tsx
pnpm --dir projects/packages/premium-analytics exec jest --config=tests/jest.config.cjs packages/widgets-toolkit/src/hooks/__tests__/use-drill-down.test.ts
pnpm --dir projects/packages/premium-analytics run typecheck

In Storybook:

  1. Open Packages/Premium Analytics/Widgets/Referrers.
  2. Confirm Default, WithComparison, and WidgetDashboardWithWidget render correctly.
  3. Drill into a referrer group (e.g. Search Engines), then into a source, and use the back link to return each level.
  4. Confirm comparison deltas appear in WithComparison.

On a Jetpack-connected test site with referrer traffic:

  1. Open Premium Analytics and add the Referrers widget from the picker.
  2. Confirm referrers render as ranked rows with view counts and favicons.
  3. Drill into a group with nested sources and navigate back with the back link.
  4. Confirm childless referrers are plain rows, not links.
  5. Select a date range with no referrer data and confirm the empty state appears.

Adds the jpa/referrers widget with drill-down through referrer
groups and sources, plus a shared WidgetBackLink component and
useDrillDown hook in widgets-toolkit.
@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

github-actions Bot commented Jul 2, 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!

@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 Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant