From ae77e60ca81ad5966aca5bb4b8fe8a45aea6d12b Mon Sep 17 00:00:00 2001 From: Christos Date: Wed, 2 Oct 2024 15:39:33 +0300 Subject: [PATCH] cleanup --- .../use-sign-up-start-tracking/index.tsx | 19 ++++++++++++------- .../use-sign-up-start-tracking/test/index.tsx | 4 +++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/client/landing/stepper/declarative-flow/internals/hooks/use-sign-up-start-tracking/index.tsx b/client/landing/stepper/declarative-flow/internals/hooks/use-sign-up-start-tracking/index.tsx index 1c86ff1669c29c..ded48696fdd715 100644 --- a/client/landing/stepper/declarative-flow/internals/hooks/use-sign-up-start-tracking/index.tsx +++ b/client/landing/stepper/declarative-flow/internals/hooks/use-sign-up-start-tracking/index.tsx @@ -19,12 +19,10 @@ export const useSignUpStartTracking = ( { flow }: Props ) => { const [ queryParams ] = useSearchParams(); const ref = queryParams.get( 'ref' ) || ''; const flowName = flow.name; + const flowVariant = flow.variantSlug; const isSignupFlow = flow.isSignupFlow; - const extraProps = useSnakeCasedKeys( { - input: { - flowVariant: flow.variantSlug, - ...flow.useTracksEventProps?.()[ STEPPER_TRACKS_EVENT_SIGNUP_START ], - }, + const signupStartEventProps = useSnakeCasedKeys( { + input: flow.useTracksEventProps?.()[ STEPPER_TRACKS_EVENT_SIGNUP_START ], } ); /** @@ -50,6 +48,13 @@ export const useSignUpStartTracking = ( { flow }: Props ) => { return; } - recordSignupStart( { flow: flowName, ref, optionalProps: extraProps || {} } ); - }, [ isSignupFlow, flowName, ref, extraProps ] ); + recordSignupStart( { + flow: flowName, + ref, + optionalProps: { + ...signupStartEventProps, + ...( flowVariant && { flow_variant: flowVariant } ), + }, + } ); + }, [ isSignupFlow, flowName, ref, signupStartEventProps, flowVariant ] ); }; diff --git a/client/landing/stepper/declarative-flow/internals/hooks/use-sign-up-start-tracking/test/index.tsx b/client/landing/stepper/declarative-flow/internals/hooks/use-sign-up-start-tracking/test/index.tsx index 73f936f84efe97..7554fd9656e981 100644 --- a/client/landing/stepper/declarative-flow/internals/hooks/use-sign-up-start-tracking/test/index.tsx +++ b/client/landing/stepper/declarative-flow/internals/hooks/use-sign-up-start-tracking/test/index.tsx @@ -135,7 +135,9 @@ describe( 'useSignUpTracking', () => { const { rerender } = render( { flow: { ...signUpFlow, - useSignupStartEventProps: () => ( { extra: 'props' } ), + useTracksEventProps: () => ( { + [ STEPPER_TRACKS_EVENT_SIGNUP_START ]: { extra: 'props' }, + } ), } satisfies Flow, } );