-
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
Stepper: Support loading in useTracksEventProps
#98219
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~25 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~62 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. |
}, | ||
[ STEPPER_TRACKS_EVENT_SIGNUP_STEP_START ]: { | ||
...( isGoalsAtFrontExperiment && { | ||
isLoading, |
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.
Posting here so we can keep a discussion.
Cool thinking! I've nearly completely lost hope in this API, at least in its current form, and primarily from the way that we pick the events to guide analyses. But having an async isLoading
prop that propagates this way can indeed create misalignment. My feeling is this is not insignificant risk and it also creates ambiguity/trust issues with the API:
Another risk is if all of these conditions are met:
- A flow customizes calypso_signup_start using the hook.
- The customization needs time load.
- They do not customize calypso_signup_step_start as well.
The calypso_signup_step_start will fire before calypso_signup_start. This is the only risky combo.
So a usage that for whatever reason (common reason apparently, like an experiment running) will need to customise all the events handled by the API to ensure there is correct order. Is this correct, from what you are saying?
Just thinking about the above, assuming correct, it's almost like this prop doesn't accomplish anything more than not passing custom props until isLoading
is true:
...( ! isLoading && {
[ STEPPER_TRACKS_EVENT_SIGNUP_START ]: {
is_goals_first: isGoalsAtFrontExperiment.toString(),
...( isGoalsAtFrontExperiment && { step: 'goals' } ),
is_logged_out: ( ! userIsLoggedIn ).toString(),
},
...
} )
If the two are equivalent, then I'd consider this instead and not have it as part of the API. It feels more ambiguous when something's part of the API but with conditions of use.
I wonder if other caveats may exist too, but I've been away from this for quite a while to have perspective 🤔
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.
Hi Christos! Long time no see.
I've nearly completely lost hope in this API, at least in its current form, and primarily from the way that we pick the events to guide analyses
Totally on the same page here. I'll reconsider this once I'm done with pdDR7T-22t-p2.
it's almost like this prop doesn't accomplish anything more than not passing custom props until isLoading is true:
That's not entirely correct. When the prop is true, the event does not fire at all. In the snippet you share, the event will fire but without the customizations passed by the flow..
Fixes: p1736504786087909/1736448746.488719-slack-C085HCWCEDN
Blocked by: #98097
Proposed Changes
The new part of Stepper API,
useTracksEventProps
, is young and needs some honing. Because of the way React works, an event is fired every time the return value of this hook changes. As opposed to picking up the most recent value when firing the event.To fix that, I added an
isLoading
flag to the hook. When this flag is true, the hook return value will not be considered and the event will not fire until it flips to false. This is a tradeoff because if the loading takes too long, the event order may be messed up. There is one more possible solution, which to remove the hook and turn it into an unchangeable property of the flow to avoid these cases, but that would miss a key feature (loading things then altering events).Another risk is if all of these conditions are met:
calypso_signup_start
using the hook.calypso_signup_step_start
as well.The
calypso_signup_step_start
will fire beforecalypso_signup_start
. This is the only risky combo.Why are these changes being made?
To avoid duplicated events.
Testing Instructions
/
(don't go to the flow URL, the experiment assignment will be cached).calypso_signup_start
.calypso_signup_start
.calypso_signup_start
.