Skip to content

Premium Analytics: Authors widget follow-ups#50078

Merged
Nikschavan merged 7 commits into
trunkfrom
update/pa-authors-widget-followups
Jun 30, 2026
Merged

Premium Analytics: Authors widget follow-ups#50078
Nikschavan merged 7 commits into
trunkfrom
update/pa-authors-widget-followups

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Jun 30, 2026

Copy link
Copy Markdown
Member

Fixes WOOA7S-1495

Proposed changes

Follow-ups to the Authors widget added in #49570:

  • Date range from URL, not a shadowed copy. render.tsx no longer passes attributes into WidgetRoot. The host injects a reportParams into the widget's attributes, and WidgetRoot would prefer that stale shadow copy over the live URL search params the date picker writes — so the date picker never reached the query. Dropping the prop lets WidgetRoot resolve report params from the URL the same way the other Stats widgets do. The widget's own max attribute is forwarded to the inner component instead.
  • Localize the untracked-authors sentinel. The Stats sanitizer substitutes an untranslated "Untracked Authors" sentinel for authors with no name. getAuthorLabel now matches that sentinel (and any empty label) and returns the localized __( 'Untracked authors' ) string. Added a test covering this.
  • Type the widget attributes. Introduced an exported AuthorsAttributes type in widget.ts and composed the render-only shape (AuthorsRenderAttributes) from it plus Partial<ReportParamsFieldAttributes>, instead of redeclaring an ad-hoc inline type. Also corrected the example attribute max from the string '7' to the number 7.
  • Center the chart empty state. Added margin-inline: auto so the empty state centers horizontally.

Related product discussion/links

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

No.

Testing instructions

  • Build/serve Premium Analytics and open a Stats dashboard with the Authors widget.
  • Change the dashboard date range via the date picker and confirm the Authors widget refetches and updates (previously it stayed stuck on the initial range).
  • Confirm authors with no name render as a localized "Untracked authors" label.
  • Confirm the chart empty state (no data) is horizontally centered.
  • Run the unit tests for the widget:
    • pnpm --filter ... test or run build-top-authors-data.test.ts to confirm the untracked-authors localization test passes.

@github-actions

github-actions Bot commented Jun 30, 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 Jun 30, 2026
@Nikschavan Nikschavan marked this pull request as ready for review June 30, 2026 10:54
@Nikschavan Nikschavan requested review from a team as code owners June 30, 2026 10:54
@Nikschavan Nikschavan requested review from chihsuan and Copilot June 30, 2026 10:54
@jp-launch-control

jp-launch-control Bot commented Jun 30, 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

@Nikschavan Nikschavan 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. labels Jun 30, 2026
@Nikschavan Nikschavan self-assigned this Jun 30, 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.

Pull request overview

Follow-up fixes for the Premium Analytics Authors widget to ensure it responds to dashboard date range changes, improves labeling for unnamed authors, and tightens typing/styling consistency.

Changes:

  • Adjust the Authors widget render flow to avoid stale reportParams overriding the live URL date range.
  • Localize the “Untracked Authors” sentinel coming from the Stats sanitizer, with unit test coverage.
  • Introduce a shared AuthorsAttributes type and correct the widget example attribute type; tweak empty-state centering styles.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
projects/packages/premium-analytics/widgets/authors/widget.ts Adds exported AuthorsAttributes and fixes example.attributes.max to a number.
projects/packages/premium-analytics/widgets/authors/render.tsx Changes how WidgetRoot is instantiated and composes render-time attribute types.
projects/packages/premium-analytics/widgets/authors/build-top-authors-data.ts Localizes the untracked-authors sentinel/empty label via getAuthorLabel.
projects/packages/premium-analytics/widgets/authors/tests/build-top-authors-data.test.ts Adds a test ensuring the sentinel label is localized.
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-empty-state/chart-empty-state.module.scss Adds margin-inline: auto for horizontal centering.
projects/packages/premium-analytics/changelog/update-pa-authors-widget-followups Adds a changelog entry describing the fixes.

Comment thread projects/packages/premium-analytics/widgets/authors/render.tsx
Comment thread projects/packages/premium-analytics/changelog/update-pa-authors-widget-followups Outdated
…ract

Reverts the attributes drop: the dashboard does not inject reportParams into
attributes (so the date-range URL still drives the query), and passing
attributes is required by the widget render contract and for the Storybook
WidgetDashboardWithWidget story.
Comment thread projects/packages/premium-analytics/widgets/authors/render.tsx Outdated
dognose24
dognose24 previously approved these changes Jun 30, 2026

@dognose24 dognose24 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.

Thanks for the follow-up fixes. This lines up with the Locations/Devices widget direction by keeping the render attributes passed into WidgetRoot and letting WidgetRoot handle the report params fallback. I left one non-blocking wording nit on the comment, but the implementation looks good to me.

@Nikschavan Nikschavan merged commit a724f8f into trunk Jun 30, 2026
72 checks passed
@Nikschavan Nikschavan deleted the update/pa-authors-widget-followups branch June 30, 2026 14:54
@github-actions github-actions Bot removed [Status] Needs Review This PR is ready for review. [Status] In Progress labels Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants