Revert "Send beta user state with AppView requests (#11474)" (#11510)

This commit is contained in:
DS Boyce
2026-08-24 11:40:15 -07:00
committed by GitHub
parent 6f46927c28
commit 6b35d3de1c
7 changed files with 22 additions and 159 deletions
+8 -8
View File
@@ -9,10 +9,6 @@ import {Platform} from 'react-native'
import {type Result, type WidenPrimitives} from '@growthbook/growthbook-react'
import {Logger} from '#/logger'
import {
getCachedIsBetaUser,
subscribeToCachedIsBetaUser,
} from '#/state/preferences/beta-user-cache'
import {
Features,
features as feats,
@@ -37,7 +33,7 @@ import {type Metrics, metrics} from '#/analytics/metrics'
import * as refParams from '#/analytics/misc/refParams'
import * as env from '#/env'
import {useGeolocationServiceResponse} from '#/geolocation/service'
import {device} from '#/storage'
import {account, device} from '#/storage'
export * as utils from '#/analytics/utils'
export const features = {init, refresh}
@@ -135,7 +131,7 @@ export const setupDeviceId = getAndMigrateDeviceId()
/**
* Reads the per-account cached `isBetaUser` flag for `did`, kept in sync with
* PDS preference query results and the beta settings toggle.
* writes from `BetaUserStorageSync` and the beta settings toggle.
*
* This deliberately does not use `useStorage`, whose `useState` seeds once and
* only updates via the change listener. The consuming `AnalyticsContext` lives
@@ -150,13 +146,17 @@ function useAccountIsBetaUser(did: string | undefined): boolean | undefined {
const subscribe = useCallback(
(onChange: () => void) => {
if (!did) return () => {}
return subscribeToCachedIsBetaUser(did, onChange)
const sub = account.addOnValueChangedListener(
[did, 'isBetaUser'],
onChange,
)
return () => sub.remove()
},
[did],
)
const getSnapshot = useCallback(() => {
if (!did) return undefined
return getCachedIsBetaUser(did)
return account.get([did, 'isBetaUser'])
}, [did])
return useSyncExternalStore(subscribe, getSnapshot)
}