Skip to content

[WIP] feat(premium-analytics): port components package from next-woocommerce-analytics#49360

Draft
chihsuan wants to merge 8 commits into
wooa7s-1318-base-datetime-formattersfrom
wooa7s-1318-integrate-components-package-into-analytics
Draft

[WIP] feat(premium-analytics): port components package from next-woocommerce-analytics#49360
chihsuan wants to merge 8 commits into
wooa7s-1318-base-datetime-formattersfrom
wooa7s-1318-integrate-components-package-into-analytics

Conversation

@chihsuan
Copy link
Copy Markdown
Member

@chihsuan chihsuan commented Jun 3, 2026

Proposed changes

First UI leaf in M2 — Shared Packages Integration: port @next-woo-analytics/components into @automattic/jetpack-premium-analytics as the internal ui package. Provides the date-filtering UI consumed by analytics widgets — the date-range popover (calendar + presets + manual inputs), the comparison dropdown, and the DateFiltersPanel container that ties them together — plus the SCSS for all of it. This is the first ported package that ships React components and styles.

It depends on both previously ported leaves, so this branch is built on an integration base that merges them in:

Base note: this PR targets wooa7s-1318-base-datetime-formatters — an integration branch (wooa7s-1320-… + the unmerged datetime #49221 and formatters #49226 dep branches merged in). Targeting it keeps this diff to only the ui package + parent wiring. Those two deps must land before (or with) this; the base will be re-pointed once they do.

Commits

Reviewed most easily commit-by-commit — the verbatim copy is isolated first, so every later diff shows exactly what the monorepo port changed.

Commit Subject
d17e81031e feat(premium-analytics): add ui package from next-woocommerce-analytics components
41d3f1bc5f refactor(premium-analytics): adapt ui package imports and manifest for monorepo
196765f562 refactor(premium-analytics): decouple ui package from admin-toolkit unlock
77b5215577 style(premium-analytics): align ported ui package with jetpack prettier
806998be42 fix(premium-analytics): satisfy ui package typecheck and import lint
f5dc81dd44 chore(premium-analytics): wire ui package deps and relax lint for the port
224ba59624 changelog: add entry for premium-analytics ui package port

What's in the package

Path Purpose
src/date-filters-panel/** DateFiltersPanel — the package's public entry; owns comparison state and composes the popover + comparison dropdown
src/date-range-popover/** DateRangePopover / DateRangePopoverContent — responsive calendar + presets + manual inputs in a dropdown
src/date-range-presets/** DateRangePresets (preset menu); also re-exports datetime preset constants/types for existing barrel consumers
src/date-range-input/** DateRangeInput — typed from/to date fields
src/date-comparison-dropdown/** DateComparisonDropdown — comparison preset menu
src/use-comparison-date-presets/** useComparisonDatePresets hook (derives comparison presets from a primary range)
src/lock/unlock.ts Local @wordpress/private-apis unlock helper (replaces @automattic/admin-toolkit)
src/**/*.scss Component styles (first ported package with SCSS)

Monorepo adaptations

Upstream Here Why
dir packages/components dir packages/ui @wordpress/build hard-codes an Emotion Babel pass for any package directory literally named components (needsEmotionPlugin = packageName === 'components'), which runs Babel without a TypeScript preset and breaks TS transpilation. These components use SCSS, not Emotion, so the pass is incidental — naming the dir ui lets esbuild transpile the TS natively with no extra Babel tooling
name: @next-woo-analytics/components name: @automattic/jetpack-premium-analytics-ui Internal-packages convention; the import specifier is @jetpack-premium-analytics/ui (from the tsconfig path alias), separate from the name: field
… from '@next-woo-analytics/datetime' (11 imports) … from '@jetpack-premium-analytics/datetime' Consume the integrated datetime package
… from '@wc-analytics/formatters' … from '@jetpack-premium-analytics/formatters' Consume the integrated formatters package (only formatDate + formatDateRange are used)
import { unlock } from '@automattic/admin-toolkit' (3 files) local src/lock/unlock.ts via @wordpress/private-apis admin-toolkit isn't available here. The helper opts in with __dangerousOptInToUnstableAPIsOnlyForCoreModules to reach the private Menu of @wordpress/components — mirrors existing Jetpack precedent (jetpack-mu-wpcom getUnlock, js-packages/charts stories)
@next-woo-analytics/data, @automattic/design-system in dependencies dropped Declared upstream but imported nowhere in the components source
@next-woo-analytics/components Storybook stories (3) dropped premium-analytics has no Storybook build; nothing non-story re-exports them
'woocommerce-analytics' text domain 'jetpack-premium-analytics' Matches the package's text domain
Leaf tsconfig.json (deleted) Parent already includes: [packages/**/*] and supplies the @jetpack-premium-analytics/* path alias; mirrors packages/datetime / packages/formatters
* version specs pinned (@automattic/ui 1.0.2, @wordpress/components 33.1.0, @wordpress/compose 7.46.0, @wordpress/ui 0.13.0, @wordpress/private-apis 1.46.0, clsx 2.1.1) Jetpack convention; versions match siblings
Upstream prettier/import-order style re-run through Jetpack ESLint + prettier Aligns the port with monorepo formatting

One small TS adaptation worth flagging: DateComparisonDropdown reuses DateRangePresets (typed for primary presets) to render comparison presets. Upstream's looser tsc allowed it; the repo's tsgo does not, so the two props are cast at that one call site with a comment — the component only reads id/label/range to render, so the runtime shape matches.

Parent-level wiring (projects/packages/premium-analytics/):

  • package.json: adds the real runtime deps imported by the components (@automattic/ui, @wordpress/components, @wordpress/compose, @wordpress/private-apis, @wordpress/ui, clsx; @wordpress/icons / date-fns already present), plus @wordpress/base-styles (dev) so the SCSS @use "@wordpress/base-styles/…" resolves at build time. 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. No link: dependency is added yet — nothing imports ui (same as datetime/formatters); the first consumer will add it.
  • eslint.config.mjs (temporary): extends the existing JSDoc softening to packages/ui/** and additionally relaxes react/jsx-no-bind + jsdoc/require-jsdoc/escape-inline-tags so the upstream inline-handler JSX style lands as-is. Tracked for follow-up alongside datetime/formatters.

Build / SCSS

pnpm build (wp-build) transpiles every internal package; ui now transpiles cleanly and its SCSS compiles — @use "@wordpress/base-styles/colors" resolves ($gray-300#ddd), --wpds-* tokens and class names are emitted, and the compiled CSS is inlined into the per-component output as a runtime style injection. Like datetime/formatters, the package is a library (not a build target), so it only lands in build/ once a route imports it; building it standalone confirms the JS and styles compile.

What's intentionally not here

  • No @automattic/admin-toolkit — replaced by the local unlock helper.
  • No Storybook — stories dropped (no Storybook build here).
  • No @next-woo-analytics/data / @automattic/design-system — declared upstream, imported nowhere.
  • No link: dependency on the parentui isn't imported anywhere yet, so wiring it into the build is deferred to the first consumer (mirrors datetime/formatters).
  • No JSDoc backfill / formatting cleanup of upstream patterns — out of scope; tracked by the temporary eslint.config.mjs comments.

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

No.

Testing instructions

Requires Node 24 (repo engineStrict).

pnpm install
cd projects/packages/premium-analytics
pnpm typecheck   # tsgo --noEmit — 0 errors
pnpm build       # wp-build — passes; ui transpiles + SCSS compiles
pnpm exec eslint --flag v10_config_lookup_from_file --max-warnings=0 packages/ui/   # clean

@chihsuan chihsuan self-assigned this Jun 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

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 wooa7s-1318-integrate-components-package-into-analytics branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack wooa7s-1318-integrate-components-package-into-analytics
bin/jetpack-downloader test jetpack-mu-wpcom-plugin wooa7s-1318-integrate-components-package-into-analytics

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

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!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jun 3, 2026
@chihsuan chihsuan changed the base branch from wooa7s-1320-configure-workspace-and-typescript-for-internal-packages to wooa7s-1318-base-datetime-formatters June 3, 2026 06:59
@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented Jun 3, 2026

Code Coverage Summary

No summary data is available for parent commit d69730d, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for d69730d is available.

Full summary · PHP report · JS report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs [Package] Premium Analytics [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant