Automattic / wp-calypso

The JavaScript and API powered WordPress.com
https://developer.wordpress.com
GNU General Public License v2.0
12.42k stars 1.99k forks source link

Odyssey Stats: Upsell section should respect bundles #80536

Open kangzj opened 1 year ago

kangzj commented 1 year ago

For example if a site has Complete plan, the Search, Backup etc should NOT be shown in the upsell section.

Image

### Tasks
- [x] Hide upsell section for sites with a Complete bundle
- [x] Update upsell section for sites with a Security bundle
- [ ] Investigate refactor of usePurchasedProducts hook
kangzj commented 2 months ago

We might want to leverage the plan checks:

https://github.com/Automattic/jetpack/blob/760d6c3b146b6b1c0c184ea99c9efd65cfbdeccf/projects/packages/plans/src/class-current-plan.php

If we are going down that road, I guess it would require both Jetpack and Calypso changes - not really a problem tho.

Thanks for picking this one up @a8ck3n !

a8ck3n commented 2 months ago

Updated the tasks for this Issue. My initial understanding was it should not be shown for Complete bundles. Reviewing the Security bundle, I think it makes sense to filter the listing (remove security & backup) but still show it on those sites.

a8ck3n commented 2 months ago

For the usePurchasedProducts hook, see comments here:

https://github.com/Automattic/wp-calypso/pull/93318#pullrequestreview-2228551161

a8ck3n commented 2 months ago

A couple notes on possible refactorings:

  1. The usePurchaseProducts hook uses an API call that returns incomplete plan data. It doesn't know about Business or Complete plans. If we update it to call getSitePurchases it should get the full set of plan/purchase data.
  2. The hook will need its config data (the key slugs values) to be updated to include Business & Complete plans.
  3. The data for the upsell section is configured in two separate places. In the caller (setting up the URLs) and in the component (hard-coded upsell options). We could improve this by putting config together in one place.