diff --git a/src/components/Tokens/TokenDetails/MobileBalanceSummaryFooter.tsx b/src/components/Tokens/TokenDetails/MobileBalanceSummaryFooter.tsx index d6a11ae4d0..0d0d355455 100644 --- a/src/components/Tokens/TokenDetails/MobileBalanceSummaryFooter.tsx +++ b/src/components/Tokens/TokenDetails/MobileBalanceSummaryFooter.tsx @@ -3,11 +3,10 @@ import { formatCurrencyAmount, NumberType } from '@uniswap/conedison/format' import { Currency } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' import { NATIVE_CHAIN_ID } from 'constants/tokens' -import { FeatureGate } from 'featureFlags/flags/featureFlags' +import { useDummyGateEnabled } from 'featureFlags/flags/dummyFeatureGate' import { CHAIN_ID_TO_BACKEND_NAME } from 'graphql/data/util' import { useStablecoinValue } from 'hooks/useStablecoinPrice' import useCurrencyBalance from 'lib/hooks/useCurrencyBalance' -import { useGate } from 'statsig-react' import styled from 'styled-components/macro' import { StyledInternalLink } from 'theme' @@ -89,7 +88,7 @@ export default function MobileBalanceSummaryFooter({ token }: { token: Currency const formattedBalance = formatCurrencyAmount(balance, NumberType.TokenNonTx) const formattedUsdValue = formatCurrencyAmount(useStablecoinValue(balance), NumberType.FiatTokenStats) const chain = CHAIN_ID_TO_BACKEND_NAME[token.chainId].toLowerCase() - const { value: isDummyGateFlagEnabled } = useGate(FeatureGate.DUMMY) + const isDummyGateFlagEnabled = useDummyGateEnabled() return ( diff --git a/src/featureFlags/flags/dummyFeatureGate.ts b/src/featureFlags/flags/dummyFeatureGate.ts new file mode 100644 index 0000000000..d23d21d431 --- /dev/null +++ b/src/featureFlags/flags/dummyFeatureGate.ts @@ -0,0 +1,9 @@ +import { BaseVariant, FeatureFlag, useBaseFlag } from '../index' + +function useDummyGateFlag(): BaseVariant { + return useBaseFlag(FeatureFlag.statsigDummy) +} + +export function useDummyGateEnabled(): boolean { + return useDummyGateFlag() === BaseVariant.Enabled +} diff --git a/src/featureFlags/flags/featureFlags.ts b/src/featureFlags/flags/featureFlags.ts index 2b95306ce9..909fecee9d 100644 --- a/src/featureFlags/flags/featureFlags.ts +++ b/src/featureFlags/flags/featureFlags.ts @@ -1,11 +1,11 @@ +/** + * The value here must match the value in the statsig dashboard, if you plan to use statsig. + */ export enum FeatureFlag { traceJsonRpc = 'traceJsonRpc', permit2 = 'permit2', payWithAnyToken = 'payWithAnyToken', - swapWidget = 'swapWidget', + swapWidget = 'swap_widget_replacement_enabled', gqlRouting = 'gqlRouting', -} - -export enum FeatureGate { - DUMMY = 'web_dummy_gate_amplitude_id', + statsigDummy = 'web_dummy_gate_amplitude_id', } diff --git a/src/featureFlags/index.tsx b/src/featureFlags/index.tsx index 1f3a1e13dc..316b4ebf6e 100644 --- a/src/featureFlags/index.tsx +++ b/src/featureFlags/index.tsx @@ -1,5 +1,6 @@ import { atomWithStorage, useAtomValue, useUpdateAtom } from 'jotai/utils' import { createContext, ReactNode, useCallback, useContext } from 'react' +import { useGate } from 'statsig-react' export { FeatureFlag } from './flags/featureFlags' interface FeatureFlagsContextType { @@ -56,7 +57,12 @@ export enum BaseVariant { } export function useBaseFlag(flag: string, defaultValue = BaseVariant.Control): BaseVariant { - switch (useFeatureFlagsContext().flags[flag]) { + const { value: statsigValue } = useGate(flag) // non-existent gates return false + const featureFlagsContext = useFeatureFlagsContext() + if (statsigValue) { + return BaseVariant.Enabled + } + switch (featureFlagsContext.flags[flag]) { case 'enabled': return BaseVariant.Enabled case 'control':