Skip to content

Commit

Permalink
Stepper: Make framework tracking of submit-step the default. Updates …
Browse files Browse the repository at this point in the history
…remaining flows (#93319)
  • Loading branch information
chriskmnds authored Aug 22, 2024
1 parent eb03c56 commit e27db4a
Show file tree
Hide file tree
Showing 36 changed files with 50 additions and 137 deletions.
7 changes: 0 additions & 7 deletions client/landing/stepper/declarative-flow/ai-assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { getCurrentUserSiteCount, isUserLoggedIn } from 'calypso/state/current-u
import { getTheme } from 'calypso/state/themes/selectors';
import { ONBOARD_STORE, SITE_STORE } from '../stores';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { STEPS } from './internals/steps';
import { ProcessingResult } from './internals/steps-repository/processing-step/constants';
import {
Expand Down Expand Up @@ -80,11 +79,6 @@ const withAIAssemblerFlow: Flow = {
},

useStepNavigation( _currentStep, navigate ) {
const flowName = this.name;
const intent = useSelect(
( select ) => ( select( ONBOARD_STORE ) as OnboardSelect ).getIntent(),
[]
);
const siteId = useSelect(
( select ) => ( select( ONBOARD_STORE ) as OnboardSelect ).getSelectedSite(),
[]
Expand Down Expand Up @@ -169,7 +163,6 @@ const withAIAssemblerFlow: Flow = {
providedDependencies: ProvidedDependencies = {},
...results: string[]
) => {
recordSubmitStep( providedDependencies, intent, flowName, _currentStep );
const selectedSiteSlug = providedDependencies?.siteSlug as string;
const selectedSiteId = providedDependencies?.siteId as string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { getTheme } from 'calypso/state/themes/selectors';
import { useSiteData } from '../hooks/use-site-data';
import { ONBOARD_STORE, SITE_STORE } from '../stores';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { STEPS } from './internals/steps';
import { ProcessingResult } from './internals/steps-repository/processing-step/constants';
import {
Expand Down Expand Up @@ -80,11 +79,6 @@ const assemblerFirstFlow: Flow = {
},

useStepNavigation( _currentStep, navigate ) {
const flowName = this.name;
const intent = useSelect(
( select ) => ( select( ONBOARD_STORE ) as OnboardSelect ).getIntent(),
[]
);
const { setPendingAction, setSelectedSite } = useDispatch( ONBOARD_STORE );
const { saveSiteSettings, setIntentOnSite } = useDispatch( SITE_STORE );
const { site, siteSlug, siteId } = useSiteData();
Expand Down Expand Up @@ -133,8 +127,6 @@ const assemblerFirstFlow: Flow = {
providedDependencies: ProvidedDependencies = {},
...results: string[]
) => {
recordSubmitStep( providedDependencies, intent, flowName, _currentStep );

switch ( _currentStep ) {
case 'check-sites': {
// Check for unlaunched sites
Expand Down
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { skipLaunchpad } from 'calypso/landing/stepper/utils/skip-launchpad';
import { triggerGuidesForStep } from 'calypso/lib/guides/trigger-guides-for-step';
import { useSiteIdParam } from '../hooks/use-site-id-param';
import { useSiteSlug } from '../hooks/use-site-slug';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import LaunchPad from './internals/steps-repository/launchpad';
import Processing from './internals/steps-repository/processing-step';
import { Flow, ProvidedDependencies } from './internals/types';
Expand All @@ -30,8 +29,6 @@ const build: Flow = {
triggerGuidesForStep( flowName, _currentStep );

const submit = ( providedDependencies: ProvidedDependencies = {} ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStep );

switch ( _currentStep ) {
case 'processing':
if ( providedDependencies?.goToHome && providedDependencies?.siteSlug ) {
Expand Down
1 change: 0 additions & 1 deletion client/landing/stepper/declarative-flow/connect-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ const connectDomain: Flow = {
submit,
};
},
use__Temporary__ShouldTrackEvent: ( event ) => 'submit' === event,
};

export default connectDomain;
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/copy-site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
setSignupCompleteFlowName,
} from 'calypso/signup/storageUtils';
import { useSiteCopy } from '../hooks/use-site-copy';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import AutomatedCopySite from './internals/steps-repository/automated-copy-site';
import CreateSite from './internals/steps-repository/create-site';
import DomainsStep from './internals/steps-repository/domains';
Expand Down Expand Up @@ -108,8 +107,6 @@ const copySite: Flow = {
const urlQueryParams = useQuery();

const submit = async ( providedDependencies: ProvidedDependencies = {} ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStepSlug );

switch ( _currentStepSlug ) {
case 'domains': {
return navigate( 'create-site', {
Expand Down
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/design-first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useEffect } from '@wordpress/element';
import { addQueryArgs, getQueryArg } from '@wordpress/url';
import { translate } from 'i18n-calypso';
import { useSelector } from 'react-redux';
import { recordSubmitStep } from 'calypso/landing/stepper/declarative-flow/internals/analytics/record-submit-step';
import { redirect } from 'calypso/landing/stepper/declarative-flow/internals/steps-repository/import/util';
import {
type AssertConditionResult,
Expand Down Expand Up @@ -92,8 +91,6 @@ const designFirst: Flow = {
}, [ siteSlug, setIntentOnSite, isSiteLaunched ] );

async function submit( providedDependencies: ProvidedDependencies = {} ) {
recordSubmitStep( providedDependencies, '', flowName, currentStep );

switch ( currentStep ) {
case 'check-sites':
// Check for unlaunched sites
Expand Down
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/domain-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { isUserLoggedIn } from 'calypso/state/current-user/selectors';
import { USER_STORE } from '../stores';
import { useLoginUrl } from '../utils/path';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import {
Flow,
ProvidedDependencies,
Expand Down Expand Up @@ -70,8 +69,6 @@ const domainTransfer: Flow = {
} );

const submit = ( providedDependencies: ProvidedDependencies = {} ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStepSlug );

switch ( _currentStepSlug ) {
case 'intro':
clearSignupDestinationCookie();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useEffect } from '@wordpress/element';
import { translate } from 'i18n-calypso';
import { recordSubmitStep } from 'calypso/landing/stepper/declarative-flow/internals/analytics/record-submit-step';
import { redirect } from 'calypso/landing/stepper/declarative-flow/internals/steps-repository/import/util';
import {
AssertConditionResult,
Expand All @@ -23,10 +22,7 @@ const domainUserTransfer: Flow = {
},

useStepNavigation( currentStep, navigate ) {
const flowName = this.name;

function submit( providedDependencies: ProvidedDependencies = {} ) {
recordSubmitStep( providedDependencies, '', flowName, currentStep );
switch ( currentStep ) {
case 'domain-contact-info':
return window.location.assign(
Expand Down
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/entrepreneur-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { isUserLoggedIn } from 'calypso/state/current-user/selectors';
import { useFlowLocale } from '../hooks/use-flow-locale';
import { USER_STORE, ONBOARD_STORE } from '../stores';
import { getLoginUrl } from '../utils/path';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { STEPS } from './internals/steps';
import { ProcessingResult } from './internals/steps-repository/processing-step/constants';
import { ENTREPRENEUR_TRIAL_SURVEY_KEY } from './internals/steps-repository/segmentation-survey';
Expand Down Expand Up @@ -78,8 +77,6 @@ const entrepreneurFlow: Flow = {
};

function submit( providedDependencies: ProvidedDependencies = {}, ...params: string[] ) {
recordSubmitStep( providedDependencies, '' /* intent */, flowName, currentStep );

switch ( currentStep ) {
case SEGMENTATION_SURVEY_SLUG: {
setIsMigrationFlow( !! providedDependencies.isMigrationFlow );
Expand Down
1 change: 0 additions & 1 deletion client/landing/stepper/declarative-flow/free-post-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const freePostSetup: Flow = {

return { goNext, goBack, goToStep, submit };
},
use__Temporary__ShouldTrackEvent: ( event ) => 'submit' === event,
};

export default freePostSetup;
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/free.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { useSiteIdParam } from '../hooks/use-site-id-param';
import { useSiteSlug } from '../hooks/use-site-slug';
import { ONBOARD_STORE } from '../stores';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { STEPS } from './internals/steps';
import { ProcessingResult } from './internals/steps-repository/processing-step/constants';
import { Flow, ProvidedDependencies } from './internals/types';
Expand Down Expand Up @@ -68,8 +67,6 @@ const free: Flow = {
};

const submit = ( providedDependencies: ProvidedDependencies = {}, ...results: string[] ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStep );

switch ( _currentStep ) {
case 'freeSetup':
return navigate( 'create-site' );
Expand Down
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/hundred-year-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { SiteId, SiteSlug } from 'calypso/types';
import { ONBOARD_STORE, USER_STORE } from '../stores';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import type { ProvidedDependencies, Flow } from './internals/types';

const HundredYearPlanFlow: Flow = {
Expand Down Expand Up @@ -88,8 +87,6 @@ const HundredYearPlanFlow: Flow = {
const { setPlanCartItem, setPendingAction } = useDispatch( ONBOARD_STORE );

function submit( providedDependencies: ProvidedDependencies = {} ) {
recordSubmitStep( providedDependencies, '', flowName, _currentStep );

const updateCartForExistingSite = async () => {
if ( ! providedDependencies?.siteSlug || ! providedDependencies?.siteId ) {
return;
Expand Down
18 changes: 12 additions & 6 deletions client/landing/stepper/declarative-flow/link-in-bio-post-setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Onboard } from '@automattic/data-stores';
import { LINK_IN_BIO_POST_SETUP_FLOW } from '@automattic/onboarding';
import { useDispatch } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import { translate } from 'i18n-calypso';
import { useSiteSlug } from '../hooks/use-site-slug';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { ONBOARD_STORE } from '../stores';
import LinkInBioPostSetup from './internals/steps-repository/link-in-bio-post-setup';
import { ProvidedDependencies } from './internals/types';
import type { Flow } from './internals/types';

const linkInBioPostSetup: Flow = {
Expand All @@ -15,14 +17,18 @@ const linkInBioPostSetup: Flow = {
useSteps() {
return [ { slug: 'linkInBioPostSetup', component: LinkInBioPostSetup } ];
},
useSideEffect() {
const { setIntent } = useDispatch( ONBOARD_STORE );

useEffect( () => {
setIntent( Onboard.SiteIntent.LinkInBioPostSetup );
}, [] );
},

useStepNavigation( currentStep ) {
const flowName = this.name;
const siteSlug = useSiteSlug();

function submit( providedDependencies: ProvidedDependencies = {} ) {
recordSubmitStep( providedDependencies, 'link-in-bio-post-setup', flowName, currentStep );

function submit() {
switch ( currentStep ) {
case 'linkInBioPostSetup':
return window.location.assign( `/setup/link-in-bio/launchpad?siteSlug=${ siteSlug }` );
Expand Down
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/link-in-bio-tld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { useSiteIdParam } from '../hooks/use-site-id-param';
import { useSiteSlug } from '../hooks/use-site-slug';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import CreateSite from './internals/steps-repository/create-site';
import DesignCarousel from './internals/steps-repository/design-carousel';
import DomainsStep from './internals/steps-repository/domains';
Expand Down Expand Up @@ -48,8 +47,6 @@ const linkInBio: Flow = {
triggerGuidesForStep( flowName, _currentStepSlug );

const submit = ( providedDependencies: ProvidedDependencies = {} ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStepSlug );

switch ( _currentStepSlug ) {
case 'domains':
clearSignupDestinationCookie();
Expand Down
3 changes: 0 additions & 3 deletions client/landing/stepper/declarative-flow/link-in-bio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { useSiteIdParam } from '../hooks/use-site-id-param';
import { useSiteSlug } from '../hooks/use-site-slug';
import { USER_STORE, ONBOARD_STORE } from '../stores';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import type { Flow, ProvidedDependencies } from './internals/types';

const linkInBio: Flow = {
Expand Down Expand Up @@ -77,8 +76,6 @@ const linkInBio: Flow = {
triggerGuidesForStep( flowName, _currentStepSlug );

const submit = ( providedDependencies: ProvidedDependencies = {} ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStepSlug );

switch ( _currentStepSlug ) {
case 'intro':
clearSignupDestinationCookie();
Expand Down
9 changes: 1 addition & 8 deletions client/landing/stepper/declarative-flow/migration-signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import { useSiteSlugParam } from '../hooks/use-site-slug-param';
import { USER_STORE, ONBOARD_STORE, SITE_STORE } from '../stores';
import { goToCheckout } from '../utils/checkout';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { STEPS } from './internals/steps';
import { type SiteMigrationIdentifyAction } from './internals/steps-repository/site-migration-identify';
import type { Flow, ProvidedDependencies } from './internals/types';
import type { OnboardSelect, SiteSelect, UserSelect } from '@automattic/data-stores';
import type { SiteSelect, UserSelect } from '@automattic/data-stores';

const FLOW_NAME = MIGRATION_SIGNUP_FLOW;

Expand Down Expand Up @@ -71,11 +70,6 @@ const migrationSignup: Flow = {
},

useStepNavigation( currentStep, navigate ) {
const flowName = this.name;
const intent = useSelect(
( select ) => ( select( ONBOARD_STORE ) as OnboardSelect ).getIntent(),
[]
);
const siteSlugParam = useSiteSlugParam();
const urlQueryParams = useQuery();
const fromQueryParam = urlQueryParams.get( 'from' );
Expand All @@ -87,7 +81,6 @@ const migrationSignup: Flow = {

// TODO - We may need to add `...params: string[]` back once we start adding more steps.
function submit( providedDependencies: ProvidedDependencies = {} ) {
recordSubmitStep( providedDependencies, intent, flowName, currentStep );
const siteSlug = ( providedDependencies?.siteSlug as string ) || siteSlugParam || '';
const siteId = getSiteIdBySlug( siteSlug ) || urlQueryParams.get( 'siteId' );

Expand Down
2 changes: 0 additions & 2 deletions client/landing/stepper/declarative-flow/migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,4 @@ export default {

return stepHandlers[ currentStep ];
},

use__Temporary__ShouldTrackEvent: ( event ) => 'submit' === event,
} satisfies Flow;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { isUserEligibleForFreeHostingTrial } from 'calypso/state/selectors/is-us
import { setSelectedSiteId } from 'calypso/state/ui/actions/index';
import { useQuery } from '../hooks/use-query';
import { ONBOARD_STORE, USER_STORE } from '../stores';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { Flow, ProvidedDependencies } from './internals/types';
import type { OnboardSelect, UserSelect } from '@automattic/data-stores';
import type { MinimalRequestCartProduct } from '@automattic/shopping-cart';
Expand Down Expand Up @@ -60,8 +59,6 @@ const hosting: Flow = {
};

const submit = ( providedDependencies: ProvidedDependencies = {} ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStepSlug );

switch ( _currentStepSlug ) {
case 'user': {
return navigate( 'plans' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { setSelectedSiteId } from 'calypso/state/ui/actions';
import { useQuery } from '../hooks/use-query';
import { ONBOARD_STORE, USER_STORE } from '../stores';
import { useLoginUrl } from '../utils/path';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { Flow, ProvidedDependencies } from './internals/types';
import type { OnboardSelect, UserSelect } from '@automattic/data-stores';
import type { MinimalRequestCartProduct } from '@automattic/shopping-cart';
Expand Down Expand Up @@ -63,8 +62,6 @@ const hosting: Flow = {
};

const submit = ( providedDependencies: ProvidedDependencies = {} ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStepSlug );

switch ( _currentStepSlug ) {
case 'plans': {
const productSlug = ( providedDependencies.plan as MinimalRequestCartProduct )
Expand Down
14 changes: 10 additions & 4 deletions client/landing/stepper/declarative-flow/newsletter-post-setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Onboard } from '@automattic/data-stores';
import { NEWSLETTER_POST_SETUP_FLOW } from '@automattic/onboarding';
import { useDispatch } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import { translate } from 'i18n-calypso';
import { useSiteSlug } from '../hooks/use-site-slug';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { ONBOARD_STORE } from '../stores';
import NewsletterPostSetup from './internals/steps-repository/newsletter-post-setup';
import { ProvidedDependencies } from './internals/types';
import type { Flow } from './internals/types';
Expand All @@ -15,14 +18,17 @@ const newsletterPostSetup: Flow = {
useSteps() {
return [ { slug: 'newsletterPostSetup', component: NewsletterPostSetup } ];
},
useSideEffect() {
const { setIntent } = useDispatch( ONBOARD_STORE );

useEffect( () => {
setIntent( Onboard.SiteIntent.NewsletterPostSetup );
}, [] );
},
useStepNavigation( currentStep, navigate ) {
const flowName = this.name;
const siteSlug = useSiteSlug();

function submit( providedDependencies: ProvidedDependencies = {} ) {
recordSubmitStep( providedDependencies, 'newsletter-post-setup', flowName, currentStep );

switch ( currentStep ) {
case 'newsletterPostSetup':
return window.location.assign(
Expand Down
1 change: 0 additions & 1 deletion client/landing/stepper/declarative-flow/newsletter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ const newsletter: Flow = {

return { goNext, goBack, goToStep, submit };
},
use__Temporary__ShouldTrackEvent: ( event ) => 'submit' === event,
};

export default newsletter;
Loading

0 comments on commit e27db4a

Please sign in to comment.