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

Add tracks events to Jetpack logged-out checkout. #53678

Merged
merged 6 commits into from
Jun 24, 2021

Conversation

elliottprogrammer
Copy link
Contributor

@elliottprogrammer elliottprogrammer commented Jun 14, 2021

Changes proposed in this Pull Request

This PR adds tracks events to the Jetpack logged-out checkout flow. More specifically it adds events & properties for the purpose of being able to measure the number of new account signups vs existing account logins during the logged-out(site-only) checkout flow.

Asana Task: 1189109545411729-as-1199371465586276

Implementation notes:

  1. Adds a checkout_flow property to the calypso_checkout_page_view event. This checkout_flow property value will be one of:
    • wpcom_checkout
    • jetpack_checkout
    • Jetpack_site_only
    • jetpack_site_only_coming_from_login
    • wpcom_registrationless
  2. Adds the checkout_flow property to the calypso_checkout_composite_payment_complete event.
  3. Adds a calypso_checkout_wpcom_email_exists event that occurs when the user enters an email that is already associated with a WordPress.com account.
  4. Adds a calypso_checkout_composite_login_click event that occurs when the user clicks the link to log into their existing account.

Testing instructions

  • Download this PR.
  • Start Calypso Blue with yarn start.
  • Create a JN site.
  • Connect the site (site-connected only - logged out of wordpress.com).
  • On the Pricing page, select a Jetpack product.
  • On the Checkout page, replace wordpress.com with calypso.localhost:3000 leaving the rest of the URL intact.
  • Open Chrome developer tools and enter into the console, localStorage.debug='calypso:analytics*'; Make sure you have the Preserve Log option selected.
  • Refresh the checkout page and to ensure you are receiving the Tracks events output in the console.
  • Verify that you receive the calypso_checkout_page_view event and that it contains the checkout_flow property with the value jetpack_site_only.
  • Enter an email address that is linked to a WP.com account (you can use your A8c account). Enter your zipcode and country, and click "Continue".
  • Here at this step you may see Invalid prop type warnings in the console.. These existed previously and are unrelated to the changes in this PR. I will fix it in a following PR, so please disregard the warning for now, if you don't mind..
  • Verify that you receive the calypso_checkout_wpcom_email_exists event with props, email and checkout_flow.
  • Under the Email field, click the "Please log in" link.
  • Verify that you receive the calypso_checkout_composite_login_click event with props, email and checkout_flow.
  • Login with your WP.com account.
  • Once redirected to the Checkout page again, check the calypso_checkout_page_view event again and verify that it contains the checkout_flow property with the value jetpack_site_only_coming_from_login.
  • Complete the purchase.
  • Verify you receive the calypso_checkout_composite_payment_complete event and that it contains the prop checkout_flow and it's value is jetpack_site_only_coming_from_login;

If you feel so inclined, to be thorough, you can create another JN site and complete these steps again, except instead of entering an email address that is already linked to an existing WordPress.com account, you can enter an email that is not associated to any WordPress.com account, and complete the purchase. (To do this you'll need to add, define( 'USE_STORE_SANDBOX', true ); into /wp-content/mu-plugins/0-sandbox.php in your sandbox. And point public-api.wordpress.com to your sandbox IP (in your hosts file). This is so we can use checkout with a test credit card. See p1HpG7-c5P-p2 for instructions on testing out the logged-out visitor checkout flow using a test credit card.)
When testing this flow, in the final calypso_checkout_composite_payment_complete event, verify that it contains the prop checkout_flow and it's value is jetpack_site_only;

@elliottprogrammer elliottprogrammer self-assigned this Jun 14, 2021
@elliottprogrammer elliottprogrammer requested a review from a team as a code owner June 14, 2021 21:24
@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 Jun 14, 2021
@matticbot
Copy link
Contributor

matticbot commented Jun 14, 2021

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

Sections (~253 bytes added 📈 [gzipped])

name      parsed_size           gzip_size
checkout       +818 B  (+0.1%)     +253 B  (+0.1%)

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 (~231 bytes added 📈 [gzipped])

name                                             parsed_size           gzip_size
async-load-calypso-blocks-editor-checkout-modal       +734 B  (+0.1%)     +231 B  (+0.1%)

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.

@elliottprogrammer elliottprogrammer requested a review from a team June 14, 2021 21:40
@matticbot
Copy link
Contributor

matticbot commented Jun 15, 2021

@matticbot
Copy link
Contributor

This PR modifies the release build for wpcom-block-editor

To test your changes on WordPress.com, run install-plugin.sh wpcom-block-editor add/logged-out-checkout-tracks-events on your sandbox.

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

if ( isJetpackCheckout ) {
return isUserComingFromLoginForm
? 'jetpack_site_only_coming_from_login'
: 'Jetpack_site_only';
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiny consistency issue: the first letter is uppercase here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, good catch! Thank you!

Copy link
Contributor

@monsieur-z monsieur-z left a comment

Choose a reason for hiding this comment

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

Everything tested well with a WordPress.com account, and code looks good.

The only blocker as far as I'm concerned is the case typo in Jetpack_site_only, since it can skew later data readings.

@elliottprogrammer
Copy link
Contributor Author

Thank you both for your thorough review. Sorry about all the little mistakes. 🤦‍♂️ 😊

Copy link
Member

@sirbrillig sirbrillig left a comment

Choose a reason for hiding this comment

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

Thanks! Code looks good to me. I didn't test it since the changes but I trust the review of @monsieur-z and the e2es.

@rcanepa
Copy link
Contributor

rcanepa commented Jun 23, 2021

@elliottprogrammer, we didn't merge this one because of the problem with the redirect after the login step, is that right? If so, and since we know the bug only happens when we are behind the proxy, I could test this without the proxy to see if everything works as expected. If it does, you could safely merge it. What do you think?

@elliottprogrammer
Copy link
Contributor Author

@elliottprogrammer, we didn't merge this one because of the problem with the redirect after the login step, is that right? If so, and since we know the bug only happens when we are behind the proxy, I could test this without the proxy to see if everything works as expected. If it does, you could safely merge it. What do you think?

Yes exactly, the redirect after login step bug was preventing us from being able to test this PR fully, but you're right, since now we know the bug only happens behind the proxy, we could test this PR proxy disabled, and that would allow us test all aspects of this PR so we can safely merge. Great idea!

Copy link
Contributor

@rcanepa rcanepa left a comment

Choose a reason for hiding this comment

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

LGTM!

I ran the instructions with the proxy disabled, and everything worked as expected.

@elliottprogrammer elliottprogrammer merged commit e449bef into trunk Jun 24, 2021
@elliottprogrammer elliottprogrammer deleted the add/logged-out-checkout-tracks-events branch June 24, 2021 14:03
@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 Jun 24, 2021
@@ -71,7 +72,8 @@ export default function useCreatePaymentCompleteCallback( {
isComingFromUpsell?: boolean;
isFocusedLaunch?: boolean;
siteSlug: string | undefined;
isJetpackCheckout?: boolean;
isJetpackCheckout: boolean;
checkoutFlow: string;
Copy link
Member

Choose a reason for hiding this comment

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

I missed this in my review, but this adds a new required argument to useCreatePaymentCompleteCallback, but doesn't change all the instances where that function is used. Notably:

const onComplete = useCreatePaymentCompleteCallback( {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thank you for spotting this @sirbrillig. I don't see why these 2 arguments, isJetpackCheckout and checkoutFlow need to be required.

I created PR #54116 to make them optional args. If you don't mind, could you give it a review? 🙂

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.

5 participants