-
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
Implement the total elapsed time tracking between calypso_signup_start
and calypso_signup_complete
#83944
Conversation
and `calypso_signup_complete`
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~154 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~6213 bytes removed 📉 [gzipped])
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 (~251 bytes added 📈 [gzipped])
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. Generated by performance advisor bot at iscalypsofastyet.com. |
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 |
client/lib/analytics/signup.js
Outdated
@@ -81,6 +93,7 @@ export function recordSignupComplete( | |||
// blog_id instead of site_id here. We keep using "siteId" otherwise since | |||
// all the other fields still refer with "site". e.g. isNewSite | |||
recordTracksEvent( 'calypso_signup_complete', { | |||
elapsed_time: elapsedTime ?? getSignupCompleteElapsedTimeInSeconds(), |
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.
The reason that getSignupCompleteElapsedTimeInSeconds()
are conditionally called in two places is because recordSignupComplete()
has an internal queue. If now
flag is absent, what it does is to queue the function and then let the internal task consumer make the real call. Thus, the elapsedTime ?? ...
above is for queuing the real elapsed time to the queue. That way when this function is called by the task consumer, elapsedTime
here will be the correct elapsed time being queued previously. In the meantime, if now
flag is enabled, this line will also guarantee that getSignupCompleteElapsedTimeInSeconds()
is called since elapsedTime
should be null in that case.
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.
Can't we just call getSignupCompleteElapsedTimeInSeconds()
on line 64 and use that value. The closure will preserve the correct value.
We do not want to add the Queuing
time to the actual metric do we? since it's not relevant to the elapsed time of the UX ?
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.
Also do you think we can rename the prop to time_since_signup_start
I have a feeling that we might need to add this time stamp across multiple events to make sense of the data and the above event name is a bit more descriptive.
Actually I would prefer if we add this event prop to all other major signup events like calypso_signup_actions_submit_step
, calypso_new_user_site_creation
, calypso_user_registration_complete
from the get go. But this can be followed up in another PR if you prefer 👍.
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.
I've updated the prop name as a slightly different elapsed_time_since_start
, since I somehow like to keep elapsed
and it's already under a signup event so I only include start
. Does that make sense to you?
Also:
Actually I would prefer if we add this event prop to all other major signup events like calypso_signup_actions_submit_step, calypso_new_user_site_creation, calypso_user_registration_complete from the get go. But this can be followed up in another PR if you prefer
Yeah, let's do it as a follow-up when the need arise :)
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.
Can't we just call getSignupCompleteElapsedTimeInSeconds() on line 64 and use that value. The closure will preserve the correct value.
We do not want to add the Queuing time to the actual metric do we? since it's not relevant to the elapsed time of the UX ?
Good question and that's the tricky part. First of all, no, we don't want to add the queuing time to the actual metric. That's why getSignupCompleteElapsedTime()
has to be called before the values go into the queue.
The way that "trigger queue" works is fairly simple(see addToQueue() and runTrigger() ). It pushes the function name and the arguments into the queue through addToQueue()
, and then invoke them accordingly by runTrigger()
. Thus, there
Thus, let's say we put getSignupCompletionTime()
call on Line 64, it'd actually be called twice:
- The 1st time: when
recordSignupComplete()
is called withnow
parameter asnull
- The 2nd time: when
recordSignupComplete()
is called again byrunTrigger()
It's fine, but I don't want it to be called twice like this. Does that make sense? :)
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.
@southp have you thought about introducing the elapsed time in milliseconds? Doing math in FE/JS in generally a bit iffy. And we can do calculation with far higher precision in our query tools?
Left a few more comment below related to the implementation.
client/signup/storageUtils.js
Outdated
@@ -83,3 +83,25 @@ export const getSignupCompleteStepNameAndClear = () => { | |||
clearSignupCompleteStepName(); | |||
return value; | |||
}; | |||
export const setSignupStartTimeInSeconds = () => | |||
ignoreFatalsForSessionStorage( () => | |||
sessionStorage?.setItem( 'wpcom_signup_start_time_in_second', Math.floor( Date.now() / 1000 ) ) |
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.
I think we can use performance.now()
which is more precise.
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.
Good idea. I've updated it into performance.now()
instead. Other than the precision, it's immune to any potential system clock changes, so it's the better choice for measuring elapsed time by design.
client/lib/analytics/signup.js
Outdated
@@ -81,6 +93,7 @@ export function recordSignupComplete( | |||
// blog_id instead of site_id here. We keep using "siteId" otherwise since | |||
// all the other fields still refer with "site". e.g. isNewSite | |||
recordTracksEvent( 'calypso_signup_complete', { | |||
elapsed_time: elapsedTime ?? getSignupCompleteElapsedTimeInSeconds(), |
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.
Can't we just call getSignupCompleteElapsedTimeInSeconds()
on line 64 and use that value. The closure will preserve the correct value.
We do not want to add the Queuing
time to the actual metric do we? since it's not relevant to the elapsed time of the UX ?
client/lib/analytics/signup.js
Outdated
@@ -81,6 +93,7 @@ export function recordSignupComplete( | |||
// blog_id instead of site_id here. We keep using "siteId" otherwise since | |||
// all the other fields still refer with "site". e.g. isNewSite | |||
recordTracksEvent( 'calypso_signup_complete', { | |||
elapsed_time: elapsedTime ?? getSignupCompleteElapsedTimeInSeconds(), |
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.
Also do you think we can rename the prop to time_since_signup_start
I have a feeling that we might need to add this time stamp across multiple events to make sense of the data and the above event name is a bit more descriptive.
Actually I would prefer if we add this event prop to all other major signup events like calypso_signup_actions_submit_step
, calypso_new_user_site_creation
, calypso_user_registration_complete
from the get go. But this can be followed up in another PR if you prefer 👍.
client/lib/analytics/signup.js
Outdated
@@ -57,6 +68,7 @@ export function recordSignupComplete( | |||
'signup', | |||
'recordSignupComplete', | |||
{ | |||
elapsedTime: elapsedTime ?? getSignupCompleteElapsedTimeInSeconds(), |
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.
Nit. Ignorable. Maybe we can do getSignupCompletionDuration
and add a comment regarding the metric and more context :)
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.
I'm not sure I fully understand your meaning. Do you mean getSignupCompleteElapsedTime()
and a comment regarding what this prop means?
Good suggestion, @jdc91 . I did that simply because the original request was in seconds, but it's simpler and even better to record the elapsed time in milliseconds. I've updated it accordingly, along with other inline comments. This PR should be ready for your revisit now :) |
I'm going ahead and deploying it. Any follow-up suggestions is still welcome :) |
…rt` and `calypso_signup_complete` (#83944) * Implement the total elapsed time tracking between `calypso_signup_start` and `calypso_signup_complete` * Remove start_time from `calypso_signup_start` since it's likely not used in the analysis * Take the implicit queuing of `recordSignupCompleteEvent` into account. * `elapsedTime` should be mark as optional * Use the performance clock to compute the elapsed time instead
Proposed Changes
This PR implements the request of Automattic/martech#2383, adding the tracking to the total elapsed time for completing a sign-up flow. The time is computed as between
calypso_signup_start
andcalypso_signup_complete
. It's implemented using the session storage along side other signup storage utilities for the following reasons:lib/analytics/signup
module directly. While this dependency relationship is questionable, it's the easiest way to get this functionality working across the classic signup framework and the Stepper framework that I can think of for now.Testing Instructions
calypso_signup_complete
event with the new propelapsed_time
./start
,calypso_signup_complete
should containelaped_time
field indicating how many seconds has been taken./start
as a logged-in user, the same/start/do-it-for-me
,/start/domain
/setup/newsletter
Pre-merge Checklist