diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/statsig/statsig.tsx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/statsig/statsig.tsx b/src/lib/statsig/statsig.tsx index 2e3fdfd5c..3b649f88d 100644 --- a/src/lib/statsig/statsig.tsx +++ b/src/lib/statsig/statsig.tsx @@ -130,6 +130,28 @@ export function useGate(): (gateName: Gate) => boolean { return gate } +/** + * Debugging tool to override a gate. USE ONLY IN E2E TESTS! + */ +export function useDangerousSetGate(): ( + gateName: Gate, + value: boolean, +) => void { + const cache = React.useContext(GateCache) + if (!cache) { + throw Error( + 'useDangerousSetGate() cannot be called outside StatsigProvider.', + ) + } + const dangerousSetGate = React.useCallback( + (gateName: Gate, value: boolean) => { + cache.set(gateName, value) + }, + [cache], + ) + return dangerousSetGate +} + function toStatsigUser(did: string | undefined): StatsigUser { let userID: string | undefined if (did) { |