-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prototype: Move goals step to front of onboarding if `onboarding/goal…
…s-first` flag (#96866) * Move goals step to front of onboarding if onboarding/goals-first flag * Ensure experiment assignment loads before showing first step * Enable on staging
- Loading branch information
Showing
7 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
client/landing/stepper/declarative-flow/helpers/use-goals-first-experiment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { isEnabled } from '@automattic/calypso-config'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
/** | ||
* Check whether the user should have the "goals first" onboarding experience. | ||
* Returns [ isLoading, isGoalsAtFrontExperiment ] | ||
* | ||
* The experience is currently gated behind a feature flag which is loaded immediately, | ||
* but we want to code as if loading time might be involved. So this hook has a fake | ||
* timer. | ||
* Note: It's important that there be no timer in the production experience | ||
* i.e. when the feature flag is disabled. | ||
*/ | ||
export function useGoalsFirstExperiment(): [ boolean, boolean ] { | ||
const [ isLoading, setIsLoading ] = useState( true ); | ||
useEffect( () => { | ||
if ( ! isEnabled( 'onboarding/goals-first' ) ) { | ||
return; | ||
} | ||
|
||
const id = setTimeout( () => setIsLoading( false ), 700 ); | ||
return () => { | ||
clearTimeout( id ); | ||
}; | ||
}, [] ); | ||
|
||
if ( ! isEnabled( 'onboarding/goals-first' ) ) { | ||
return [ false, false ]; | ||
} | ||
|
||
return [ isLoading, true ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters