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

Global Styles: Show notice in privacy settings #69242

Merged
merged 22 commits into from
Oct 26, 2022

Conversation

rcrdortiz
Copy link
Contributor

@rcrdortiz rcrdortiz commented Oct 19, 2022

This PR implements the UI changes necessary for displaying a notice in the privacy settings when our users are using Global Styles and are required to upgrade their plan in order to make the customization changes they've made available publicly.

I've decided not to show the notice when the site is not launched because of two main reasons. This isn't specified in the design and I think this wasn't taken into consideration, the second reason is to reduce friction when launching a site, I experimented a bit with the UI and it becomes cluttered with buttons and we aren't providing a clear path that our users should follow, which could lead to a decrease in the number of sites that get launched.

Also, when a user launches a free site, he will already get prompted to purchase a domain and a plan.

Captura de Pantalla 2022-10-19 a las 10 12 03

Proposed Changes

  • We now check if the user has GS in use and if we should show a notice.
  • If the user qualifies, we show a notice that includes a button so that the user can upgrade his plan.

Testing Instructions

Happy Case

  • Go to the general settings screen, privacy section. http://calypso.localhost:3000/settings/general/{siteSlug}
  • Make sure your site is FREE and that you have some GS customizations applied.
    • When the site is not launched you should not see a notice
    • When the site is launched you should see a notice.
      • Make sure the buttons on the notice work as expected.
  • Remove or reset your customizations.
  • You should not see the notice.

Mobile devices

  • Repeat the happy case using a mobile viewport (just the part where you interact with the notice).

Test un-launched site

  • Create a site and make sure to not launch it.
  • Make sure it has the corresponding blog sticker.
  • Go to the general settings screen, privacy section.
  • You should not see the notice.

Test tracking event when clicking on the upgrade button.

  • Go through the Happy Case
  • Open tracks and search for calypso_global_styles_gating_%
  • You should see some events named calypso_global_styles_gating_settings_notice_upgrade_click

Test network error when fetching global styles info

  • Block the global styles info request in Chrome's inspector and reload.
  • You should see no console errors.
  • You should see no errors on the screen.
  • You should see the last value cached by useQuery.

Test for regressions

  • Accent color should continue to work as before. See this PR for testing instructions

Test evidence

Captura de Pantalla 2022-10-20 a las 15 27 51

Pre-merge Checklist

Related to #

…obal styles in use and does not have a paid plan
@github-actions
Copy link

github-actions bot commented Oct 19, 2022

@rcrdortiz rcrdortiz changed the title We now show a notice in the privacy setting screen if the user has gl… Global Styles: Show notice in privacy settings Oct 19, 2022
@matticbot
Copy link
Contributor

matticbot commented Oct 19, 2022

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

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

name                   parsed_size           gzip_size
entry-stepper              +1186 B  (+0.0%)     +805 B  (+0.1%)
entry-main                  -197 B  (-0.0%)       +4 B  (+0.0%)
entry-gutenboarding         -103 B  (-0.0%)      +15 B  (+0.0%)
entry-login                  -63 B  (-0.0%)      +10 B  (+0.0%)
entry-domains-landing        -63 B  (-0.0%)      +10 B  (+0.0%)
entry-browsehappy            -63 B  (-0.1%)      +10 B  (+0.0%)

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

Sections (~9473 bytes added 📈 [gzipped])

name                             parsed_size           gzip_size
settings                            +37861 B  (+5.5%)   +10678 B  (+5.2%)
plans                                 -248 B  (-0.0%)    -1293 B  (-0.5%)
jetpack-cloud-pricing                 -248 B  (-0.0%)    -1128 B  (-0.6%)
checkout                              -248 B  (-0.0%)     -886 B  (-0.2%)
jetpack-connect                       -150 B  (-0.0%)     -631 B  (-0.2%)
signup                                 -47 B  (-0.0%)     +168 B  (+0.2%)
accept-invite                          -47 B  (-0.0%)     +168 B  (+0.2%)
plugins                                -39 B  (-0.0%)      -37 B  (-0.0%)
woocommerce-installation               -30 B  (-0.0%)      -16 B  (-0.0%)
themes                                 -30 B  (-0.0%)      -16 B  (-0.0%)
theme                                  -30 B  (-0.0%)      -16 B  (-0.0%)
stats                                  -30 B  (-0.0%)      -18 B  (-0.0%)
sites-dashboard                        -30 B  (-0.0%)      -16 B  (-0.0%)
site-purchases                         -30 B  (-0.0%)      -17 B  (-0.0%)
settings-writing                       -30 B  (-0.0%)      -16 B  (-0.0%)
settings-security                      -30 B  (-0.0%)      -16 B  (-0.0%)
settings-performance                   -30 B  (-0.0%)      -16 B  (-0.0%)
settings-jetpack                       -30 B  (-0.0%)      -16 B  (-0.0%)
settings-discussion                    -30 B  (-0.0%)      -16 B  (-0.0%)
scan                                   -30 B  (-0.0%)      -16 B  (-0.0%)
purchases                              -30 B  (-0.0%)      -17 B  (-0.0%)
purchase-product                       -30 B  (-0.0%)      -16 B  (-0.0%)
posts-custom                           -30 B  (-0.0%)      -17 B  (-0.0%)
posts                                  -30 B  (-0.0%)      -17 B  (-0.0%)
people                                 -30 B  (-0.0%)      -16 B  (-0.0%)
migrate                                -30 B  (-0.0%)      -16 B  (-0.0%)
media                                  -30 B  (-0.0%)      -18 B  (-0.0%)
marketplace                            -30 B  (-0.0%)      -29 B  (-0.0%)
marketing                              -30 B  (-0.0%)      -16 B  (-0.0%)
jetpack-social                         -30 B  (-0.0%)      -16 B  (-0.0%)
jetpack-search                         -30 B  (-0.0%)      -16 B  (-0.0%)
jetpack-cloud-settings                 -30 B  (-0.0%)      -16 B  (-0.0%)
jetpack-cloud-plugin-management        -30 B  (-0.0%)      -16 B  (-0.0%)
jetpack-cloud-partner-portal           -30 B  (-0.0%)      -16 B  (-0.0%)
jetpack-cloud-agency-dashboard         -30 B  (-0.0%)      -16 B  (-0.0%)
jetpack-cloud                          -30 B  (-0.0%)      -16 B  (-0.0%)
hosting                                -30 B  (-0.0%)      -16 B  (-0.0%)
home                                   -30 B  (-0.0%)      -16 B  (-0.0%)
help                                   -30 B  (-0.0%)      -16 B  (-0.0%)
google-my-business                     -30 B  (-0.0%)      -16 B  (-0.0%)
email                                  -30 B  (-0.0%)      -16 B  (-0.0%)
earn                                   -30 B  (-0.0%)      -16 B  (-0.0%)
domains                                -30 B  (-0.0%)      -16 B  (-0.0%)
backup                                 -30 B  (-0.0%)      -16 B  (-0.0%)
add-ons                                -30 B  (-0.0%)      -16 B  (-0.0%)
activity                               -30 B  (-0.0%)      -16 B  (-0.0%)
pages                                  -22 B  (-0.0%)      -16 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 (~63 bytes removed 📉 [gzipped])

name                                                              parsed_size           gzip_size
async-load-masterbar-cart-masterbar-cart-wrapper                        -30 B  (-0.0%)      -16 B  (-0.0%)
async-load-design-playground                                            -30 B  (-0.0%)      -16 B  (-0.0%)
async-load-design-blocks                                                -30 B  (-0.0%)      -19 B  (-0.0%)
async-load-design                                                       -30 B  (-0.0%)      -16 B  (-0.0%)
async-load-calypso-reader-sidebar                                       -30 B  (-0.0%)      -16 B  (-0.0%)
async-load-calypso-post-editor-editor-media-modal                       -30 B  (-0.0%)      -16 B  (-0.0%)
async-load-calypso-my-sites-current-site-stale-cart-items-notice        -30 B  (-0.0%)      -16 B  (-0.1%)
async-load-calypso-my-sites-current-site-notice                         -30 B  (-0.0%)      -16 B  (-0.1%)
async-load-calypso-components-web-preview-component                     -30 B  (-0.0%)      -11 B  (-0.0%)
async-load-calypso-components-jetpack-sidebar                           -30 B  (-0.0%)      -16 B  (-0.0%)
async-load-calypso-blocks-jitm-templates-sidebar-banner                 -30 B  (-0.0%)      -16 B  (-0.1%)
async-load-calypso-blocks-jitm-templates-notice                         -30 B  (-0.0%)      -16 B  (-0.1%)
async-load-calypso-blocks-jitm-templates-default                        -30 B  (-0.0%)      -16 B  (-0.1%)
async-load-calypso-blocks-inline-help-popover                           -30 B  (-0.0%)      -16 B  (-0.0%)
async-load-calypso-blocks-editor-checkout-modal                         -30 B  (-0.0%)      -49 B  (-0.0%)
async-load-automattic-help-center                                       -30 B  (-0.0%)      -16 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.

@rcrdortiz rcrdortiz changed the title Global Styles: Show notice in privacy settings [WIP] Global Styles: Show notice in privacy settings Oct 19, 2022
@@ -260,6 +261,12 @@ export class SiteSettingsFormGeneral extends Component {
} );
};

trackAdvancedCustomizationUpgradeClick = () => {
this.props.recordTracksEvent( 'calypso_global_styles_gating_settings_notice_upgrade_click', {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll need to add this event to Tracks.

@rcrdortiz rcrdortiz self-assigned this Oct 20, 2022
@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 add/global-styles-notice-in-privacy-settings on your sandbox.

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

@rcrdortiz rcrdortiz requested a review from a team October 20, 2022 13:42
@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 Oct 20, 2022
@rcrdortiz rcrdortiz changed the title [WIP] Global Styles: Show notice in privacy settings Global Styles: Show notice in privacy settings Oct 20, 2022
@rcrdortiz rcrdortiz added [Team] AJAX [Feature] Global Styles The Global Styles tools in the site editor and theme style variations. labels Oct 20, 2022
Copy link
Member

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

Nice work! Overall this tests very well, but I think we should address a few things before shipping.

  • You need to consider that the copy of the notice might be longer in other languages and wrapped in two lines. The layout is a bit off in such cases right now:

Screen Shot 2022-10-21 at 13 22 33

  • I think we should add the endpoint in a separate PR so we can deploy a new ETK version before deploying the Calypso changes that start fetching data from it

  • Looks like we make a recurrent request to the endpoint. That's not usually our approach when fetching data from an endpoint due to performance reasons (the only exception is when the fetched data is very critical and needs to be reflected in real time, but this not the case). The data should be loaded only once when the component first renders. I realize this can cause issues like the notice not showing up if you have the settings page open and are editing the Global Styles in a separate tab, but that's edge-case scenario and it's fine to don't cover it.

Screen Shot 2022-10-21 at 13 21 34

Co-authored-by: Miguel Torres <miguel.torres@automattic.com>
@rcrdortiz
Copy link
Contributor Author

rcrdortiz commented Oct 21, 2022

I think we should add the endpoint in a separate PR so we can deploy a new ETK version before deploying the Calypso changes that start fetching data from it

No need to do this. useQuery will use the default values and not show the notice until the ETK endpoint is live, which shouldn't be a few minutes after at most.

Co-authored-by: Miguel Torres <miguel.torres@automattic.com>
@rcrdortiz
Copy link
Contributor Author

rcrdortiz commented Oct 21, 2022

Looks like we make a recurrent request to the endpoint. That's not usually our approach when fetching data from an endpoint due to performance reasons (the only exception is when the fetched data is very critical and needs to be reflected in real time, but this not the case). The data should be loaded only once when the component first renders. I realize this can cause issues like the notice not showing up if you have the settings page open and are editing the Global Styles in a separate tab, but that's edge-case scenario and it's fine to don't cover it.

Exactly how are you making it make more than one request? I'm unable to reproduce it. Maybe what you're experiencing is related to how useQuery handles state internally 🤔, with normal usage of the settings screen, I can't seem to reproduce it.

requests.mp4

@mmtr
Copy link
Member

mmtr commented Oct 21, 2022

No need to do this. useQuery will use the default values and not show the notice until the ETK endpoint is live.

I got a WSOD if the endpoint is not live:

Screen Shot 2022-10-21 at 15 17 35

Exactly how are you making it make more than one request? I'm unable to reproduce it.

Oh sorry, I thought it was a recurring request, but apparently there is a new request every time I come back to the tab after switching to a different tab:

Screen.Recording.2022-10-21.at.15.21.08.mov

It's not a big deal, but I don't think that's the normal behavior we have in other components.

@rcrdortiz
Copy link
Contributor Author

rcrdortiz commented Oct 21, 2022

It's not a big deal, but I don't think that's the normal behavior we have in other components.

Do you happen to know how to avoid that? It has to be related to useQuery but I can't seem to find anything about it.

@rcrdortiz
Copy link
Contributor Author

You need to consider that the copy of the notice might be longer in other languages and wrapped in two lines. The layout is a bit off in such cases right now

This should be working now for longer translated texts.

@rcrdortiz rcrdortiz requested a review from mmtr October 21, 2022 15:14
Copy link
Member

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all the feedback!

Looks like there is a regression in the notices showed during onboarding.

For example, /setup/designSetup?siteSlug=<SITE_SLUG> used to display a premium badge on non-default variations but it's missing:

Screen Shot 2022-10-21 at 17 41 15

Also, when going to /setup/newsletterSetup?flow=newsletter there is a request to the API endpoint despite the site not being created. Where is that siteId coming from?

Screen Shot 2022-10-21 at 17 43 54

@rcrdortiz
Copy link
Contributor Author

rcrdortiz commented Oct 21, 2022

Thanks for addressing all the feedback!

Looks like there is a regression in the notices showed during onboarding.

For example, /setup/designSetup?siteSlug=<SITE_SLUG> used to display a premium badge on non-default variations but it's missing:

Screen Shot 2022-10-21 at 17 41 15

Also, when going to /setup/newsletterSetup?flow=newsletter there is a request to the API endpoint despite the site not being created. Where is that siteId coming from?

Screen Shot 2022-10-21 at 17 43 54

I can't reproduce the regression you mentioned. Could you share what steps you're following?

works.mp4

For the second thing you mention, there seems to be a bug with useSelector( getSelectedSiteId ); or with the actual newsletterSetup flow, the selected site isn't getting cleaned up from the store when navigating to /setup/newsletterSetup?flow=newsletter so the logic we have for determining the siteId is returning the last siteId (since that is what we have in the store). Is it possible to navigate to the newsletter flow from within Calypso? Or is this something that won't happen in real-life scenarios?

@rcrdortiz rcrdortiz requested a review from mmtr October 21, 2022 19:59
@mmtr
Copy link
Member

mmtr commented Oct 24, 2022

I can't reproduce the regression you mentioned. Could you share what steps you're following?

I just created a new site, added the blog sticker and started the design step during the site setup process. However, I cannot reproduce it now, so maybe I was half-sandboxed, or maybe it was a caching issue. I guess it's fine to ignore for now.

Is it possible to navigate to the newsletter flow from within Calypso? Or is this something that won't happen in real-life scenarios?

No idea how the newsletter flow starts, but I think it's something that can happen in a real-time scenario since we cannot guarantee that the user didn't visit Calypso previously (even if the flows starts outside of Calypso).

I think the problem is that all these onboarding flows use a different way of storing site data and completely ignores what's in the traditional state. I wonder if there is any selector that tells us whether the user is onboarding so we can discard whatever getSelectedSiteId returns.

@mmtr
Copy link
Member

mmtr commented Oct 24, 2022

I think the problem is that all these onboarding flows use a different way of storing site data and completely ignores what's in the traditional state. I wonder if there is any selector that tells us whether the user is onboarding so we can discard whatever getSelectedSiteId returns.

Maybe select( ONBOARD_STORE ).getState()?

@rcrdortiz
Copy link
Contributor Author

I think the problem is that all these onboarding flows use a different way of storing site data and completely ignores what's in the traditional state. I wonder if there is any selector that tells us whether the user is onboarding so we can discard whatever getSelectedSiteId returns.

Maybe select( ONBOARD_STORE ).getState()?

Thanks for the insight! It kinda worked, we also need to check for some other conditions like not having site query args. It should be working now.

Copy link
Member

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

Pretty close!!

client/state/sites/hooks/use-premium-global-styles.ts Outdated Show resolved Hide resolved
client/state/sites/hooks/use-premium-global-styles.ts Outdated Show resolved Hide resolved
client/state/sites/hooks/use-premium-global-styles.ts Outdated Show resolved Hide resolved
@rcrdortiz rcrdortiz requested a review from mmtr October 25, 2022 12:41
Copy link
Member

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

Works great!

{ translate( 'View site' ) }
</Button>
<Button
className="is-primary"
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick (non-blocking): The same can be accomplished by setting a primary prop.

Suggested change
className="is-primary"
primary

@mmtr mmtr added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 25, 2022
@rcrdortiz rcrdortiz merged commit fe0bff0 into trunk Oct 26, 2022
@rcrdortiz rcrdortiz deleted the add/global-styles-notice-in-privacy-settings branch October 26, 2022 06:41
@a8ci18n
Copy link

a8ci18n commented Oct 26, 2022

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

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

@mmtr mmtr restored the add/global-styles-notice-in-privacy-settings branch October 26, 2022 09:59
@mmtr mmtr deleted the add/global-styles-notice-in-privacy-settings branch October 26, 2022 10:01
@a8ci18n
Copy link

a8ci18n commented Nov 3, 2022

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] Global Styles The Global Styles tools in the site editor and theme style variations. [Team] AJAX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants