Skip to content

Premium Analytics: align Stats normalizers with legacy rows#49877

Merged
kangzj merged 3 commits into
trunkfrom
fix/stats-normalizer-calypso-parity
Jun 24, 2026
Merged

Premium Analytics: align Stats normalizers with legacy rows#49877
kangzj merged 3 commits into
trunkfrom
fix/stats-normalizer-calypso-parity

Conversation

@kangzj

@kangzj kangzj commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #

Proposed changes

  • Align Stats traffic row metadata with the legacy Calypso Stats list normalizers.
  • Strip parent names from nested referrer labels and preserve the legacy spam-action eligibility logic.
  • Preserve link actions for top-author post children and video-play rows.
  • Match legacy click child-label behavior by removing only the first parent-name occurrence.
  • Add regression tests for the adjusted row metadata.

Related product discussion/links

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

No. This only adjusts client-side normalization of existing Stats API response data.

Testing instructions

  • Run pnpm --dir projects/packages/premium-analytics test --runInBand projects/packages/premium-analytics/packages/data/src/processing/stats.
  • Run pnpm --dir projects/packages/premium-analytics typecheck.
  • Run pnpm run lint-file projects/packages/premium-analytics/packages/data/src/processing/stats/referrers.ts projects/packages/premium-analytics/packages/data/src/processing/stats/top-authors.ts projects/packages/premium-analytics/packages/data/src/processing/stats/clicks.ts projects/packages/premium-analytics/packages/data/src/processing/stats/video-plays.ts projects/packages/premium-analytics/packages/data/src/processing/stats/__tests__/referrers.test.ts projects/packages/premium-analytics/packages/data/src/processing/stats/__tests__/top-authors.test.ts projects/packages/premium-analytics/packages/data/src/processing/stats/__tests__/clicks.test.ts projects/packages/premium-analytics/packages/data/src/processing/stats/__tests__/video-plays.test.ts --max-warnings=0.
  • Run pnpm --dir projects/packages/premium-analytics test --runInBand.

@kangzj kangzj requested review from a team as code owners June 24, 2026 02:32
@kangzj kangzj added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. labels Jun 24, 2026
@kangzj kangzj self-assigned this Jun 24, 2026
@kangzj kangzj added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. labels Jun 24, 2026
@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!

@jp-launch-control

jp-launch-control Bot commented Jun 24, 2026

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

@kangzj

This comment has been minimized.

@claude

This comment has been minimized.

@kangzj

This comment has been minimized.

@claude

This comment has been minimized.

@kangzj

kangzj commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Review-cycle summary - 15e5df0caa -> cfde7a0ffd

2 round(s); CI green; 0 inline threads resolved; Claude feedback addressed.

What changed during the cycle

Commits added:

  • cfde7a0ffd - Address review: cover referrer spam URL branch (comment #4785396806)

Diff summary: 1 file changed, 40 insertions(+)

Review feedback addressed:

Source Comment Resolution
Claude #4785396806 Added a regression test for the referrers canSpam URL branch, also pinning single-result label vs spam-domain behavior.

Unaddressed human comments: None.

CI: all required checks passing.

@kangzj kangzj added [Status] Needs Team Review Obsolete. Use Needs Review instead. and removed [Status] Needs Review This PR is ready for review. labels Jun 24, 2026
chihsuan
chihsuan previously approved these changes Jun 24, 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 @kangzj LGTM!

One non-blocking thought: Could the new conditionals get a few negative-case tests?

the new conditionals are tested positive-only. A actions: [] assertion for the no-url case (top-authors/video-plays) and a negative canSpam case (url excludes item.name) would catch an over-broad condition later. Not blocking.

@kangzj

kangzj commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Addressed Chihsuan's review in #49877 (review).

Added negative-case coverage for:

  • top authors posts without url -> actions: [] and link: null
  • video play rows without url -> actions: [] and link: null
  • referrer URL branch where url excludes item.name -> no spam action and actionMenu: 0

Verification:

  • pnpm --dir projects/packages/premium-analytics test --runInBand packages/data/src/processing/stats/__tests__/top-authors.test.ts packages/data/src/processing/stats/__tests__/video-plays.test.ts packages/data/src/processing/stats/__tests__/referrers.test.ts
  • pnpm run lint-file projects/packages/premium-analytics/packages/data/src/processing/stats/__tests__/top-authors.test.ts projects/packages/premium-analytics/packages/data/src/processing/stats/__tests__/video-plays.test.ts projects/packages/premium-analytics/packages/data/src/processing/stats/__tests__/referrers.test.ts --max-warnings=0

@kangzj kangzj merged commit d94827b into trunk Jun 24, 2026
74 checks passed
@kangzj kangzj deleted the fix/stats-normalizer-calypso-parity branch June 24, 2026 07:26
@github-actions github-actions Bot removed the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Jun 24, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants