Poll Statsig for config changes (#3158)
parent
7899a6fd09
commit
aad8c080ed
|
@ -48,6 +48,18 @@ export function Provider({children}: {children: React.ReactNode}) {
|
||||||
() => toStatsigUser(currentAccount?.did),
|
() => toStatsigUser(currentAccount?.did),
|
||||||
[currentAccount?.did],
|
[currentAccount?.did],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
function refresh() {
|
||||||
|
// Intentionally refetching the config using the JS SDK rather than React SDK
|
||||||
|
// so that the new config is stored in cache but isn't used during this session.
|
||||||
|
// It will kick in for the next reload.
|
||||||
|
Statsig.updateUser(currentStatsigUser)
|
||||||
|
}
|
||||||
|
const id = setInterval(refresh, 3 * 60e3 /* 3 min */)
|
||||||
|
return () => clearInterval(id)
|
||||||
|
}, [currentStatsigUser])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StatsigProvider
|
<StatsigProvider
|
||||||
sdkKey="client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV"
|
sdkKey="client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV"
|
||||||
|
|
|
@ -48,6 +48,18 @@ export function Provider({children}: {children: React.ReactNode}) {
|
||||||
() => toStatsigUser(currentAccount?.did),
|
() => toStatsigUser(currentAccount?.did),
|
||||||
[currentAccount?.did],
|
[currentAccount?.did],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
function refresh() {
|
||||||
|
// Intentionally refetching the config using the JS SDK rather than React SDK
|
||||||
|
// so that the new config is stored in cache but isn't used during this session.
|
||||||
|
// It will kick in for the next reload.
|
||||||
|
Statsig.updateUser(currentStatsigUser)
|
||||||
|
}
|
||||||
|
const id = setInterval(refresh, 3 * 60e3 /* 3 min */)
|
||||||
|
return () => clearInterval(id)
|
||||||
|
}, [currentStatsigUser])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StatsigProvider
|
<StatsigProvider
|
||||||
sdkKey="client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV"
|
sdkKey="client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV"
|
||||||
|
|
Loading…
Reference in New Issue