Update statsig API

This commit is contained in:
Eric Bailey
2024-04-18 10:03:22 -05:00
parent 9075b123d5
commit bb53548541
5 changed files with 31 additions and 23 deletions
+2 -1
View File
@@ -244,7 +244,8 @@ const pinnedFeedInfosQueryKeyRoot = 'pinnedFeedsInfos'
export function usePinnedFeedsInfos() {
const {hasSession} = useSession()
const {data: preferences, isLoading: isLoadingPrefs} = usePreferencesQuery()
const isPrimaryAlgoExperimentEnabled = useGate(
const gate = useGate()
const isPrimaryAlgoExperimentEnabled = gate(
'reduced_onboarding_and_home_algo',
)
const primaryAlgo = preferences?.primaryAlgorithm
+20 -8
View File
@@ -12,28 +12,40 @@ const stateContext = React.createContext<StateContext>('home')
const setContext = React.createContext<SetContext>((_: string) => {})
function getInitialFeed(gate: (gateName: Gate) => boolean) {
const isPrimaryAlgoExperimentEnabled = gate(
'reduced_onboarding_and_home_algo',
)
let feed = isPrimaryAlgoExperimentEnabled ? 'primary-algo' : 'home'
if (isWeb) {
if (window.location.pathname === '/') {
const params = new URLSearchParams(window.location.search)
const feedFromUrl = params.get('feed')
if (feedFromUrl) {
// If explicitly booted from a link like /?feed=..., prefer that.
// basically a link to a specific tab, use that every time if present
return feedFromUrl
}
}
const feedFromSession = sessionStorage.getItem('lastSelectedHomeFeed')
if (feedFromSession) {
// Fall back to a previously chosen feed for this browser tab.
return feedFromSession
feed = feedFromSession
}
}
if (!gate('start_session_with_following')) {
const feedFromPersisted = persisted.get('lastSelectedHomeFeed')
if (feedFromPersisted) {
// Fall back to the last chosen one across all tabs.
return feedFromPersisted
}
const feedFromPersisted = persisted.get('lastSelectedHomeFeed')
if (feedFromPersisted) {
// Fall back to the last chosen one across all tabs.
feed = feedFromPersisted
}
if (isPrimaryAlgoExperimentEnabled) {
if (feed === 'home') {
return 'home'
}
return 'primary-algo'
}
return 'home'
}
+2 -4
View File
@@ -93,9 +93,7 @@ export function FeedSourceCardLoaded({
const {_} = useLingui()
const removePromptControl = Prompt.usePromptControl()
const navigation = useNavigationDeduped()
const isPrimaryAlgoExperimentEnabled = useGate(
'reduced_onboarding_and_home_algo',
)
const gate = useGate()
const primaryAlgoDialogControl = Prompt.usePromptControl()
const {isPending: isSavePending, mutateAsync: saveFeed} =
@@ -239,7 +237,7 @@ export function FeedSourceCardLoaded({
</View>
{showFeedSaveButton &&
(isPrimaryAlgoExperimentEnabled && isPrimaryAlgo ? (
(gate('reduced_onboarding_and_home_algo') && isPrimaryAlgo ? (
<Button
variant="solid"
color="secondary"
+5 -9
View File
@@ -54,9 +54,7 @@ function HomeScreenReady({
pinnedFeedInfos: FeedSourceInfo[]
}) {
useOTAUpdates()
const isPrimaryAlgoExperimentEnabled = useGate(
'reduced_onboarding_and_home_algo',
)
const gate = useGate()
const allFeeds = React.useMemo(() => {
const feeds: FeedDescriptor[] = []
@@ -66,6 +64,9 @@ function HomeScreenReady({
} else if (uri.includes('app.bsky.graph.list')) {
feeds.push(`list|${uri}`)
} else if (uri === 'primary-algo') {
const isPrimaryAlgoExperimentEnabled = gate(
'reduced_onboarding_and_home_algo',
)
if (
isPrimaryAlgoExperimentEnabled &&
preferences.primaryAlgorithm.enabled &&
@@ -87,11 +88,7 @@ function HomeScreenReady({
}
}
return feeds
}, [
pinnedFeedInfos,
isPrimaryAlgoExperimentEnabled,
preferences.primaryAlgorithm,
])
}, [pinnedFeedInfos, gate, preferences.primaryAlgorithm])
const rawSelectedFeed = useSelectedFeed()
const setSelectedFeed = useSetSelectedFeed()
@@ -137,7 +134,6 @@ function HomeScreenReady({
}),
)
const gate = useGate()
React.useEffect(() => {
const listener = AppState.addEventListener('change', nextAppState => {
if (nextAppState === 'active') {
+2 -1
View File
@@ -168,7 +168,8 @@ export function ProfileFeedScreenInner({
const playHaptic = useHaptics()
const feedSectionRef = React.useRef<SectionRef>(null)
const isScreenFocused = useIsFocused()
const isPrimaryAlgoExperimentEnabled = useGate(
const gate = useGate()
const isPrimaryAlgoExperimentEnabled = gate(
'reduced_onboarding_and_home_algo',
)
const primaryAlgoDialogControl = useDialogControl()