feat(premium-analytics): port data package from next-woocommerce-analytics#49263
Draft
chihsuan wants to merge 8 commits into
Draft
Conversation
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
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! |
0bc6f06 to
8ec819e
Compare
…ackage-into-analytics' into wooa7s-1316-integrate-data-package-into-analytics # Conflicts: # projects/packages/premium-analytics/package.json
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.
Proposed changes
Second leaf in M2 — Shared Packages Integration: port
@next-woo-analytics/datainto@automattic/jetpack-premium-analyticsas an internal package, stacked on the datetime port (#49221). Provides the analytics data layer — React Query report hooks, REST fetchers, query keys, response processing/normalization, prefetching, and the global query-client/error providers consumed by analytics widgets.Stacked on #49221 (WOOA7S-1312), which it consumes: every date/preset helper in this package now imports from the already-integrated
@jetpack-premium-analytics/datetime.Commits
Reviewed most easily commit-by-commit — the verbatim copy is isolated first, so every later diff shows exactly what the monorepo port changed.
5640b43a30f4f06289418510450d21cacb76f756b8a36689ac8ec819e4c1What's in the package
src/api/**src/queries/**queryKey/queryFndefinitions per reportsrc/hooks/**useReport*hooks (anduseProductImages) wrapping the queriessrc/processing/**src/providers/**AnalyticsQueryClientProvider,QueryClientconfig, and global error context/managersrc/prefetch/**prefetchReportfor warming the cachesrc/utils/**datetime), parsing, product filters, searchsrc/defaults/**,src/types/**,src/types.tsMonorepo adaptations
name: @next-woo-analytics/dataname: @automattic/jetpack-premium-analytics-dataREADME.md): the import specifier (@jetpack-premium-analytics/data) comes fromwpPlugin.packageNamespace; thename:field is separate and uses the@automattic/...formimport … from '@next-woo-analytics/datetime'… from '@jetpack-premium-analytics/datetime'import type { FilterCondition } from '@next-woo-analytics/data'(self-import)../../types/filter-conditionimport { useExperiments } from '@automattic/admin-toolkit'(gates devtools)areQueryDevtoolsEnabled()flagadmin-toolkitdependency; devtools stay lazy + Suspense-gated, now opt-in (OFF by default; enable viawindow.jetpackPremiumAnalyticsQueryDevtools = true, or automatically outside production)@tanstack/react-routerindependencies*version specs@tanstack/react-query 5.90.8,@wordpress/api-fetch 7.46.0,@wordpress/url 4.46.0,@wordpress/core-data 7.46.0,@tanstack/react-query-devtools 5.90.2)my-jetpacketc.)'woocommerce-analytics'text domain'jetpack-premium-analytics'tsconfig.jsonincludes: [packages/**/*]and supplies the@jetpack-premium-analytics/*path alias; mirrorspackages/datetime/Parent-level wiring (
projects/packages/premium-analytics/):package.json: adds the real deps (@tanstack/react-query,@wordpress/api-fetch,@wordpress/core-data,@wordpress/url;date-fns/@date-fns/tz/@wordpress/data/@wordpress/i18nalready present) plus@tanstack/react-query-devtools(dev). The leaf isn't a pnpm workspace member (the root glob doesn't reach two levels in), so the parent's deps are the load-bearing ones. Nolink:dependency is added yet — nothing importsdata(same as datetime); the first consumer will add it.eslint.config.mjs(temporary): extends the existing datetime JSDoc softening topackages/data/**, and adds a small data-only block (keeps upstream's intentionalas anygeneric-TDataescapes and silences thereactextraneous-dependency false positive).tests/jest.config.cjs(extendsjetpack-js-tools/jest/config.base.js, maps@jetpack-premium-analytics/*to source), ababel.config.cjs(Jetpack webpack babel preset, for the test transform), atestscript, and@types/jest/jest/@automattic/jetpack-webpack-configdev deps — so the 4 ported tests run and the test globals typecheck.What's intentionally not here
@automattic/admin-toolkit/ experiments dependency — replaced by the local devtools flag described above.@tanstack/react-router— unused upstream.link:dependency on the parent —dataisn't imported anywhere yet, so wiring it into the build is deferred to the first consumer (mirrors datetime). This also avoids theeslint-plugin-package-jsonlink:conflict feat(premium-analytics): port datetime package from next-woocommerce-analytics #49221 flagged.eslint.config.mjscomments.Does this pull request change what data or activity we track or use?
No.
Testing instructions
Requires Node 24 (repo
engineStrict).Optional — build-time resolution via
link:(confirms wp-build tracks the package as a module dependency once a consumer imports it):projects/packages/premium-analytics/package.jsondependencies:"@jetpack-premium-analytics/data": "link:packages/data"(add"@jetpack-premium-analytics/datetime": "link:packages/datetime"too if you want datetime resolved at build time). Thevalid-dependencieslint rejectslink:— relax it for the temp edit.dataexport inroutes/dashboard/stage.tsx.pnpm install && pnpm build→build/routes/dashboard/content.min.asset.phplists the dependency undermodule_dependencies.pnpm install.