Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plans 2023: Migrate plan-properties computation and other refactors #79733

Merged
merged 13 commits into from
Aug 9, 2023

Conversation

chriskmnds
Copy link
Contributor

@chriskmnds chriskmnds commented Jul 21, 2023

Fixes #79003, #79000
Partly addresses #79004, #79005 -- which can be deprioritized until package extraction

Proposed Changes

  • extracts the plan properties computation into respective hooks for putting together GridPlan concept.
    • GridPlan is a more complete data structure with most data needed by the respective grid components i.e. components are now fed only the GridPlans they need to render (e.g. ComparisonGrid gets the full set of plans that features are built out from) and these include all Pricing and Features metadata.
  • starts to surface more the splitting up of individual components - you will notice two instances of grid context provider, which is what the eventual split will be (with FeaturesGrid, ComparisonGrid, SpotlightPlan be enclosed within their own grid context)

A few more:

  • More work/refactors on the hooks used for putting together GridPlan can help down the line (use-grid-plan, use-plan-features-). Nothing final, and the calls made in plan-features-main can potentially be reduced once everything public-facing for the plans package.
  • Decouples the grid components from client/lib/plans/features-list (some parts are intermediate until feature definitions migrate to calypso-products). So partly addresses Plans Next: Migrate the Features list/metadata to @automattic/calypso-products #79004 to get us closer to a package
  • Decouples the grid from local calypso state for pricing computation (also intermediate until site and plans data stores are built out more, although this looks like it will be a long way out endeavor). So also partly addresses Plans 2023: Refactor grid plans pricing to derive from Plans data-store #79005 to get us closer to a package

Testing Instructions

Everything plans related:

@southp has written out a careful testing plan down below. For a more general sanity check:

  • Test /start and tailored flows (e.g. /start/hosting, /setup/newsletter, /setup/link-in-bio)
  • Test /plans/[ paid, free]
  • Test /plans with WooExpress (grabbed from /setup/wooexpress) and Newsletter sites
  • Confirm plan features render correctly in both features table and comparison grid (compare with production that all the checkmarks are correct)
  • Confirm pricing, discounts, and notices render correctly (try /plans/[paid] with a paid site to show the pro-rated credits notice)

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

@chriskmnds chriskmnds self-assigned this Jul 21, 2023
@github-actions
Copy link

github-actions bot commented Jul 21, 2023

@matticbot
Copy link
Contributor

matticbot commented Jul 21, 2023

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~5763 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
update-design-flow        +5723 B  (+0.7%)    +1464 B  (+0.7%)
plugins                   +5723 B  (+0.3%)    +1501 B  (+0.3%)
plans                     +5723 B  (+0.5%)    +1400 B  (+0.5%)
link-in-bio-tld-flow      +5723 B  (+0.4%)    +1414 B  (+0.4%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~341 bytes added 📈 [gzipped])

name                                                 parsed_size           gzip_size
async-load-signup-steps-plans-theme-preselected          +5723 B  (+2.5%)    +1420 B  (+2.1%)
async-load-signup-steps-plans                            +5723 B  (+2.5%)    +1420 B  (+2.2%)
async-load-calypso-my-sites-plan-features-2023-grid      -3942 B  (-2.0%)    -1079 B  (-1.7%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@chriskmnds chriskmnds changed the title Plans 2023: Extract plan-properties computation and other refactors Plans 2023: Migrate plan-properties computation and other refactors Jul 21, 2023
@chriskmnds chriskmnds force-pushed the update/plans-grid-2023-plan-properties branch from 5918886 to b70413d Compare July 25, 2023 12:54
@chriskmnds chriskmnds marked this pull request as ready for review July 25, 2023 12:54
@chriskmnds chriskmnds requested review from a team as code owners July 25, 2023 12:54
@chriskmnds chriskmnds requested a review from aneeshd16 July 25, 2023 12:54
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 25, 2023
@southp
Copy link
Contributor

southp commented Jul 26, 2023

Thanks for pulling this off, @chriskmnds :)
The PR touches generally how the data is fed and computed for the pricing grid, so I've focused on testing if plans / prices / plans are presented correctly in this first round. The test plan I'll be going through is down below. Once I've checked everything, I'll come back and update :)

  • The main onboarding flow, /start/
    • create a free site
    • create a paid site
    • the paid domain + free site modal
  • The site launching flow, /start/launch-site
  • Some more flows on the classic signup framework
    • /start/hosting
    • /start/onboarding-pm
    • /start/domain
    • /start/personal, /start/premium, etc.
  • Cherry-picking tailored flows (they are on Stepper and some of them varies by the intent)
    • /setup/newsletter
    • /setup/videopress
    • /setup/link-in-bio
    • /setup/domain-upsell
    • /setup/start-writing
    • /setup/deisgn-first
  • The p2 flow, /start/p2
  • The plans admin, /plans while logged-in
    • A site that shows the default pricing grid
    • A Newsletter site
    • A WooExpress site
    • Any atomic site
    • Confirm the upgrade credits is shown and computed properly -> (the price is computed correctly but the notif is gone. See the attached screenshot below)
  • Cherry-pick a few currencies
    • USD, EUR, TWD
    • Longer-form currency, IDR
    • Currencies that have the 1st-year discount, e.g. PHP

Update:

The only major thing I've found is that the upgrade credit notification is gone. i.e. this notif:
image

Also, when I tested the onboarding-pm flow and some others, there was one time this warning popping up:
截圖 2023-07-26 下午5 05 43

However, I couldn't reproduce it since, so I thought I'd just still attach it here so there is a clue to track it down :)

@ddc22
Copy link
Contributor

ddc22 commented Jul 26, 2023

Reviewer Story - aka what I understood

This is a set of personal notes that other reviewer can find useful and possibly also thinks out loud so that any misconceptions can be clarified by the PR author as well.

Examining the New Hooks Introduced

useGridPlans - data-store/use-grid-plans.tsx

This is the root of the change where the GridPlan data structure is built. The useGridPlan is currently wired up in the client at plans-features-main/index.tsx. It acts as a central consolidating hook to several other hooks (and simple Functions?) . Some hooks that branch out from here include.

  • usePlanTypesWithIntent - this is not a hook but a simple function that generates an array based on variables
  • usePlansFromTypes - Same here this is a simple function which talks to other functions but this not related to the current change
  • usePlanUpgradeabilityCheck - Selects from client state
  • useHighlightLabels - Unrelated to this PR
  • usePricedAPIPlans - The simple API returned plain plan price object
  • usePricingMetaForGridPlans - Even more plan pricing related derived data based on PricedAPIPlan

Hooks Injected from client

Hooks ready to be moved into separate package

Hooks used outside useGridPlan

useIsLargeCurrency - use-is-large-currency.ts

This hook was previously introduced and is just refactored to use the GridPlan data structure and moved. It is wired closer near the grid.

Other Related Notes

  • usePlansFromTypes Takes a set of planTypes ( Which are essentially plan slugs but for the frontend ) and a term. and provides the actual mapped planSlugs which are the actual plan unique identifiers in the back end.

Copy link
Contributor

@jeyip jeyip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary for my own understanding:

Plans Properties becomes Grid Plans

  • This PR focuses on plansProperties, a data structure that we used to build inclient/my-sites/plan-features-2023-grid/index.tsx
  • plansProperties was a collection of data about each plan ( ecommerce, business, premium, etc. ). The data was used to help the features grid and comparison grid render properly in onboarding, /plans, etc. ( Ex. what storage options were available for each plan, what kind of billing was available for each plan, etc. )
  • This PR moves the construction of plansProperties into a hook, use-grid-plans.tsx
  • This PR also renames plansProperties into gridPlans

Grid Plans are made accessible through React Context

The large surface area of file changes and lines of code changed is due to the widespread usage of plansProperties.

@jeyip
Copy link
Contributor

jeyip commented Jul 26, 2023

Testing

Requirements

  • /start
  • /start/hosting
  • /start/p2
  • /setup/link-in-bio
  • /setup/start-writing
  • /setup/wooexpress
  • /plans

Spot checked with production:

  • line items in the feature grid
  • storage labels in the feature grid
  • header prices in feature + comparison grid
  • highlighted plan columns
  • monthly terms
  • annual terms

Also tested:

  • plan selection and checkout
  • plan switcher in /plans
  • plan upgrades from /plans
  • pro-rated credits

Browsers

  • Chrome

Issues

@chriskmnds

The /start/hosting flow in this branch displays all plans instead of just Business and Commerce plans. I double checked, and Calypso trunk also only displays Business and Commerce plans
Screenshot 2023-07-26 at 4 11 54 PM

Copy link
Contributor

@ddc22 ddc22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial Round of review comments.

@chriskmnds
Copy link
Contributor Author

The only major thing I've found is that the upgrade credit notification is gone.

this should be fixed. good TS lesson to not do ... as PlanSlug[] 😬

@southp probably not worth a re-review yet. a few conflicts to address (and a few more coming in still from @jeyip's work)

@chriskmnds
Copy link
Contributor Author

chriskmnds commented Aug 1, 2023

The /start/hosting flow in this branch displays all plans instead of just Business and Commerce plans. I double checked, and Calypso trunk also only displays Business and Commerce plans

Thanks @jeyip . Good catch. This should be fixed. missed to update the set for that intent in a rebase

^ probably worth adding test coverage for more intents (I think we only cover newsletter and wpcom-default)

@chriskmnds chriskmnds force-pushed the update/plans-grid-2023-plan-properties branch from ceb42b0 to c3d4af8 Compare August 4, 2023 13:24
@chriskmnds chriskmnds force-pushed the update/plans-grid-2023-plan-properties branch from 60cda02 to 6d488b8 Compare August 5, 2023 19:54
@chriskmnds
Copy link
Contributor Author

@jeyip care to give this another round of testing pls? everything should be addressed and rebased

@jeyip
Copy link
Contributor

jeyip commented Aug 7, 2023

Yes! I’d be happy to 🎉

Taking a look before eod. Let’s get this over the finish line

@mj-collab mj-collab mentioned this pull request Aug 7, 2023
@jeyip
Copy link
Contributor

jeyip commented Aug 7, 2023

Testing

Requirements

  • /start
  • /start/hosting
  • /start/p2
  • /setup/link-in-bio
  • /setup/start-writing
  • /setup/wooexpress
  • /plans

Spot checked with production:

  • line items in the feature grid
  • storage labels in the feature grid
  • header prices in feature + comparison grid
  • highlighted plan columns
  • monthly terms
  • annual terms

Also tested:

Browsers

  • Chrome

Issues

The transaction fees for payments appears to be incorrect for free plans in /start

Screenshot 2023-08-07 at 4 08 33 PM

The start/p2 plans page now has a broken thank-you page that we redirect to after plan purchase. This problem is not caused by the current PR and there is no action to take in this pull request. I've asked about who to report the problem to here p1691450964830269/1691450530.670719-slack-C03N25JPCE4

Screenshot 2023-08-07 at 4 26 33 PM

@jeyip
Copy link
Contributor

jeyip commented Aug 8, 2023

After we resolve the issue in #79733 (comment) with transaction fees for payments ( whether we decide it be through a follow-up or a fix in this PR ) , the testing side of this looks good. Consider it a +1 from me when completed

@matticbot
Copy link
Contributor

This PR modifies the release build for happy-blocks

To test your changes on WordPress.com, run install-plugin.sh happy-blocks update/plans-grid-2023-plan-properties on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-r7r-p2

@matticbot
Copy link
Contributor

This PR modifies the release build for editing-toolkit

To test your changes on WordPress.com, run install-plugin.sh editing-toolkit update/plans-grid-2023-plan-properties on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-mMA-p2

@chriskmnds
Copy link
Contributor Author

The transaction fees for payments appears to be incorrect for free plans in /start

Thanks @jeyip . I did notice this from early on but forgot about it. It should be addressed now. Thanks for being thorough :-)

Also, when I tested the onboarding-pm flow and some others, there was one time this warning popping up:

I notice this too @southp, but didn't got to the bottom of it. As far as I checked, those slugs are part of the plans list, so it seemed a little weird 😕 . I will create a follow-up issue and leave it up for grabs/later, as it's not actually blocking anything.

@jeyip
Copy link
Contributor

jeyip commented Aug 8, 2023

Thanks @jeyip . I did notice this from early on but forgot about it. It should be addressed now.

Can confirm it has been addressed 👍

Copy link
Contributor

@jeyip jeyip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 :shipit: 🚀

@chriskmnds chriskmnds merged commit 7f3a272 into trunk Aug 9, 2023
@chriskmnds chriskmnds deleted the update/plans-grid-2023-plan-properties branch August 9, 2023 05:53
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Aug 9, 2023
@chriskmnds
Copy link
Contributor Author

Thnaks @jeyip for the trusted reviews.

This is obviously not the final shape. Right now we are mostly removing dependencies and separating concerns. We will iterate and improve things more. GridPlan in particular can be optimized with prospect of being easier to mock next.

@a8ci18n
Copy link

a8ci18n commented Aug 9, 2023

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/8692603

Hi @chriskmnds, could you please edit the description of this PR and add a screenshot for our translators? Ideally it'd include all of the following strings:

  • per month, %(discountedPriceFullTermText)s for the first year, Excl. Taxes
  • per month, %(originalPriceFullTermText)s billed annually, Excl. Taxes
  • per month, %(originalPriceFullTermText)s billed every two years, Excl. TaxesText
  • per month, %(originalPriceFullTermText)s billed every three years, Excl. TaxesText

Thank you in advance!

@a8ci18n
Copy link

a8ci18n commented Aug 9, 2023

Translation for this Pull Request has now been finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plans 2023 (NPM essential): Migrate plan properties computation to PlansFeaturesMain
6 participants