Skip to content

Prevent launchpad track events from firing when focused launchpad to be shown #102023

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 16 additions & 1 deletion client/landing/stepper/declarative-flow/flows/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { BUILD_FLOW } from '@automattic/onboarding';
import { useSelect } from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
import { useMemo, useRef } from 'react';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { getStepFromURL } from 'calypso/landing/stepper/utils/get-flow-from-url';
import { skipLaunchpad } from 'calypso/landing/stepper/utils/skip-launchpad';
import { triggerGuidesForStep } from 'calypso/lib/guides/trigger-guides-for-step';
import { useSelector } from 'calypso/state';
import getInitialQueryArguments from 'calypso/state/selectors/get-initial-query-arguments';
import { shouldShowLaunchpadFirst } from 'calypso/state/selectors/should-show-launchpad-first';
import { STEPPER_TRACKS_EVENT_SIGNUP_STEP_START } from '../../../constants';
import { useExitFlow } from '../../../hooks/use-exit-flow';
import { useSiteIdParam } from '../../../hooks/use-site-id-param';
Expand Down Expand Up @@ -40,8 +43,10 @@ const build: Flow = {

// we are only interested in the initial values and not when they values change
const initialGoals = useRef( goals );
const site = useSite();
const step = getStepFromURL();

return useMemo(
const tracksEventProps = useMemo(
() => ( {
eventsProperties: {
[ STEPPER_TRACKS_EVENT_SIGNUP_STEP_START ]: {
Expand All @@ -56,6 +61,16 @@ const build: Flow = {
} ),
[ isGoalsAtFrontExperiment, initialGoals ]
);

if ( site && shouldShowLaunchpadFirst( site ) && step === 'launchpad' ) {
//prevent track events from firing until we're sure we won't redirect away from Launchpad
return {
isLoading: true,
eventsProperties: {},
};
}

return tracksEventProps;
},

useStepNavigation( _currentStep, navigate ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { translate } from 'i18n-calypso';
import { useEffect } from 'react';
import { useLaunchpadDecider } from 'calypso/landing/stepper/declarative-flow/internals/hooks/use-launchpad-decider';
import { useQuery } from 'calypso/landing/stepper/hooks/use-query';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { getStepFromURL } from 'calypso/landing/stepper/utils/get-flow-from-url';
import { skipLaunchpad } from 'calypso/landing/stepper/utils/skip-launchpad';
import { triggerGuidesForStep } from 'calypso/lib/guides/trigger-guides-for-step';
import {
Expand All @@ -14,6 +16,7 @@ import {
persistSignupDestination,
setSignupCompleteFlowName,
} from 'calypso/signup/storageUtils';
import { shouldShowLaunchpadFirst } from 'calypso/state/selectors/should-show-launchpad-first';
import { useExitFlow } from '../../../hooks/use-exit-flow';
import { useSiteIdParam } from '../../../hooks/use-site-id-param';
import { useSiteSlug } from '../../../hooks/use-site-slug';
Expand Down Expand Up @@ -57,6 +60,22 @@ const newsletter: Flow = {
setIntent( Onboard.SiteIntent.Newsletter );
}, [] );
},
useTracksEventProps() {
const site = useSite();
const step = getStepFromURL();
if ( site && shouldShowLaunchpadFirst( site ) && step === 'launchpad' ) {
//prevent track events from firing until we're sure we won't redirect away from Launchpad
return {
isLoading: true,
eventsProperties: {},
};
}

return {
isLoading: false,
eventsProperties: {},
};
},
useStepNavigation( _currentStep, navigate ) {
const flowName = this.name;
const siteId = useSiteIdParam();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import {
type Flow,
type ProvidedDependencies,
} from 'calypso/landing/stepper/declarative-flow/internals/types';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { SITE_STORE, ONBOARD_STORE } from 'calypso/landing/stepper/stores';
import { getStepFromURL } from 'calypso/landing/stepper/utils/get-flow-from-url';
import { skipLaunchpad } from 'calypso/landing/stepper/utils/skip-launchpad';
import { useSelector } from 'calypso/state';
import { getCurrentUserSiteCount, isUserLoggedIn } from 'calypso/state/current-user/selectors';
import { shouldShowLaunchpadFirst } from 'calypso/state/selectors/should-show-launchpad-first';
import { useExitFlow } from '../../../hooks/use-exit-flow';
import { useSiteData } from '../../../hooks/use-site-data';
import { stepsWithRequiredLogin } from '../../../utils/steps-with-required-login';
Expand Down Expand Up @@ -42,7 +45,22 @@ const startWriting: Flow = {
STEPS.CELEBRATION,
] );
},
useTracksEventProps() {
const site = useSite();
const step = getStepFromURL();
if ( site && shouldShowLaunchpadFirst( site ) && step === 'launchpad' ) {
//prevent track events from firing until we're sure we won't redirect away from Launchpad
return {
isLoading: true,
eventsProperties: {},
};
}

return {
isLoading: false,
eventsProperties: {},
};
},
useStepNavigation( currentStep, navigate ) {
const { saveSiteSettings, setIntentOnSite } = useDispatch( SITE_STORE );
const { setSelectedSite } = useDispatch( ONBOARD_STORE );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { useDispatch } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import { translate } from 'i18n-calypso';
import { useLaunchpadDecider } from 'calypso/landing/stepper/declarative-flow/internals/hooks/use-launchpad-decider';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { getStepFromURL } from 'calypso/landing/stepper/utils/get-flow-from-url';
import {
setSignupCompleteSlug,
persistSignupDestination,
setSignupCompleteFlowName,
} from 'calypso/signup/storageUtils';
import { shouldShowLaunchpadFirst } from 'calypso/state/selectors/should-show-launchpad-first';
import { useQuery } from '../../../hooks/use-query';
import { useSiteIdParam } from '../../../hooks/use-site-id-param';
import { useSiteSlug } from '../../../hooks/use-site-slug';
Expand All @@ -34,6 +37,22 @@ const updateDesign: Flow = {
setIntent( Onboard.SiteIntent.UpdateDesign );
}, [] );
},
useTracksEventProps() {
const site = useSite();
const step = getStepFromURL();
if ( site && shouldShowLaunchpadFirst( site ) && step === 'launchpad' ) {
//prevent track events from firing until we're sure we won't redirect away from Launchpad
return {
isLoading: true,
eventsProperties: {},
};
}

return {
isLoading: false,
eventsProperties: {},
};
},
useStepNavigation( currentStep, navigate ) {
const siteId = useSiteIdParam();
const siteSlug = useSiteSlug();
Expand Down
19 changes: 18 additions & 1 deletion client/landing/stepper/declarative-flow/flows/write/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { addQueryArgs } from '@wordpress/url';
import { translate } from 'i18n-calypso';
import { useEffect } from 'react';
import { useFlowLocale } from 'calypso/landing/stepper/hooks/use-flow-locale';
import { useSite } from 'calypso/landing/stepper/hooks/use-site';
import { getStepFromURL } from 'calypso/landing/stepper/utils/get-flow-from-url';
import { skipLaunchpad } from 'calypso/landing/stepper/utils/skip-launchpad';
import { triggerGuidesForStep } from 'calypso/lib/guides/trigger-guides-for-step';
import { shouldShowLaunchpadFirst } from 'calypso/state/selectors/should-show-launchpad-first';
import { useSiteIdParam } from '../../../hooks/use-site-id-param';
import { useSiteSlug } from '../../../hooks/use-site-slug';
import { USER_STORE } from '../../../stores';
Expand All @@ -18,7 +21,6 @@ import {
ProvidedDependencies,
} from '../../internals/types';
import type { UserSelect } from '@automattic/data-stores';

const WRITE_FLOW_STEPS = [ STEPS.LAUNCHPAD, STEPS.SUBSCRIBERS, STEPS.PROCESSING ];

const write: Flow = {
Expand All @@ -30,7 +32,22 @@ const write: Flow = {
useSteps() {
return WRITE_FLOW_STEPS;
},
useTracksEventProps() {
const site = useSite();
const step = getStepFromURL();
if ( site && shouldShowLaunchpadFirst( site ) && step === 'launchpad' ) {
// Keep the loading flag high, to block firing all track events from firing until we're sure we won't redirect away from Launchpad
return {
isLoading: true,
eventsProperties: {},
};
}

return {
isLoading: false,
eventsProperties: {},
};
},
useStepNavigation( _currentStep, navigate ) {
const flowName = this.name;
const siteId = useSiteIdParam();
Expand Down
Loading