-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated env feature flags to openfeature
- Loading branch information
1 parent
fedae9e
commit fbe982b
Showing
34 changed files
with
197 additions
and
85 deletions.
There are no files selected for viewing
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
29 changes: 21 additions & 8 deletions
29
packages/commonwealth/client/scripts/helpers/feature-flags.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 |
---|---|---|
@@ -1,12 +1,25 @@ | ||
// As of 240205, we are moving away from the use of env vars for feature flags, | ||
// and towards the use of Unleash for all flag management. | ||
// This is our in memory provider setup. It does not automatically ensure your | ||
// feature flag is set on our Unleash instance (May not be available on prod). | ||
// | ||
// See knowledge_base/Feature-Flags.md for info. | ||
// See knowledge_base/Feature-Flags.md for more info. | ||
|
||
const buildFlag = (env: string) => { | ||
return { | ||
variants: { | ||
on: true, | ||
off: false, | ||
}, | ||
disabled: false, | ||
defaultVariant: env === 'true' ? 'on' : 'off', | ||
}; | ||
}; | ||
|
||
export const featureFlags = { | ||
proposalTemplates: process.env.FLAG_PROPOSAL_TEMPLATES === 'true', | ||
communityHomepage: process.env.FLAG_COMMUNITY_HOMEPAGE === 'true', | ||
newAdminOnboardingEnabled: process.env.FLAG_NEW_ADMIN_ONBOARDING === 'true', | ||
communityStake: process.env.FLAG_COMMUNITY_STAKE === 'true', | ||
newSignInModal: process.env.FLAG_NEW_SIGN_IN_MODAL === 'true', | ||
proposalTemplates: buildFlag(process.env.FLAG_PROPOSAL_TEMPLATES), | ||
communityHomepage: buildFlag(process.env.FLAG_COMMUNITY_HOMEPAGE), | ||
newAdminOnboarding: buildFlag(process.env.FLAG_NEW_ADMIN_ONBOARDING), | ||
communityStake: buildFlag(process.env.FLAG_COMMUNITY_STAKE), | ||
newSignInModal: buildFlag(process.env.FLAG_NEW_SIGN_IN_MODAL), | ||
}; | ||
|
||
export type AvailableFeatureFlag = keyof typeof featureFlags; |
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,8 @@ | ||
import { useBooleanFlagValue } from '@openfeature/react-sdk'; | ||
import { AvailableFeatureFlag } from '../helpers/feature-flags'; | ||
|
||
export const useFlag = (name: AvailableFeatureFlag) => { | ||
return useBooleanFlagValue(name, false, { | ||
updateOnConfigurationChanged: false, | ||
}); | ||
}; |
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
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
Oops, something went wrong.