build: default flags but maintain togglability (#5702)

fix: default flags but maintain togglability
This commit is contained in:
Zach Pomerantz 2022-12-15 10:56:06 -08:00 committed by GitHub
parent 1f871d4e73
commit 21a2863ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

@ -55,12 +55,13 @@ export enum BaseVariant {
Enabled = 'enabled', Enabled = 'enabled',
} }
export function useBaseFlag(flag: string): BaseVariant { export function useBaseFlag(flag: string, defaultValue = BaseVariant.Control): BaseVariant {
switch (useFeatureFlagsContext().flags[flag]) { switch (useFeatureFlagsContext().flags[flag]) {
case 'enabled': case 'enabled':
return BaseVariant.Enabled return BaseVariant.Enabled
case 'control': case 'control':
default:
return BaseVariant.Control return BaseVariant.Control
default:
return defaultValue
} }
} }

@ -7,6 +7,7 @@ export function isTestEnv(): boolean {
} }
export function isStagingEnv(): boolean { export function isStagingEnv(): boolean {
// NB: This is set in vercel builds.
return Boolean(process.env.REACT_APP_STAGING) return Boolean(process.env.REACT_APP_STAGING)
} }