Skip to content

Commit

Permalink
Rename the flag that indicate the flow is starting from a non initial…
Browse files Browse the repository at this point in the history
… step (#94364)
  • Loading branch information
gabrielcaires authored Sep 10, 2024
1 parent dd590a0 commit cde9f52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ export const useSignUpStartTracking = ( { flow, currentStepRoute }: Props ) => {
const steps = flow.useSteps();
const [ queryParams, setQuery ] = useSearchParams();
const ref = queryParams.get( 'ref' ) || '';
const isSignupStep = queryParams.has( 'signup' );

// TODO: Using the new signup flag we can remove reference to SENSEI_FLOW
// TODO: Using the new start flag we can remove reference to SENSEI_FLOW
const firstStepSlug = ( flow.name === SENSEI_FLOW ? steps[ 1 ] : steps[ 0 ] ).slug;
const isFirstStep = firstStepSlug === currentStepRoute;
const flowVariant = flow.variantSlug;
const signupStartEventProps = flow.useSignupStartEventProps?.();
const isStartingFlow = isFirstStep || queryParams.has( 'start' );
const flowName = flow.name;
const shouldTrack = flow.isSignupFlow && isStartingFlow;

const extraProps = useMemo(
() => ( {
Expand All @@ -31,11 +33,10 @@ export const useSignUpStartTracking = ( { flow, currentStepRoute }: Props ) => {
} ),
[ signupStartEventProps, flowVariant ]
);
const flowName = flow.name;
const shouldTrack = flow.isSignupFlow && ( isFirstStep || isSignupStep );

const removeSignupParam = useCallback( () => {
if ( queryParams.has( 'signup' ) ) {
queryParams.delete( 'signup' );
if ( queryParams.has( 'start' ) ) {
queryParams.delete( 'start' );
setQuery( queryParams );
}
}, [ queryParams, setQuery ] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe( 'useSignUpTracking', () => {
} );

it( 'does not track event when the flow is not a isSignupFlow and the signup flag is set', () => {
render( { flow: regularFlow, currentStepRoute: 'step-1', queryParams: { signup: 1 } } );
render( { flow: regularFlow, currentStepRoute: 'step-1', queryParams: { start: 1 } } );

expect( recordTracksEvent ).not.toHaveBeenCalled();
} );
Expand All @@ -85,11 +85,11 @@ describe( 'useSignUpTracking', () => {
} );
} );

it( 'tracks the event when the step is not the first but the signup flag is set', () => {
it( 'tracks the event when the step is not the first but the start flag is set', () => {
render( {
flow: signUpFlow,
currentStepRoute: 'step-2',
queryParams: { signup: 1 },
queryParams: { start: 1 },
} );

expect( recordTracksEvent ).toHaveBeenCalledWith( 'calypso_signup_start', {
Expand Down

0 comments on commit cde9f52

Please sign in to comment.