···88import {isWeb} from '#/platform/detection'
99import {IS_TESTFLIGHT} from 'lib/app-info'
1010import {useSession} from '../../state/session'
1111+import {timeout} from '../async/timeout'
1112import {useNonReactiveCallback} from '../hooks/useNonReactiveCallback'
1213import {LogEvents} from './events'
1314import {Gate} from './gates'
···163164 })
164165 }
165166})
167167+168168+export async function tryFetchGates(
169169+ did: string,
170170+ strategy: 'prefer-low-latency' | 'prefer-fresh-gates',
171171+) {
172172+ try {
173173+ let timeoutMs = 250 // Don't block the UI if we can't do this fast.
174174+ if (strategy === 'prefer-fresh-gates') {
175175+ // Use this for less common operations where the user would be OK with a delay.
176176+ timeoutMs = 1500
177177+ }
178178+ // Note: This condition is currently false the very first render because
179179+ // Statsig has not initialized yet. In the future, we can fix this by
180180+ // doing the initialization ourselves instead of relying on the provider.
181181+ if (Statsig.initializeCalled()) {
182182+ await Promise.race([
183183+ timeout(timeoutMs),
184184+ Statsig.prefetchUsers([toStatsigUser(did)]),
185185+ ])
186186+ }
187187+ } catch (e) {
188188+ // Don't leak errors to the calling code, this is meant to be always safe.
189189+ console.error(e)
190190+ }
191191+}
166192167193export function Provider({children}: {children: React.ReactNode}) {
168194 const {currentAccount, accounts} = useSession()