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

Goals First: Prevent calypso_signup_start from firing multiple times #98182

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions client/landing/stepper/declarative-flow/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { OnboardSelect, Onboard, UserSelect } from '@automattic/data-stores';
import { ONBOARDING_FLOW, clearStepPersistedState } from '@automattic/onboarding';
import { useDispatch, useSelect } from '@wordpress/data';
import { addQueryArgs, getQueryArg, getQueryArgs, removeQueryArgs } from '@wordpress/url';
import { useState, useMemo, useEffect } from 'react';
import { useState, useMemo, useEffect, useRef } from 'react';
import { SIGNUP_DOMAIN_ORIGIN } from 'calypso/lib/analytics/signup';
import { pathToUrl } from 'calypso/lib/url';
import {
Expand Down Expand Up @@ -57,6 +57,9 @@ const onboarding: Flow = {
[]
);

// we are only interested in the initial goals value when the user enters the goals step
Copy link
Contributor

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" ?

Copy link
Contributor

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! 😄

const initialGoals = useRef( goals );

return useMemo(
() => ( {
[ STEPPER_TRACKS_EVENT_SIGNUP_START ]: {
Expand All @@ -68,10 +71,12 @@ const onboarding: Flow = {
...( isGoalsAtFrontExperiment && {
is_goals_first: isGoalsAtFrontExperiment.toString(),
} ),
...( goals.length && { goals: goals.join( ',' ) } ),
...( initialGoals.current.length && {
goals: initialGoals.current.join( ',' ),
} ),
},
} ),
[ isGoalsAtFrontExperiment, userIsLoggedIn, goals ]
[ isGoalsAtFrontExperiment, userIsLoggedIn, initialGoals ]
);
},
useSteps() {
Expand Down
Loading