Get trending section indices from GrowthBook (#11319)

This commit is contained in:
DS Boyce
2026-07-29 10:24:50 -07:00
committed by GitHub
parent a35c4ac4ba
commit 196e81eb0c
3 changed files with 20 additions and 8 deletions
+3
View File
@@ -23,5 +23,8 @@ export enum Features {
SearchStarterPacksV2Enable = 'search_starter_packs_v2:enable', SearchStarterPacksV2Enable = 'search_starter_packs_v2:enable',
FollowSortEnable = 'follow_sort:enable', FollowSortEnable = 'follow_sort:enable',
// values
TrendingDiscoverValues = 'trending_discover:values',
AATest = 'aa-test', AATest = 'aa-test',
} }
+4 -1
View File
@@ -6,7 +6,7 @@ import {
useSyncExternalStore, useSyncExternalStore,
} from 'react' } from 'react'
import {Platform} from 'react-native' import {Platform} from 'react-native'
import {type Result} from '@growthbook/growthbook-react' import {type Result, type WidenPrimitives} from '@growthbook/growthbook-react'
import {Logger} from '#/logger' import {Logger} from '#/logger'
import { import {
@@ -67,6 +67,7 @@ export type AnalyticsContextType = {
) => void ) => void
features: typeof Features & { features: typeof Features & {
enabled(feature: Features): boolean enabled(feature: Features): boolean
getValue<T>(feature: Features, defaultValue: T): WidenPrimitives<T>
} }
} }
export type AnalyticsBaseContextType = Omit<AnalyticsContextType, 'features'> export type AnalyticsBaseContextType = Omit<AnalyticsContextType, 'features'>
@@ -83,6 +84,7 @@ function createLogger(
warn: logger.warn.bind(logger), warn: logger.warn.bind(logger),
error: logger.error.bind(logger), error: logger.error.bind(logger),
useChild: (context: Exclude<Logger['context'], undefined>) => { useChild: (context: Exclude<Logger['context'], undefined>) => {
// oxlint-disable-next-line react-hooks/exhaustive-deps
return useMemo(() => createLogger(context, metadata), [context, metadata]) return useMemo(() => createLogger(context, metadata), [context, metadata])
}, },
Context: Logger.Context, Context: Logger.Context,
@@ -314,6 +316,7 @@ export function AnalyticsFeaturesContext({
...parentContext, ...parentContext,
features: { features: {
enabled: feats.isOn.bind(feats), enabled: feats.isOn.bind(feats),
getValue: feats.getFeatureValue.bind(feats),
...Features, ...Features,
}, },
} }
+13 -7
View File
@@ -211,10 +211,6 @@ export type PostFeedRef = {
// const REFRESH_AFTER = STALE.HOURS.ONE // const REFRESH_AFTER = STALE.HOURS.ONE
const CHECK_LATEST_AFTER = STALE.SECONDS.THIRTY const CHECK_LATEST_AFTER = STALE.SECONDS.THIRTY
const TRENDING_TOPICS_INDEX = 5
const TRENDING_VIDEO_INDEX = 30
const SUGGESTED_FOR_YOU_INDEX = 15
let PostFeed = ({ let PostFeed = ({
feed, feed,
description, description,
@@ -280,6 +276,15 @@ let PostFeed = ({
const {rightNavVisible} = useLayoutBreakpoints() const {rightNavVisible} = useLayoutBreakpoints()
const areVideoFeedsEnabled = IS_NATIVE const areVideoFeedsEnabled = IS_NATIVE
const trendingIndices = ax.features.getValue(
ax.features.TrendingDiscoverValues,
{
topics: 5,
accounts: 15,
videos: 30,
},
)
const [hasPressedShowLessUris, setHasPressedShowLessUris] = useState( const [hasPressedShowLessUris, setHasPressedShowLessUris] = useState(
() => new Set<string>(), () => new Set<string>(),
) )
@@ -574,19 +579,19 @@ let PostFeed = ({
key: 'composerPrompt-' + sliceIndex, key: 'composerPrompt-' + sliceIndex,
}) })
} }
} else if (sliceIndex === TRENDING_TOPICS_INDEX) { } else if (sliceIndex === trendingIndices.topics) {
arr.push({ arr.push({
type: 'interstitialFeedTrendingTopics', type: 'interstitialFeedTrendingTopics',
key: 'interstitialFeedTrendingTopics-' + sliceIndex, key: 'interstitialFeedTrendingTopics-' + sliceIndex,
}) })
} else if (sliceIndex === TRENDING_VIDEO_INDEX) { } else if (sliceIndex === trendingIndices.videos) {
if (areVideoFeedsEnabled && !trendingVideoDisabled) { if (areVideoFeedsEnabled && !trendingVideoDisabled) {
arr.push({ arr.push({
type: 'interstitialTrendingVideos', type: 'interstitialTrendingVideos',
key: 'interstitial-' + sliceIndex + '-' + lastFetchedAt, key: 'interstitial-' + sliceIndex + '-' + lastFetchedAt,
}) })
} }
} else if (sliceIndex === SUGGESTED_FOR_YOU_INDEX) { } else if (sliceIndex === trendingIndices.accounts) {
arr.push({ arr.push({
type: 'interstitialFollows', type: 'interstitialFollows',
key: 'interstitial-' + sliceIndex + '-' + lastFetchedAt, key: 'interstitial-' + sliceIndex + '-' + lastFetchedAt,
@@ -739,6 +744,7 @@ let PostFeed = ({
ageAssuranceBannerState, ageAssuranceBannerState,
isCurrentFeedAtStartupSelected, isCurrentFeedAtStartupSelected,
blockedOrMutedAuthors, blockedOrMutedAuthors,
trendingIndices,
]) ])
// events // events