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

Offer Reset: create Upsell page #44954

Merged
merged 9 commits into from Aug 18, 2020
Merged

Conversation

rcanepa
Copy link
Contributor

@rcanepa rcanepa commented Aug 14, 2020

Changes proposed in this Pull Request

  • Create the Upsell page that nudge users into buying Jetpack Backup or Jetpack Scan depending on what product they previously selected.
  • Configurations allowed: from Jetpack Backup Daily to Jetpack Scan Daily, and from Jetpack Scan Daily to Jetpack Backup Daily. Real-time won't be supported at this time because there is no real Jetpack Scan Real-time yet.

Implementation notes

  • We don't have the real discounted price for upsells so for now we are showing the standard price of the product. It's expected that discounted prices of upsells will come from the API.
  • We don't have an official source for products and their allowed upsells. This PR hardcodes a matrix for that purpose but this data should come from an API.

Testing instructions

  • Run this PR.
  • Enable the Offer Reset AB experiment.

From Jetpack Backup Daily to Jetpack Scan Daily (monthly and yearly)

  • Visit http://calypso.localhost:3000/plans/:site/jetpack_backup_daily/annual/additions
  • Visit http://calypso.localhost:3000/plans/:site/jetpack_backup_daily_monthly/monthly/additions

From Jetpack Scan Daily to Jetpack Backup Daily (monthly and yearly)

  • Visit http://calypso.localhost:3000/plans/:site/jetpack_scan/annual/additions
  • Visit http://calypso.localhost:3000/plans/:site/jetpack_scan_monthly/monthly/additions

Fixes 1169247016322522-as-1189040767770459

Demo

Purchasing Jetpack Backup

Purchasing Jetpack Scan

Jetpack Scan + upsell Jetpack Backup Daily

Kapture 2020-08-17 at 13 21 15

Jetpack Backup Daily + upsell Jetpack Scan

Kapture 2020-08-17 at 13 16 54

@rcanepa rcanepa added [Feature] Plans & Upgrades All of the plans on WordPress.com and flow for upgrading plans. [Status] In Progress labels Aug 14, 2020
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Aug 14, 2020

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

Sections (~673 bytes added 📈 [gzipped])

name   parsed_size           gzip_size
plans      +2585 B  (+0.5%)     +673 B  (+0.5%)

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

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.

@rcanepa rcanepa force-pushed the add/offer-reset-upsell-checkout-step branch 2 times, most recently from 685d9d0 to c2ef599 Compare August 17, 2020 16:14
@rcanepa rcanepa added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Aug 17, 2020
@rcanepa rcanepa requested a review from a team August 17, 2020 16:22
Copy link
Contributor

@ChaosExAnima ChaosExAnima left a comment

Choose a reason for hiding this comment

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

Feedback left. Note this will need a significant rebase when #44927 is merged, so may be worth waiting till afterwards to tackle my feedback 😄

const onPurchaseSingleProduct = useCallback( () => {
addItem( jetpackProductItem( productSlug ) );
goToCheckout();
}, [ goToCheckout, productSlug ] );
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why the code uses useCallback here? Does any of these need memoization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not memoization but on every render those functions are going to be recreated making children components re-render even if the rest of the props haven't changed. I'll say that I'm used to do it. On higher components in the components tree could be troublesome because by definition those will have many children.

On the other hand, I don't think having those could hurt. What do you think?

mainProduct: mainProductName,
upsellProduct: upsellProductName,
},
comment: '%s are abbreviated name of product such as Scan or Backup',
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's be specific as to what %s the comment is referring to, in case this string ever has something else added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, those are mistakes from a copy-paste.

mainProduct: mainProductName,
upsellProduct: upsellProductName,
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs a comment. Also should the currency symbol be an arg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

if ( ! product ) {
// If the product is not valid or there is no upsell product for it,
// send the user to the selector page.
if ( ! mainProduct || ! upsellProduct ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps the code could instead send the user to the checkout page if there's no upsell product? The current structure of does not check if an upsell exists before sending the user to this page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This a very good idea.

@@ -209,6 +210,7 @@ export function itemToSelectorProduct(
productSlug: item.product_slug,
iconSlug: `${ item.product_slug }_v2`,
displayName: getJetpackProductDisplayName( item ),
shortName: getJetpackProductShortName( item ),
Copy link
Contributor

Choose a reason for hiding this comment

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

The type above adds shortName as required, but it is only implemented on products, not plans. This will cause TS errors and should be fixed, even with an empty string if no such data exists for plans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

Copy link
Contributor

@ChaosExAnima ChaosExAnima left a comment

Choose a reason for hiding this comment

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

Whoops, meant to not approve!

@rcanepa rcanepa force-pushed the add/offer-reset-upsell-checkout-step branch from c2ef599 to 9a7fff7 Compare August 17, 2020 22:08
Copy link
Contributor

@ChaosExAnima ChaosExAnima left a comment

Choose a reason for hiding this comment

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

Looks okay! Some minor cleanup comments, but overall looks good. 👍

/>
</Main>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Good for now, but let's re-use the ProductCardWrapper component soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do in follow up PR because I we need to update ProductCardWrapper to make it accept a onCancelClick and cancelLabel.

onButtonClick={ onPurchaseBothProducts }
cancelLabel={ translate( 'No, I do not want %s', {
args: [ upsellProductName ],
} ) }
Copy link
Contributor

Choose a reason for hiding this comment

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

The two strings here should have a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@rcanepa rcanepa merged commit 7d9ea1f into master Aug 18, 2020
@rcanepa rcanepa deleted the add/offer-reset-upsell-checkout-step branch August 18, 2020 16:03
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Aug 18, 2020
@a8ci18n
Copy link

a8ci18n commented Aug 18, 2020

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

Thank you @rcanepa for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Aug 27, 2020

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

Thank you @rcanepa for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Sep 4, 2020

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
[Feature] Plans & Upgrades All of the plans on WordPress.com and flow for upgrading plans.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants