Move Statsig init call earlier
This commit is contained in:
+1
-6
@@ -17,11 +17,7 @@ import {useLingui} from '@lingui/react'
|
|||||||
|
|
||||||
import {KeyboardControllerProvider} from '#/lib/hooks/useEnableKeyboardController'
|
import {KeyboardControllerProvider} from '#/lib/hooks/useEnableKeyboardController'
|
||||||
import {QueryProvider} from '#/lib/react-query'
|
import {QueryProvider} from '#/lib/react-query'
|
||||||
import {
|
import {Provider as StatsigProvider, tryFetchGates} from '#/lib/statsig/statsig'
|
||||||
initialize,
|
|
||||||
Provider as StatsigProvider,
|
|
||||||
tryFetchGates,
|
|
||||||
} from '#/lib/statsig/statsig'
|
|
||||||
import {s} from '#/lib/styles'
|
import {s} from '#/lib/styles'
|
||||||
import {ThemeProvider} from '#/lib/ThemeContext'
|
import {ThemeProvider} from '#/lib/ThemeContext'
|
||||||
import I18nProvider from '#/locale/i18nProvider'
|
import I18nProvider from '#/locale/i18nProvider'
|
||||||
@@ -101,7 +97,6 @@ function InnerApp() {
|
|||||||
if (account) {
|
if (account) {
|
||||||
await resumeSession(account)
|
await resumeSession(account)
|
||||||
} else {
|
} else {
|
||||||
await initialize()
|
|
||||||
await tryFetchGates(undefined, 'prefer-fresh-gates')
|
await tryFetchGates(undefined, 'prefer-fresh-gates')
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import {Gate} from './gates'
|
|||||||
|
|
||||||
const SDK_KEY = 'client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV'
|
const SDK_KEY = 'client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV'
|
||||||
|
|
||||||
|
export const initPromise = initialize()
|
||||||
|
|
||||||
type StatsigUser = {
|
type StatsigUser = {
|
||||||
userID: string | undefined
|
userID: string | undefined
|
||||||
// TODO: Remove when enough users have custom.platform:
|
// TODO: Remove when enough users have custom.platform:
|
||||||
@@ -219,9 +221,6 @@ export async function tryFetchGates(
|
|||||||
// Use this for less common operations where the user would be OK with a delay.
|
// Use this for less common operations where the user would be OK with a delay.
|
||||||
timeoutMs = 1500
|
timeoutMs = 1500
|
||||||
}
|
}
|
||||||
// Note: This condition is currently false the very first render because
|
|
||||||
// Statsig has not initialized yet. In the future, we can fix this by
|
|
||||||
// doing the initialization ourselves instead of relying on the provider.
|
|
||||||
if (Statsig.initializeCalled()) {
|
if (Statsig.initializeCalled()) {
|
||||||
await Promise.race([
|
await Promise.race([
|
||||||
timeout(timeoutMs),
|
timeout(timeoutMs),
|
||||||
|
|||||||
Reference in New Issue
Block a user