From f13628cc7798a858734c2dae21521984f7981ba7 Mon Sep 17 00:00:00 2001 From: Renan Carvalho Date: Tue, 8 Oct 2024 18:12:14 +0200 Subject: [PATCH] Track events: Fix tracking property when transferring domains (#95214) * Track event when using own domain * Fix tracking property on start * Improve variable definition --- .../landing/stepper/declarative-flow/onboarding.ts | 1 + .../stepper/hooks/use-record-signup-complete.ts | 14 +++++++++++++- client/signup/main.jsx | 12 +++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/client/landing/stepper/declarative-flow/onboarding.ts b/client/landing/stepper/declarative-flow/onboarding.ts index e195e4ce109f8..3d9c5bc28f2d1 100644 --- a/client/landing/stepper/declarative-flow/onboarding.ts +++ b/client/landing/stepper/declarative-flow/onboarding.ts @@ -99,6 +99,7 @@ const onboarding: Flow = { setRedirectedToUseMyDomain( false ); return navigate( 'plans' ); case 'use-my-domain': + setSignupDomainOrigin( SIGNUP_DOMAIN_ORIGIN.USE_YOUR_DOMAIN ); if ( providedDependencies?.mode && providedDependencies?.domain ) { return navigate( `use-my-domain?step=${ providedDependencies.mode }&initialQuery=${ providedDependencies.domain }` diff --git a/client/landing/stepper/hooks/use-record-signup-complete.ts b/client/landing/stepper/hooks/use-record-signup-complete.ts index 481a445e6c481..7e7499c39416c 100644 --- a/client/landing/stepper/hooks/use-record-signup-complete.ts +++ b/client/landing/stepper/hooks/use-record-signup-complete.ts @@ -75,6 +75,18 @@ export const useRecordSignupComplete = ( flow: string | null ) => { true ); }, - [ domainCartItem, flow, planCartItem, selectedDomain, siteCount, siteId, theme ] + [ + domainCartItem, + flow, + isNewUser, + isNewishUser, + planCartItem, + selectedDomain, + signupDomainOrigin, + site?.slug, + siteCount, + siteId, + theme, + ] ); }; diff --git a/client/signup/main.jsx b/client/signup/main.jsx index 8a12c07953e55..39a92aaa0ce55 100644 --- a/client/signup/main.jsx +++ b/client/signup/main.jsx @@ -565,6 +565,12 @@ class Signup extends Component { // but it's not recommended outside of this, hence the name toStepper. See Automattic/growth-foundations#72 for more context. if ( ! dependencies.toStepper ) { debug( 'Tracking signup completion.', debugProps ); + const isMapping = domainItem && isDomainMapping( domainItem ); + const isTransfer = domainItem && isDomainTransfer( domainItem ); + const signupDomainOriginValue = + isTransfer || isMapping + ? SIGNUP_DOMAIN_ORIGIN.USE_YOUR_DOMAIN + : signupDomainOrigin ?? SIGNUP_DOMAIN_ORIGIN.NOT_SET; recordSignupComplete( { flow: this.props.flowName, @@ -582,9 +588,9 @@ class Signup extends Component { intent, startingPoint, isBlankCanvas: isBlankCanvasDesign( dependencies.selectedDesign ), - isMapping: domainItem && isDomainMapping( domainItem ), - isTransfer: domainItem && isDomainTransfer( domainItem ), - signupDomainOrigin: signupDomainOrigin ?? SIGNUP_DOMAIN_ORIGIN.NOT_SET, + isMapping: isMapping, + isTransfer: isTransfer, + signupDomainOrigin: signupDomainOriginValue, } ); } };