about summary refs log tree commit diff
path: root/src/lib/statsig/statsig.tsx
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-05-21 00:17:57 +0100
committerGitHub <noreply@github.com>2024-05-21 00:17:57 +0100
commit4fa92d7a49e8a1e6118053de4d5d4174b894b528 (patch)
tree738a68135e30dfc323765213ed52aa78b9d80eea /src/lib/statsig/statsig.tsx
parent516eb69637d4d71cb25397376f9e1e5d3680f314 (diff)
downloadvoidsky-4fa92d7a49e8a1e6118053de4d5d4174b894b528.tar.zst
[Statsig] Fix exposure logging for reduced onboarding (#4131)
* Add dangerouslyDisableExposureLogging option

* Rename onboarding gate to v2

* Disable exposure logging for onboarding in PostFeed query
Diffstat (limited to 'src/lib/statsig/statsig.tsx')
-rw-r--r--src/lib/statsig/statsig.tsx19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/statsig/statsig.tsx b/src/lib/statsig/statsig.tsx
index 3b649f88d..005027820 100644
--- a/src/lib/statsig/statsig.tsx
+++ b/src/lib/statsig/statsig.tsx
@@ -108,20 +108,29 @@ export function logEvent<E extends keyof LogEvents>(
 // Our own cache ensures consistent evaluation within a single session.
 const GateCache = React.createContext<Map<string, boolean> | null>(null)
 
-export function useGate(): (gateName: Gate) => boolean {
+type GateOptions = {
+  dangerouslyDisableExposureLogging?: boolean
+}
+
+export function useGate(): (gateName: Gate, options?: GateOptions) => boolean {
   const cache = React.useContext(GateCache)
   if (!cache) {
     throw Error('useGate() cannot be called outside StatsigProvider.')
   }
   const gate = React.useCallback(
-    (gateName: Gate): boolean => {
+    (gateName: Gate, options: GateOptions = {}): boolean => {
       const cachedValue = cache.get(gateName)
       if (cachedValue !== undefined) {
         return cachedValue
       }
-      const value = Statsig.initializeCalled()
-        ? Statsig.checkGate(gateName)
-        : false
+      let value = false
+      if (Statsig.initializeCalled()) {
+        if (options.dangerouslyDisableExposureLogging) {
+          value = Statsig.checkGateWithExposureLoggingDisabled(gateName)
+        } else {
+          value = Statsig.checkGate(gateName)
+        }
+      }
       cache.set(gateName, value)
       return value
     },