Skip to content

Premium Analytics: note adjustments in the Earnings History widget - #52526

Merged
dognose24 merged 6 commits into
trunkfrom
add/premium-analytics-earnings-history-adjustments-line
Sep 22, 2026
Merged

dognose24 merged 6 commits into
trunkfrom
add/premium-analytics-earnings-history-adjustments-line

Conversation

@dognose24

@dognose24 dognose24 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes WOOA7S-2155

Proposed changes

Adjustments are reconciliation rows: a transfer or a support compensation moves the All-time balance, and the adjustment bucket is the only thing that explains why the balance does not equal the sum of the WordAds months. Since #52420 removed the Adjustments History widget, the Earnings report's Adjustments tab (#52437) is their only home, and nothing on the Ads tab points there.

  • When the earnings payload carries at least one adjustment row, the Earnings History widget renders an N adjustments badge at the far end of its footer, opposite View all, linking into /reports/earnings?section=adjustments. The count is the number of adjustment rows, so it implies no sign; the amounts themselves stay on the report.
  • Sites without adjustments render exactly what they render today. Sites with them keep the same tile height and the same list, since the link shares the footer row.
  • notes is never read. It carries other blog IDs and, occasionally, Zendesk URLs.
  • The Storybook fixture already has two adjustment rows, so Default shows the line; a new NoAdjustments story shows the unchanged widget.

From Eder's design pass on the Slack thread: the adjustments link is a badge, without "Includes", so it cannot crowd View all in a narrow tile. ReportLink gained a children slot for it and drops its hover underline there. The other half of that pass, badges for the widget's status column, is #52565.

The card's own placement, a line between the list and the footer, was tried first and dropped: it cost the list a row and read as a stray line.

Without adjustments With adjustments
截圖 2026-09-21 下午4 26 25 截圖 2026-09-22 凌晨1 53 11

Related product discussion/links

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

No.

Testing instructions

Use a site with adjustment rows, or mock proxy/v1.1/wordads/earnings with at least one row in adjustment. On the local Docker site the zz-tmp-pa-wordads-mock.php mu-plugin returns two.

  • Open Stats → Ads. In Earnings History, confirm a 2 adjustments badge at the right end of the footer, with View all unchanged on the left.
  • Click the line: the Earnings report opens on the Adjustments history tab.
  • With one adjustment row the badge reads 1 adjustment.
  • Empty the adjustment bucket (wp option update jpa_mock_wordads_only 1 with the mu-plugin). Confirm the widget renders exactly as before: View all alone in the footer.
  • Keyboard: Tab from the list reaches View all, then the adjustments link; both show the inset focus ring.
  • jp test js packages/premium-analytics passes.

🤖 Generated with Claude Code

When the earnings payload carries adjustment rows, the widget renders an
"Includes N adjustments" link above its footer, into the Adjustments
history tab of the Earnings report. Sites without adjustments render
exactly as before. The amounts and notes stay on the report.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24
dognose24 requested a review from a team as a code owner September 21, 2026 07:18
@dognose24 dognose24 added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. labels Sep 21, 2026
@dognose24 dognose24 self-assigned this Sep 21, 2026
@github-actions github-actions Bot added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh labels Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/premium-analytics-earnings-history-adjustments-line branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/premium-analytics-earnings-history-adjustments-line
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/premium-analytics-earnings-history-adjustments-line

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Sep 21, 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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


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.

@jp-launch-control

jp-launch-control Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/widgets/wordads-earnings-history/render.tsx 5/5 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

dognose24 and others added 3 commits September 21, 2026 16:16
Second child of the footer, so View all keeps its place and the link takes
the far end only on sites that have adjustments. The tile height no longer
changes for them either.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…s-earnings-history-adjustments-line

# Conflicts:
#	projects/packages/premium-analytics/widgets/wordads-earnings-history/stories/wordads-earnings-history-widget.stories.tsx
Per Eder's design pass: the footer link is an "N adjustments" badge,
without "Includes", so it cannot crowd View all in a narrow tile.
ReportLink gains a children slot for it and drops its hover underline
there.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24
dognose24 force-pushed the add/premium-analytics-earnings-history-adjustments-line branch from b415768 to 8dcc8a3 Compare September 21, 2026 17:20
The link with content is an inline-flex box, so the badge inside it takes
its line height plus padding, matching the status badges.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Nikschavan
Nikschavan previously approved these changes Sep 22, 2026

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

Thank you, the changes look good. I left two comments inline: one on the badge link's accessible name, one on the singular test case.

What I checked: the Default and NoAdjustments stories from this branch in Storybook, the inset focus ring on the badge from the keyboard, and the footer at a 260px tile to confirm View all and the badge stay on one row.

Badge in the footer Without adjustments
Default story: 2 adjustments badge opposite View all NoAdjustments story: View all alone in the footer
Keyboard focus on the badge 260px tile
Inset focus ring around the badge Both footer links on one row at 260px

<ReportLink
report="earnings"
section="adjustments"
ariaLabel={ __( 'View adjustments history', 'jetpack-premium-analytics-pkg' ) }

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.

The aria-label replaces the badge text as the link's accessible name, so a screen reader announces "View adjustments history" and never the count, which is the one thing this badge adds over View all (render.tsx#L77). Voice control has the mirror problem: the visible "2 adjustments" is not part of the name, so speaking it does not activate the link (WCAG 2.5.3). A label built from the same _n() string, such as "2 adjustments, view adjustments history", would keep both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on both counts. The label is now built from the same _n() string as the badge, so the accessible name is "2 adjustments, view adjustments history" and the visible count is part of it.

await expect( screen.findByText( 'July 2026' ) ).resolves.toBeInTheDocument();

const link = screen.getByRole( 'link', { name: 'View adjustments history' } );
expect( link ).toHaveTextContent( label );

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.

toHaveTextContent( label ) matches a substring, so the 1-row case still passes when the singular form is lost: with both _n() forms set to %d adjustments the badge reads "1 adjustments", which contains "1 adjustment", and the suite stays green. Only the 2-row case catches a swap. An exact match such as getByText( label ) would make the singular row fail for its own reason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to an exact match inside the link: within( link ).getByText( label ). The singular row now fails on its own if the forms are swapped.

section="adjustments"
ariaLabel={ __( 'View adjustments history', 'jetpack-premium-analytics-pkg' ) }
>
<Badge intent="high">

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.

I wonder if Badge should be the link itself? We have to remove the link styling to make it fit, and @wordpress/ui describes Badge as a status label, not something you click.

If we want it to look like a chip, LinkButton may be a better fit. Right now the widget draws its own footer, but later, we will replace this with native widget actions the host draws it (WordPress/gutenberg#81740) and only uses Link or LinkButton. cc @retrofox

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point: nothing in the monorepo puts a Badge inside a link today, so this is a first. I tried a plain Adjustments link with a count badge beside it, but it reads as two things and drifts from Eder's single-chip design for this line; LinkButton keeps the shape but loses the intent colour.

I'd like to ship this as designed and settle the component question in a follow-up with Eder and @retrofox. The change is contained (ReportLink only gained a children slot), so swapping to Link or LinkButton later is a small local change. I'll open the follow-up and link it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up opened: WOOA7S-2194.

The aria-label replaced the badge text as the link's accessible name, so
screen readers never heard the count and voice control could not match
the visible "2 adjustments". Build the label from the same _n() string.

The test now matches the badge text exactly, so the singular row fails on
its own if the plural forms are swapped.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24
dognose24 merged commit 116c12b into trunk Sep 22, 2026
85 checks passed
@dognose24
dognose24 deleted the add/premium-analytics-earnings-history-adjustments-line branch September 22, 2026 16:10
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Sep 22, 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 [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh [Status] UI Changes Add this to PRs that change the UI so documentation can be updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants