-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Goals First: Prevent calypso_signup_start
from firing multiple times
#98182
Conversation
…nt from firing each time goals are selected
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~14 bytes added 📈 [gzipped])
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. Generated by performance advisor bot at iscalypsofastyet.com. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spreading the object creates a new reference every time, so it doesn't/fixes the problem in a way that might introduce more bugs in the future.
Instead, we could serialize the goals into a string and pass that string to the dependency array, like Paulo did here: https://github.com/Automattic/wp-calypso/pull/98084/files
Something to investigate in the future is why the |
Wouldn't this still cause re-render as the goals changed as the string will change also? We want to record the goals but in a sense remove the dependency in the useMemo. |
Are the goals changing, or only the reference to the goals array? If the goals are the same, the serialized string will be the same, so it won't re-trigger the calculation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I'd even add a comment saying that we're only interested in the goals that were selected whenever the user entered.
@alshakero Is Basically I think the behaviour described by this unit test description is the opposite of what we would want. Line 134 in 4a11655
A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -57,6 +57,9 @@ const onboarding: Flow = { | |||
[] | |||
); | |||
|
|||
// we are only interested in the initial goals value when the user enters the goals step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vykes-mac Should this comment say "when the user leaves the goals step" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh oh, nevermind. Of course when calypso_signup_start
fires !! "Start" being the key word! 😄
Related to #
Proposed Changes
The
calypso_signup_start
event gets fired multiple times when goals are selected, this is because list of goals are apart of the memoization dependency in theuseTracksEventProps
hook. As a result each time the user changes the goals the memoization is invalidated and so the event is fired again.calypso_signup_start
is fired once.See for more information #98097 (comment)
Why are these changes being made?
Testing Instructions
/setup/onboarding
calypso_signup_start
is fired oncecalypso_signup_step_start
for the design,domain steps.Pre-merge Checklist