Hook up suggestedUser:seen client events (#9468)
* Hook up suggestedUser:seen client events * Fix crash when clicking "find people to follow" * While we're at it, fix the position of the X button on the "find people to follow" modal * Add suggestedDid and category attributes to suggestedUser client events --------- Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -1030,26 +1030,48 @@ export function Explore({
|
||||
|
||||
// track headers and report module viewability
|
||||
const alreadyReportedRef = useRef<Map<string, string>>(new Map())
|
||||
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}, {statsig: false})
|
||||
}
|
||||
}, [])
|
||||
const seenProfilesRef = useRef<Set<string>>(new Set())
|
||||
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'
|
||||
// Track individual profile seen events
|
||||
if (!seenProfilesRef.current.has(item.profile.did)) {
|
||||
seenProfilesRef.current.add(item.profile.did)
|
||||
const position = suggestedFollowsModule.findIndex(
|
||||
i => i.type === 'profile' && i.profile.did === item.profile.did,
|
||||
)
|
||||
logger.metric(
|
||||
'suggestedUser:seen',
|
||||
{
|
||||
logContext: 'Explore',
|
||||
recId: item.recId,
|
||||
position: position !== -1 ? position - 1 : 0, // -1 to account for header
|
||||
suggestedDid: item.profile.did,
|
||||
category: null,
|
||||
},
|
||||
{statsig: true},
|
||||
)
|
||||
}
|
||||
} 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}, {statsig: false})
|
||||
}
|
||||
},
|
||||
[suggestedFollowsModule],
|
||||
)
|
||||
|
||||
return (
|
||||
<List
|
||||
|
||||
@@ -123,6 +123,8 @@ let SuggestedProfileCard = ({
|
||||
logContext: 'Explore',
|
||||
recId,
|
||||
position,
|
||||
suggestedDid: profile.did,
|
||||
category: null,
|
||||
},
|
||||
{statsig: true},
|
||||
)
|
||||
@@ -162,6 +164,8 @@ let SuggestedProfileCard = ({
|
||||
location: 'Card',
|
||||
recId,
|
||||
position,
|
||||
suggestedDid: profile.did,
|
||||
category: null,
|
||||
},
|
||||
{statsig: true},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user