-
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.
Add experiment assignment to Big Sky before plans
- Loading branch information
Showing
7 changed files
with
54 additions
and
21 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
client/landing/stepper/declarative-flow/helpers/use-bigsky-before-plans-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,33 @@ | ||
import { isEnabled } from '@automattic/calypso-config'; | ||
import { ONBOARDING_FLOW } from '@automattic/onboarding'; | ||
import { useMemo } from 'react'; | ||
import { useExperiment } from 'calypso/lib/explat'; | ||
import { getFlowFromURL } from '../../utils/get-flow-from-url'; | ||
|
||
// TODO: change the experiment name accordingly | ||
export const EXPERIMENT_NAME = 'calypso_woo_express_plans_grid_2023'; | ||
|
||
/** | ||
* Check whether the user should have the "Big Sky before plans" onboarding experience. | ||
* | ||
* Returns [ isLoading, isBigSkyBeforePlans ] | ||
*/ | ||
export function useBigSkyBeforePlans(): [ boolean, boolean ] { | ||
const flow = useMemo( () => getFlowFromURL(), [] ); | ||
|
||
const [ isLoading, experimentAssignment ] = useExperiment( EXPERIMENT_NAME, { | ||
isEligible: flow === ONBOARDING_FLOW && ! isEnabled( 'onboarding/force-big-sky-before-plan' ), | ||
} ); | ||
|
||
if ( isEnabled( 'onboarding/force-big-sky-before-plan' ) ) { | ||
return [ false, true ]; | ||
} | ||
|
||
/** | ||
* This fallback is necessary because experimentAssignment returns null when the user | ||
* is not eligible, and we're using this hook within steps that are used by other flows. | ||
*/ | ||
const variationName = experimentAssignment?.variationName ?? 'control'; | ||
|
||
return [ isLoading, variationName === 'treatment' ]; | ||
} |
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