diff --git a/src/App.native.tsx b/src/App.native.tsx index 5b2071e1..322e944a 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -14,7 +14,11 @@ import * as SplashScreen from 'expo-splash-screen' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {Provider as StatsigProvider} from '#/lib/statsig/statsig' +import { + initialize, + Provider as StatsigProvider, + tryFetchGates, +} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {MessagesProvider} from '#/state/messages' import {init as initPersistedState} from '#/state/persisted' @@ -69,6 +73,9 @@ function InnerApp() { try { if (account) { await resumeSession(account) + } else { + await initialize() + await tryFetchGates(undefined, 'prefer-fresh-gates') } } catch (e) { logger.error(`session: resume failed`, {message: e}) diff --git a/src/lib/statsig/gates.ts b/src/lib/statsig/gates.ts index 4481935f..6e460dc6 100644 --- a/src/lib/statsig/gates.ts +++ b/src/lib/statsig/gates.ts @@ -1,5 +1,6 @@ export type Gate = // Keep this alphabetic please. + | 'native_pwi_disabled' | 'request_notifications_permission_after_onboarding_v2' | 'show_avi_follow_button' | 'show_follow_back_label_v2' diff --git a/src/lib/statsig/statsig.tsx b/src/lib/statsig/statsig.tsx index f6aed999..b5a239c3 100644 --- a/src/lib/statsig/statsig.tsx +++ b/src/lib/statsig/statsig.tsx @@ -14,6 +14,8 @@ import {useNonReactiveCallback} from '../hooks/useNonReactiveCallback' import {LogEvents} from './events' import {Gate} from './gates' +const SDK_KEY = 'client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV' + type StatsigUser = { userID: string | undefined // TODO: Remove when enough users have custom.platform: @@ -251,7 +253,7 @@ AppState.addEventListener('change', (state: AppStateStatus) => { }) export async function tryFetchGates( - did: string, + did: string | undefined, strategy: 'prefer-low-latency' | 'prefer-fresh-gates', ) { try { @@ -275,6 +277,10 @@ export async function tryFetchGates( } } +export function initialize() { + return Statsig.initialize(SDK_KEY, null, createStatsigOptions([])) +} + export function Provider({children}: {children: React.ReactNode}) { const {currentAccount, accounts} = useSession() const did = currentAccount?.did @@ -320,7 +326,7 @@ export function Provider({children}: {children: React.ReactNode}) { } if (hasSession && currentAccount?.signupQueued) {