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

Launchpad.- Update mayberedirect launchpad option retrieval #74365

Merged

Conversation

agrullon95
Copy link
Contributor

@agrullon95 agrullon95 commented Mar 13, 2023

Related to #73830

Time Estimate

Review: Short
Test: Short

Proposed Changes

  • Add useLaunchpad hook to maybeRedirect controller function. This hook will use the launchpad endpoint to fetch the latest launchpad to determine if the user needs to be redirected to the launchpad screen or /home

Testing Instructions

  • Checkout this branch
  • Create or use an existing launchpad enabled site (Test on an atomic site as well)
  • Navigate to /home/{siteSlug} and verify that you are redirected to the launchpad screen
  • Navigate to /home/{siteSlug}?launchpadComplete=true and verify you are not redirected to the launchpad screen
  • Disable the launchpad (change site option launchpad_screen to off or FALSE) or use a site that is not launchpad enable and navigate to /home. Verify that you are not navigated to the launchpad screen.

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

@github-actions
Copy link

github-actions bot commented Mar 13, 2023

@matticbot
Copy link
Contributor

matticbot commented Mar 13, 2023

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

Sections (~81 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
home                       +218 B  (+0.0%)      +69 B  (+0.0%)
write-flow                 +117 B  (+0.1%)      +12 B  (+0.0%)
videopress-flow            +117 B  (+0.0%)      +12 B  (+0.0%)
newsletter-flow            +117 B  (+0.0%)      +12 B  (+0.0%)
link-in-bio-tld-flow       +117 B  (+0.0%)      +12 B  (+0.0%)
link-in-bio-flow           +117 B  (+0.0%)      +12 B  (+0.0%)
free-flow                  +117 B  (+0.0%)      +12 B  (+0.0%)
build-flow                 +117 B  (+0.1%)      +12 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.

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.

} );
};

export const useLaunchpad = ( siteSlug: string, cache = true ) => {
Copy link
Contributor

@edanzer edanzer Mar 14, 2023

Choose a reason for hiding this comment

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

Been a while since I used React Query, and I know it has a range of different options and settings around caching. Do we need to worry about caching this value, and not updating quickly after the setting has been updated on the backend?

Copy link
Contributor

Choose a reason for hiding this comment

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

Worth noting I tested this - by completing Launchpad, which turns the launchpad_screen option to off, and then immediately navigating to My Home. Seems to work fine. If I recall, RQ may automatticaly refetch data on window refreshes. Not sure how that interacts with the meta -> persist property here, but in any case, seems to be working just fine - no stale data when arriving on My Home.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the React Query docs, it seems like the query will refetch when its mounted again or the user refocuses on the window by default: https://react-query-v3.tanstack.com/guides/caching

For now we may be fine with the react query default values

const shouldRedirectToLaunchpad =
refetchedOptions?.launchpad_screen === 'full' &&
launchpad_screen === 'full' &&
// Temporary hack/band-aid to resolve a stale issue with atomic that the requestSite
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we need the 'temporary band-aid for atomic' part of this given the new endpoint?

Copy link
Contributor Author

@agrullon95 agrullon95 Mar 14, 2023

Choose a reason for hiding this comment

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

We can remove the shouldRedirectToLaunchpad logic since const { launchpad_screen, site_intent } = await fetchLaunchpad( slug ); should always retrieve the latest data.

@edanzer
Copy link
Contributor

edanzer commented Mar 14, 2023

This is testing as expected for me. Added a few comments. I'll also hold on approving as it's still in draft, and there's a convo happening about React Query vs using Redux data stores. Also some failing e2e tests.

It's nice to be able to delete all that extra code to handle stale state situations.

@agrullon95 agrullon95 requested a review from a team March 14, 2023 20:09
@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 Mar 14, 2023
@agrullon95 agrullon95 self-assigned this Mar 14, 2023
@agrullon95 agrullon95 added [Feature] Launchpad The onboarding Launchpad that guides users through setting up their site and getting it launched. and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 14, 2023
@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 Mar 14, 2023
@agrullon95 agrullon95 marked this pull request as ready for review March 14, 2023 20:10
@agrullon95 agrullon95 changed the title Update/mayberedirect update launchpad option retrieval Launchpad.- Update mayberedirect launchpad option retrieval Mar 15, 2023
Copy link
Contributor

@edanzer edanzer left a comment

Choose a reason for hiding this comment

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

Latest code changes look good. I tested this multiple times on Simple sites with different flows. I then tested multiple times on Atomic via different flows and upgrade paths. I also tested both prelaunch (when the home-to-launchpad redirect should work) and post-launch (when the redirect should not be active). In all cases, the My Home redirect worked when it should, and did not fire when it shouldn't.

Only small issue I had was unrelated to the PR. On two separate atomic sites, I'm noticing if you upgrade to an Ecommerce plan, we always seem to load the wp-admin version of My Home, not the calypso version. In such cases, obviously the redirect doesn't work. I would force the issue by manually loading the calypso home url, and the redirect would then work.

I usually test atomic via business plans (and force the atomic transfer by activating a plugin).
I can't recall testing an ecommerce plan. I only did so here because I wanted to force the atomic transfer right away without extra steps. But because I haven't tested this before, it could be that loading the wp-admin version of the dashboard is standard behavior for ecommerce plan sites. But to the extent that's expected, our redirect in the my home controller won't fire on such sites.

This is nothing we need to address in this PR. If we did somehow want to address it, I think we would need to discuss this and do it via a very different PR.

@edanzer
Copy link
Contributor

edanzer commented Mar 15, 2023

Some e2e tests had been failing. I just re-ran them, and looks like they're good now.

@sharpirate
Copy link
Contributor

Testing

✔️ Navigate to /home/{siteSlug} and verify that you are redirected to the launchpad screen
✔️ Navigate to /home/{siteSlug}?launchpadComplete=true and verify you are not redirected to the launchpad screen
✔️ Disable the launchpad (change site option launchpad_screen to off or FALSE) or use a site that is not launchpad enable and navigate to /home. Verify that you are not navigated to the launchpad screen.

@agrullon95 agrullon95 merged commit aaaa7d4 into trunk Mar 16, 2023
@agrullon95 agrullon95 deleted the update/mayberedirect-update-launchpad-option-retrieval branch March 16, 2023 21:38
@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 Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Launchpad The onboarding Launchpad that guides users through setting up their site and getting it launched.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants