Premium Analytics: add Stats proxy data hooks - #49773
Conversation
|
@claude please review this PR. |
|
Claude finished @kangzj's task in 2m 45s —— View job PR Review: Premium Analytics Stats proxy data hooks
Nice, well-structured PR. The layering (fetch → query factory → hook) is clean and consistent with the existing Woo report hooks, and the 🐛 Object spread overrides sanitized
|
|
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! |
There was a problem hiding this comment.
Pull request overview
Adds a Premium Analytics data-layer surface for the unified Stats proxy route, including fetch utilities, React Query query factories, useStats… hooks/mutations, and response normalization for common widget/report-style payloads.
Changes:
- Introduces
fetchStatsProxy/getStatsProxyPathand Stats query factories for many Stats endpoint families. - Adds Stats response normalizers plus fixture-backed unit tests.
- Exposes
useStats…hooks and re-exports Stats APIs/types from the data package entrypoints.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/premium-analytics/packages/data/src/utils/stats-params.ts | Adds helpers to convert report params into Stats query params and build stable query-key parts. |
| projects/packages/premium-analytics/packages/data/src/utils/tests/stats-params.test.ts | Tests interval→period mapping and report→stats param conversion. |
| projects/packages/premium-analytics/packages/data/src/queries/stats-queries.ts | Adds React Query option factories for many Stats endpoints via the proxy fetcher. |
| projects/packages/premium-analytics/packages/data/src/queries/index.ts | Re-exports Stats queries. |
| projects/packages/premium-analytics/packages/data/src/processing/stats/index.ts | Adds Stats response normalization utilities/types. |
| projects/packages/premium-analytics/packages/data/src/processing/stats/tests/stats.test.ts | Tests key normalizers using fixtures. |
| projects/packages/premium-analytics/packages/data/src/processing/stats/fixtures/stats.ts | Provides fixture payloads for normalizer tests. |
| projects/packages/premium-analytics/packages/data/src/processing/index.ts | Re-exports Stats processing. |
| projects/packages/premium-analytics/packages/data/src/index.ts | Exports Stats hooks, proxy helpers, query/utils, and normalized types. |
| projects/packages/premium-analytics/packages/data/src/hooks/use-stats.ts | Adds useStats… hooks and mutations for Stats proxy endpoints. |
| projects/packages/premium-analytics/packages/data/src/hooks/use-report.ts | Generalizes useReport params typing and broadens primary/comparison param forwarding. |
| projects/packages/premium-analytics/packages/data/src/hooks/index.ts | Re-exports Stats hooks. |
| projects/packages/premium-analytics/packages/data/src/hooks/tests/stats-exports.test.ts | Ensures useStats… hooks are exported from the package entry. |
| projects/packages/premium-analytics/packages/data/src/api/stats-proxy-fetch.ts | Adds Stats proxy fetcher and URL builder for /jetpack-premium-analytics/v1/proxy/v<version>/…. |
| projects/packages/premium-analytics/packages/data/src/api/index.ts | Re-exports Stats proxy fetch APIs/types. |
| projects/packages/premium-analytics/packages/data/src/api/constants.ts | Adds statsProxyPath constant. |
| projects/packages/premium-analytics/packages/data/src/api/tests/stats-proxy-fetch.test.ts | Tests Stats proxy path construction (including comma segments). |
| projects/packages/premium-analytics/changelog/add-stats-proxy-data-hooks | Adds changelog entry for the new data hooks. |
|
I'm adding everything in one-go and potentially split up in smaller chunks for reviews. |
e4efb58 to
d9a2820
Compare
|
@claude please review the latest changes. Implemented the follow-up pass after checking live Stats endpoint shapes:
Validation:
|
|
Claude finished @kangzj's task in 2m 18s —— View job PR Review: latest changes (follow-up pass)
Thanks for the thorough follow-up — this is a solid pass. I confirmed the earlier feedback is all addressed, and the new app/report split reads cleanly. One concrete server-contract bug stands out, plus a couple of small notes. ✅ Previous feedback — verified fixed
🐛
|
|
Addressing Claude follow-up review: the unsupported |
|
@claude please re-review the latest changes. Outstanding feedback addressed:
Validation after latest changes:
All inline review threads that were already addressed have been replied to with the relevant hash and resolved. |
|
Claude finished @kangzj's task in 1m 13s —— View job PR Re-review: Premium Analytics Stats proxy data hooks
Thanks for the thorough follow-up — everything I flagged as blocking or worth-a-guard is now resolved. This looks ready to me. ✅ Outstanding feedback — verified fixed
💬 Non-blocking, for whenever the consuming screens landThese are carried-over notes, not regressions — fine to defer:
Net: the blocking
|
|
Additional minor/nit follow-up addressed in
Validation after this commit:
|
|
Moved subscriber counts and WordAds earnings back into the stats hook/query surface in
Validation before commit:
|
Proposed changes
useStats...hooks and mutations for the WPCOM-proxied Stats endpoint families from Premium Analytics: extend the API proxy to cover Stats-Admin endpoints #49571.Related product discussion/links
Does this pull request change what data or activity we track or use?
No. This adds frontend data-layer access to existing proxied Stats endpoints and does not add or change tracking.
Testing instructions
pnpm --dir projects/packages/premium-analytics testpnpm --dir projects/packages/premium-analytics typecheckpnpm --dir projects/packages/premium-analytics build