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

extract shuffle into js-utils and use it to randomize the themes on /start flow #57344

Merged
merged 5 commits into from
Nov 1, 2021

Conversation

roo2
Copy link
Contributor

@roo2 roo2 commented Oct 26, 2021

Changes proposed in this Pull Request

Fixes #56832 by giving a random sort to themes presented in the design picker. This will prevent certain themes from being prioritized and will allow us to see which themes are the most often selected.

There was an existing random function used in the design-picker package, but we could not share this since we use the theme API to load designs instead of the design pickers getAvailableDesigns method. Since we're migrating away from lodash (p4TIVU-9Bf-p2) and shuffle is a lodash function, I've migrated shuffleArray into our js-utils library.

Testing instructions

Test the design picker with
/start/design-setup-site?siteSlug=YOUR_SITE.wordpress.com Test the existing /newflow by going to/new` and navigating to the design picker step.

@roo2 roo2 requested review from p-jackson and a team October 26, 2021 02:28
@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 26, 2021
@roo2 roo2 removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 26, 2021
@roo2 roo2 marked this pull request as draft October 26, 2021 02:30
@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 26, 2021
@matticbot
Copy link
Contributor

matticbot commented Oct 26, 2021

@roo2 roo2 force-pushed the update/randomize-site-designs branch from 51364e1 to c5fd682 Compare October 26, 2021 03:53
@roo2 roo2 force-pushed the update/randomize-site-designs branch from 401e974 to bd08002 Compare October 26, 2021 04:39
@matticbot
Copy link
Contributor

matticbot commented Oct 26, 2021

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

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

name                 parsed_size           gzip_size
entry-gutenboarding       +112 B  (+0.0%)      +33 B  (+0.0%)

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

Sections (~26 bytes added 📈 [gzipped])

name    parsed_size           gzip_size
signup       +125 B  (+0.0%)      +26 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 (~58 bytes added 📈 [gzipped])

name                                   parsed_size           gzip_size
async-load-signup-steps-design-picker        +97 B  (+0.1%)      +58 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.

Copy link
Member

@tyxla tyxla 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 considering not using Lodash! I think shuffle is a good candidate for @automattic/js-utils now that we need to use it in multiple packages.

I can see this PR is still a draft, but I thought some early feedback could be helpful.

In a nutshell, @automattic/js-utils@0.1.0 was never released, so we should keep the version intact.

@@ -1,6 +1,6 @@
{
"name": "@automattic/js-utils",
"version": "0.1.0",
"version": "0.2.0",
Copy link
Member

Choose a reason for hiding this comment

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

0.1.0 has never been released, so there's no need to bump the version here. Let's make sure to revert all the related changes to package.json and yarn.lock.

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!

@@ -1 +1,2 @@
export { default as uniqueBy } from './unique-by';
export { default as shuffle } from './shuffle';
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Should we keep the list alphabetically sorted?

Copy link
Contributor

Choose a reason for hiding this comment

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

@roo2
Copy link
Contributor Author

roo2 commented Oct 26, 2021

thanks for the feedback @tyxla ! I've made those changes, hopefully the only thing left to do is get CI passing 🤞

@@ -32,6 +32,7 @@
},
"dependencies": {
"@automattic/calypso-config": "^1.0.0-alpha.0",
"@automattic/js-utils": "^0.1.0",
Copy link
Member

Choose a reason for hiding this comment

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

Let's also add js-utils to the references list in tsconfig.json of the design-picker package.

That should resolve the Cannot find module '@automattic/js-utils' or its corresponding type declarations. error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you!

@@ -6,6 +6,7 @@

// Reference all TS packages
"references": [
{ "path": "./js-utils" }, // define js-utils first so that it will be build before packages that depend on it
Copy link
Member

Choose a reason for hiding this comment

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

Small typo here:

Suggested change
{ "path": "./js-utils" }, // define js-utils first so that it will be build before packages that depend on it
{ "path": "./js-utils" }, // define js-utils first so that it will be built before packages that depend on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this, I think that this order was only relevant because I'd forgotten to add it to the tsconfig of design-picker as a dependency 😂

@roo2 roo2 marked this pull request as ready for review October 26, 2021 10:27
@roo2
Copy link
Contributor Author

roo2 commented Oct 26, 2021

Thanks for finding that I had forgot to add the dependency to design-picker/tsconfig.json. I was able to remove that non-alphabetical hack and the unit tests are passing now :)

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Works well and looks good from my perspective 👍 🚢

Copy link
Contributor

@arthur791004 arthur791004 left a comment

Choose a reason for hiding this comment

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

Well done!

@roo2 roo2 merged commit e8b48b9 into trunk Nov 1, 2021
@roo2 roo2 deleted the update/randomize-site-designs branch November 1, 2021 00:22
@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 Nov 1, 2021
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.

Design Picker: Add random sort to selections
5 participants