From a301e31f76c2b39adf92dd0301e80b51b4c00814 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Fri, 4 Apr 2025 17:28:02 -0700 Subject: Fix the 'seen' metric in explore (#8134) --- src/screens/Search/Explore.tsx | 54 ++++++++++++----------------- src/state/queries/explore-feed-previews.tsx | 5 +++ 2 files changed, 27 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/screens/Search/Explore.tsx b/src/screens/Search/Explore.tsx index a6d6b1703..79e27ec9a 100644 --- a/src/screens/Search/Explore.tsx +++ b/src/screens/Search/Explore.tsx @@ -1,5 +1,5 @@ import {useCallback, useMemo, useRef, useState} from 'react' -import {View, type ViewabilityConfig, type ViewToken} from 'react-native' +import {View, type ViewabilityConfig} from 'react-native' import { type AppBskyActorDefs, type AppBskyFeedDefs, @@ -837,36 +837,26 @@ export function Explore({ // track headers and report module viewability const alreadyReportedRef = useRef>(new Map()) - const onViewableItemsChanged = useCallback( - ({ - viewableItems, - }: { - viewableItems: ViewToken[] - changed: ViewToken[] - }) => { - for (const {item, index} of viewableItems.filter(vi => vi.isViewable)) { - let module: MetricEvents['explore:module:seen']['module'] - if (item.type === 'trendingTopics' || item.type === 'trendingVideos') { - module = item.type - } else if (item.type === 'profile') { - module = 'suggestedAccounts' - } else if (item.type === 'feed') { - module = 'suggestedFeeds' - } else if (item.type === 'starterPack') { - module = 'suggestedStarterPacks' - } else if (item.type === 'preview:header') { - module = `feed:feedgen|${item.feed.uri}` - } else { - continue - } - if (!alreadyReportedRef.current.has(module)) { - alreadyReportedRef.current.set(module, module) - logger.metric('explore:module:seen', {module, index: index ?? -1}) - } - } - }, - [], - ) + const onItemSeen = useCallback((item: ExploreScreenItems) => { + let module: MetricEvents['explore:module:seen']['module'] + if (item.type === 'trendingTopics' || item.type === 'trendingVideos') { + module = item.type + } else if (item.type === 'profile') { + module = 'suggestedAccounts' + } else if (item.type === 'feed') { + module = 'suggestedFeeds' + } else if (item.type === 'starterPack') { + module = 'suggestedStarterPacks' + } else if (item.type === 'preview:sliceItem') { + module = `feed:feedgen|${item.feed.uri}` + } else { + return + } + if (!alreadyReportedRef.current.has(module)) { + alreadyReportedRef.current.set(module, module) + logger.metric('explore:module:seen', {module}) //, index: index ?? -1}) + } + }, []) return (