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

Check the plan on launch site to show domain message or not #90866

Merged
merged 4 commits into from
May 23, 2024

Conversation

JuanLucha
Copy link
Contributor

@JuanLucha JuanLucha commented May 18, 2024

Related to https://github.com/Automattic/dotcom-forge/issues/7164

Proposed Changes

We need to check the site's current plan when it launches. If the site doesn't include a plan, like when the site was created by A4A, it shouldn't show the "claim your domain" message. This PR makes this change.

Why are these changes being made?

We don't offer a free domain as part of a Creator plan made by A4A. More context: https://github.com/Automattic/automattic-for-agencies-dev/issues/482

Testing Instructions

Instructions to test not A4A sites

  • Go to http://calypso.localhost:3000/sites and create a site normally. It would be awesome to test different plans, including Free.
  • In My Home, click on "Launch your site" (note: there are different launchpads, so the link to launch your site could be in a different order):
Screenshot 2024-05-18 at 13 47 39

You should see different popups depending on the circumstances of the blog:

  • a free blog (no domain included):
Screenshot 2024-05-17 at 19 57 17
  • a paid plan, including a domain:
Screenshot 2024-05-17 at 20 14 45

Instructions to test A4A sites

  • Log into our A4A testing account (details here: pfunGA-1mD-p2).
  • Create a new site (or use one of the existing sites that hasn't launched yet).
  • Create a new admin user on that site. You will require the credentials of such user in your local calypso. Accept the invitation in the new admin user email.
  • Login to the site using your local Calypso instance and this newly created account.
  • In My Home, click on "Launch your site":
  • This site has a paid plan, created with A4A (no domain included), so the popup should look like this:
Screenshot 2024-05-17 at 19 48 16

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-aUh-p2)?

@JuanLucha JuanLucha self-assigned this May 18, 2024
@matticbot
Copy link
Contributor

matticbot commented May 18, 2024

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

App Entrypoints (~1 bytes added 📈 [gzipped])

name           parsed_size           gzip_size
entry-stepper        +54 B  (+0.0%)       +1 B  (+0.0%)
entry-main           +54 B  (+0.0%)       +1 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~4361 bytes added 📈 [gzipped])

name                               parsed_size           gzip_size
home                                  +66906 B  (+4.2%)   +16722 B  (+3.7%)
site-purchases                           +62 B  (+0.0%)      +21 B  (+0.0%)
purchases                                +62 B  (+0.0%)      +21 B  (+0.0%)
plans                                    +62 B  (+0.0%)      +19 B  (+0.0%)
jetpack-connect                          +62 B  (+0.0%)      +19 B  (+0.0%)
jetpack-cloud-pricing                    +62 B  (+0.0%)      +19 B  (+0.0%)
jetpack-cloud-features-comparison        +62 B  (+0.0%)      +19 B  (+0.0%)
email                                    +62 B  (+0.0%)      +21 B  (+0.0%)
domains                                  +62 B  (+0.0%)      +21 B  (+0.0%)
checkout                                 +62 B  (+0.0%)      +19 B  (+0.0%)
stats                                    -13 B  (-0.0%)       +9 B  (+0.0%)

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

name                                             parsed_size           gzip_size
async-load-calypso-my-sites-checkout-modal             +62 B  (+0.0%)      +19 B  (+0.0%)
async-load-calypso-blocks-editor-checkout-modal        +62 B  (+0.0%)      +19 B  (+0.0%)

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.

Copy link
Contributor

@ivan-ottinger ivan-ottinger left a comment

Choose a reason for hiding this comment

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

Nice! I haven't had a chance to fully review and test the proposed changes, but noticed couple smaller things on the initial read through the code. Please see the inline comments below. 🙂

As, I am approaching EOD, I will finish reviewing it in the morning (if nobody gets to it earlier)

@ivan-ottinger ivan-ottinger requested a review from a team May 20, 2024 15:46
@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 May 20, 2024
Copy link
Contributor

@ivan-ottinger ivan-ottinger left a comment

Choose a reason for hiding this comment

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

Sharing a couple more thoughts.

Comment on lines 28 to 46
const purchases = useSelector( ( state ) => getSitePurchases( state, site?.ID ) );
const actualPlanPurchase =
purchases
.filter(
( purchase ) => purchase.productSlug === site?.plan?.product_slug && purchase.active
)
.sort( ( a, b ) => new Date( a.expiryDate ) - new Date( b.expiryDate ) )[ 0 ] || null;
const isA4ASite = actualPlanPurchase?.partnerType === 'a4a_agency';
const isLoading = useSelector( isFetchingSitePurchases );

useEffect( () => {
dispatch( fetchSitePurchases( site?.ID ) );
}, [ dispatch, site?.ID ] );

useEffect( () => {
if ( ! isLoading && ( ! isPaidPlan || purchases.length > 0 ) && ! isInitiallyLoaded ) {
setIsInitiallyLoaded( true );
}
}, [ isLoading, purchases, isPaidPlan, isInitiallyLoaded ] );
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there are selectors (e.g. getSitePlanSlug) that we can leverage to simplify the code.

Suggested change
const purchases = useSelector( ( state ) => getSitePurchases( state, site?.ID ) );
const actualPlanPurchase =
purchases
.filter(
( purchase ) => purchase.productSlug === site?.plan?.product_slug && purchase.active
)
.sort( ( a, b ) => new Date( a.expiryDate ) - new Date( b.expiryDate ) )[ 0 ] || null;
const isA4ASite = actualPlanPurchase?.partnerType === 'a4a_agency';
const isLoading = useSelector( isFetchingSitePurchases );
useEffect( () => {
dispatch( fetchSitePurchases( site?.ID ) );
}, [ dispatch, site?.ID ] );
useEffect( () => {
if ( ! isLoading && ( ! isPaidPlan || purchases.length > 0 ) && ! isInitiallyLoaded ) {
setIsInitiallyLoaded( true );
}
}, [ isLoading, purchases, isPaidPlan, isInitiallyLoaded ] );
const sitePlanSlug = useSelector( ( state ) => getSitePlanSlug( state, site?.ID ) );
const purchases = useSelector( ( state ) => getSitePurchases( state, site?.ID ) );
const actualPlanPurchase = purchases.filter( ( purchase ) => purchase.productSlug === sitePlanSlug );
const isA4ASite = isA4APurchase( actualPlanPurchase[0] );

Note that in the above suggestion, I've also introduced a helper function isA4APurchase() in lib/purchases to avoid sprinkling the string literal to various parts of the code base.

export function isA4APurchase( purchase?: Purchase ) {
	return 'a4a_agency' === purchase?.partnerType;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the approach of introducing isA4APurchase that can be potentially reused later. It simplifies the whole logic as well. 👌🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty nice, indeed 👍

@@ -77,7 +98,7 @@ function CelebrateLaunchModal( { setModalIsOpen, site, allDomains } ) {
);
buttonText = translate( 'Claim your free domain' );
buttonHref = `/domains/add/${ site.slug }`;
} else if ( hasCustomDomain ) {
} else if ( hasCustomDomain || isA4ASite ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of removing the mentions of a custom domain, we can probably updating https://github.com/Automattic/wp-calypso/pull/90866/files#diff-b2a3bdf3b4cec65b339e0803b39186ea50d15861cfa347b97294688a3b89e58eR69 to ensure we render the upsell banner for A4A sites!

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 point 👍

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug update/dont-show-free-domain-launch-popup on your sandbox.

@JuanLucha JuanLucha merged commit df06558 into trunk May 23, 2024
11 checks passed
@JuanLucha JuanLucha deleted the update/dont-show-free-domain-launch-popup branch May 23, 2024 07:42
@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 May 23, 2024
JuanLucha added a commit that referenced this pull request May 24, 2024
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.

None yet

4 participants