feat(premium-analytics): port routing package from next-woocommerce-analytics#49266
Draft
chihsuan wants to merge 7 commits into
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! |
0bc6f06 to
8ec819e
Compare
25e6b44 to
9b948a7
Compare
…ge-into-analytics' into wooa7s-1317-integrate-routing-package-into-analytics
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
Third leaf in M2 — Shared Packages Integration: port
@next-woo-analytics/routinginto@automattic/jetpack-premium-analyticsas an internal package, stacked on the data port (#49263). Provides the routing/URL-search layer — date-range and comparison search-param encoders that write to the URL via@wordpress/route, thederiveComparisonRangehelper, and theuseStagedSearchhook (staged UI edits + atomic URL commits).Routing is Layer 1 and depends on both already-integrated packages: every helper imports from
@jetpack-premium-analytics/dataand@jetpack-premium-analytics/datetime, so this stacks on #49263 (WOOA7S-1316), which itself stacks on the datetime port (#49221).Commits
Reviewed most easily commit-by-commit — the verbatim copy is isolated first, so every later diff shows exactly what the monorepo port changed.
bb049fbeae4234b7862c18c468ea92b30249156525e6b441a3What's in the package
src/search/date-range/**encodeDateToSearchParam,writeDateRangeToSearch,writeComparisonToSearch— serializeDateRange/comparison state to ISO(+offset) URL params vianavigate()src/search/comparison/**deriveComparisonRange— derivecompare_from/compare_tofrom the main range + preset, honoring the site timezonesrc/hooks/use-staged-search/**useStagedSearch— stage UI edits locally and commit them atomically to the URL (with optional debounced auto-commit); includes its usage READMEsrc/hooks/use-date-range-search/**src/index.tsMonorepo adaptations
name: @next-woo-analytics/routingname: @automattic/jetpack-premium-analytics-routingREADME.md): the import specifier (@jetpack-premium-analytics/routing) comes fromwpPlugin.packageNamespace; thename:field is separate and uses the@automattic/...formimport … from '@next-woo-analytics/data'/'…/datetime'… from '@jetpack-premium-analytics/data'/'…/datetime'@next-woo-analytics/routingin doc examples@jetpack-premium-analytics/routing@tanstack/react-routerindependenciesdate-fnsindependencies@wordpress/routeis the only external runtime dep and is already on the parent manifest*version specs@wordpress/route 0.12.0)tsconfig.jsonincludes: [packages/**/*]and supplies the@jetpack-premium-analytics/*path alias; mirrorspackages/datetime/andpackages/data/Parent-level wiring (
projects/packages/premium-analytics/):package.json: adds@jetpack-premium-analytics/routing: link:packages/routingso the build resolves the package.@wordpress/routeand the data/datetime links are already present from the earlier ports — nothing else to add.eslint.config.mjs(temporary): extends the existing JSDoc-softening glob topackages/routing/**, and adds a small routing-only block that silences thereactextraneous-dependency false positive (the hook importsreactdirectly; the internal package's deps live on the parent manifest).What's intentionally not here
@tanstack/react-router— unused upstream.date-fnsleaf dep — not imported by routing.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/routing": "link:packages/routing"(addlink:entries for@jetpack-premium-analytics/dataand@jetpack-premium-analytics/datetimetoo if you want its internal deps resolved at build time). Thevalid-dependencieslint rejectslink:— relax it for the temp edit.routingexport inroutes/dashboard/stage.tsx.pnpm install && pnpm build→build/routes/dashboard/content.min.asset.phplists the dependency undermodule_dependencies.pnpm install.