WOOA7S-1502: Port Stats Shares widget#50394
Merged
Merged
Conversation
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes WOOA7S-1502
Proposed changes
Ports the Jetpack Stats Shares module into a registered Premium Analytics widget (
jpa/shares).Why. This is a re-do of #50148, which is being closed. That PR rendered Publicize follower counts (via
useStatsPublicize) — the data behind the upstreamstats-reachmodule — rather than the Shares module this issue is scoped to. The upstream source (stats-shares.tsx) is the "Number of Shares" card: how many times content was shared to each social network, not follower counts.How. The share counts already live on the site summary (
statsendpoint) asshares_<service>fields, so the widget reads them through the existinguseStatsSitehook — no new data-package hook or query. A widget-local view hook (use-share-views.ts) scans theshares_<service>summary keys, labels known services, sorts by count, and trims tomax. The summary is all-time with no comparison period, so the widget renders current counts with no period-over-period deltas.Design note — data-driven service list (intentional divergence from upstream). Upstream
stats-shares.tsxintersects the counts withuseSharingButtonsQuery— the site's currently enabled sharing buttons. Because share counts are all-time historical, that approach hides historical shares for any network whose share button was later turned off (e.g. years of Facebook shares vanish the moment the Facebook button is disabled). This widget instead derives the service list from the summary's ownshares_<service>keys, so historical counts stay visible regardless of the current button config, and a network Jetpack adds server-side shows up automatically — no extra sharing-buttons query. The single assumption, that everyshares_<service>key is a per-network count, is pinned with a comment in the hook.What.
widgets/shares/workspace package:package.json,widget.json,widget.ts,use-share-views.ts,render.tsx,style.module.css, and a Storybook story.<WidgetRoot>seeded with hostattributes, and<WidgetState>(not the legacyWidgetLoadingOverlay) for loading/error/empty. Empty state uses a neutral glyph and the upstream "Learn where your content has been shared the most." copy./statssummary is already routed byregisterReportMocks(), so this only addsshares_*fields to the existingsite-summaryfixture — no story-scopedapiFetchmiddleware.No changes to
packages/data,packages/widgets-toolkitsource, or@automattic/charts.Follow-up. WOOA7S-1706 tracks unifying this widget-local service-label map with the data package's
publicizeServicesregistry into one shared source (and giving Shares the service icons the Reach widget already renders), so the two social widgets stay visually consistent. Kept out of this PR to leave the data source untouched.Does this pull request change what data or activity we track or use?
No. It surfaces existing Jetpack Stats share-count data through a new dashboard widget.
Testing instructions
pnpm --dir projects/js-packages/storybook run storybook:dev→ open Packages / Premium Analytics / Widgets / Shares and confirm theDefault,WithComparison, andWidgetDashboardWithWidgetstories render a populated leaderboard (Facebook / Twitter / LinkedIn / Tumblr).WithComparisonshows the same counts with no deltas, as documented./widget-audit sharesclean,eslintclean,tsgotypecheck clean, andjetpack build --deps packages/premium-analyticssucceeds (jpa/sharesappears in the generated widget registry).Screen.Recording.2026-07-13.at.3.55.44.PM.mov