Skip to content

Premium Analytics: port the Average order value widget#49578

Merged
chihsuan merged 5 commits into
trunkfrom
add/wooa7s-1461-port-woo-widget-average-order-value
Jul 2, 2026
Merged

Premium Analytics: port the Average order value widget#49578
chihsuan merged 5 commits into
trunkfrom
add/wooa7s-1461-port-woo-widget-average-order-value

Conversation

@nerrad

@nerrad nerrad commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Fixes: WOOA7S-1461

Proposed changes

  • Ports the Average order value widget into the Premium Analytics customizable dashboard.
  • Registers the jpa/average-order-value widget and renders the shared order metric widget inside WidgetRoot using dashboard-level report params.
  • Passes the dashboard widget error callback through to WidgetRoot so order-report failures can surface through the dashboard error UI.
  • Adds standalone Default and WithComparison Storybook stories plus a dashboard-hosted WidgetDashboardWithWidget story for the widget.

Finishing changes (conform to the widget contract)

  • Reverted the comparative-line-chart wrapper to import LineChart from the public @automattic/charts export (the export exists on trunk), so the shared toolkit file is now unchanged vs trunk and this widget is fully independent.
  • render.tsx now types props with WidgetRenderProps<T> from @wordpress/widget-primitives, composing the widget's own attribute type with Partial<ReportParamsFieldAttributes>, and defaults attributes = {}.
  • widget.ts declares the empty attribute shape as Record<never, never>.
  • package.json: dropped the unused @wordpress/ui, added @wordpress/widget-primitives.
  • Removed the spurious js-packages/storybook changelog entry (that project has no code changes; the changelog check passes without it).

Related product discussion/links

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

No.

Testing instructions

  • pnpm --filter @automattic/jetpack-premium-analytics typecheck
  • pnpm --filter @automattic/jetpack-premium-analytics build
  • From projects/js-packages/storybook, run Storybook (pnpm exec storybook dev -c ./storybook) and open the Packages / Premium Analytics / Widgets / AverageOrderValue stories.
  • Confirm Default shows the metric value, WithComparison shows the value plus the comparative line chart, and WidgetDashboardWithWidget renders the widget in the host dashboard card.

@github-actions

Copy link
Copy Markdown
Contributor

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!

@jp-launch-control

jp-launch-control Bot commented Jun 12, 2026

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report

@nerrad nerrad force-pushed the update/pa-introduce-customize-dashboard branch from 5bb6dd9 to 7ff7f71 Compare June 17, 2026 11:19
@nerrad nerrad force-pushed the add/wooa7s-1461-port-woo-widget-average-order-value branch 4 times, most recently from 911c952 to 06031fb Compare June 17, 2026 17:28
@louwie17 louwie17 force-pushed the update/pa-introduce-customize-dashboard branch from 7ff7f71 to 22e10a7 Compare June 19, 2026 12:21
@nerrad nerrad force-pushed the add/wooa7s-1461-port-woo-widget-average-order-value branch from a98ad6b to 5b0fb75 Compare June 23, 2026 12:49
@nerrad nerrad changed the base branch from update/pa-introduce-customize-dashboard to trunk June 23, 2026 12:50
@nerrad nerrad force-pushed the add/wooa7s-1461-port-woo-widget-average-order-value branch 2 times, most recently from d1eb44f to ef63280 Compare June 25, 2026 00:52
nerrad and others added 5 commits July 2, 2026 17:06
Port the Average order value widget from next-woocommerce-analytics (woocommerce/woocommerce-analytics@develop) into the Premium Analytics customizable dashboard (WOOA7S-1461).

Same composition shape as the average-items-per-order port: report data via @jetpack-premium-analytics/data (useReportOrders), rendering via the widgets-toolkit (WidgetRoot + OrderMetricWidget, average_order_value metric), and the Range editor via the fields package's ReportParamsField as an externalized script module.

Adds the icons and widgets-toolkit link: entries and the widgets/** lint relaxations this widget needs.
@chihsuan chihsuan force-pushed the add/wooa7s-1461-port-woo-widget-average-order-value branch from ef63280 to ac1f2ed Compare July 2, 2026 09:22
@chihsuan chihsuan self-assigned this Jul 2, 2026
@chihsuan chihsuan marked this pull request as ready for review July 2, 2026 09:22
@chihsuan chihsuan requested review from a team as code owners July 2, 2026 09:22
@chihsuan

chihsuan commented Jul 2, 2026

Copy link
Copy Markdown
Member

Rebased on trunk, conformed the port to the current widget contract, and reverted the comparative-line-chart import back to the public @automattic/charts LineChart export so the shared toolkit file is unchanged vs trunk — the widget is now fully independent.

Changed

  • packages/widgets-toolkit/.../chart-comparative-line/comparative-line-chart.tsx — restored import { LineChart } from '@automattic/charts' (drops the deep-relative import; file now matches trunk).
  • widgets/average-order-value/render.tsx — typed props via WidgetRenderProps<T> from @wordpress/widget-primitives, composed with Partial<ReportParamsFieldAttributes>, and defaulted attributes = {}.
  • widgets/average-order-value/widget.ts — declared the empty attribute shape as Record<never, never>.
  • widgets/average-order-value/package.json — dropped unused @wordpress/ui, added @wordpress/widget-primitives.
  • Removed the js-packages/storybook changelog entry (that project has no code changes).

Verification

  • eslint — clean on the widget + shared file.
  • tsgo typecheck (@automattic/jetpack-premium-analytics) — clean.
  • No SCSS in this widget (stylelint N/A).
  • widget-audit: PASS (no judgment findings; the only mechanical items were the ones above).
  • Storybook (local): Default renders the $128.54 metric; WithComparison renders the value + +18% delta with the comparative line chart (solid current / dashed prior period, area fill, axes, legend); WidgetDashboardWithWidget renders the widget inside the host dashboard card. Console shows only the shared-harness baseline warnings (useRouter / useGlobalError), identical to the payment-status sibling — no widget-specific errors.
  • CI green on the pre-rebase run; re-running on the rebased branch.
Screen.Recording.2026-07-02.at.5.32.45.PM.mov

@chihsuan chihsuan merged commit 7311bb9 into trunk Jul 2, 2026
73 checks passed
@chihsuan chihsuan deleted the add/wooa7s-1461-port-woo-widget-average-order-value branch July 2, 2026 09:33
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] In Progress labels Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[JS Package] Storybook [Package] Premium Analytics RNA [Status] UI Changes Add this to PRs that change the UI so documentation can be updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants