From 2ffa02c82ac5b0e09efe17e2f1e70dc8f24b229c Mon Sep 17 00:00:00 2001 From: DS Boyce <260543580+ds-boyce@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:59:31 -0700 Subject: [PATCH] Fix post view attribution for feed replies (#11622) --- src/analytics/metrics/types.ts | 1 + src/lib/hooks/usePostViewTracking.ts | 1 + src/screens/PostThread/index.tsx | 1 + src/screens/VideoFeed/index.tsx | 1 + src/view/com/posts/PostFeed.tsx | 14 +++++++++++--- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/analytics/metrics/types.ts b/src/analytics/metrics/types.ts index 78a4574f0f..f909767156 100644 --- a/src/analytics/metrics/types.ts +++ b/src/analytics/metrics/types.ts @@ -450,6 +450,7 @@ export type Events = { 'post:view': { uri: string authorDid: string + isReply: boolean logContext: | 'FeedItem' | 'PostThreadItem' diff --git a/src/lib/hooks/usePostViewTracking.ts b/src/lib/hooks/usePostViewTracking.ts index 28fe8ba448..3c10f5bfd9 100644 --- a/src/lib/hooks/usePostViewTracking.ts +++ b/src/lib/hooks/usePostViewTracking.ts @@ -24,6 +24,7 @@ export function usePostViewTracking( ax.metric('post:view', { uri: post.uri, authorDid: post.author.did, + isReply: !!post.record.reply, logContext, }) }, diff --git a/src/screens/PostThread/index.tsx b/src/screens/PostThread/index.tsx index d68a7280d8..23c9a82c02 100644 --- a/src/screens/PostThread/index.tsx +++ b/src/screens/PostThread/index.tsx @@ -104,6 +104,7 @@ export function PostThread({uri}: {uri: string}) { ax.metric('post:view', { uri: post.uri, authorDid: post.author.did, + isReply: !!post.record.reply, logContext: 'Post', feedDescriptor: feedFeedback.feedDescriptor, }) diff --git a/src/screens/VideoFeed/index.tsx b/src/screens/VideoFeed/index.tsx index 63cf084eb8..cb43845b3a 100644 --- a/src/screens/VideoFeed/index.tsx +++ b/src/screens/VideoFeed/index.tsx @@ -508,6 +508,7 @@ let VideoItem = ({ ax.metric('post:view', { uri: post.uri, authorDid: post.author.did, + isReply: !!post.record.reply, logContext: 'ImmersiveVideo', feedDescriptor, }) diff --git a/src/view/com/posts/PostFeed.tsx b/src/view/com/posts/PostFeed.tsx index 85eb1fb627..5806548342 100644 --- a/src/view/com/posts/PostFeed.tsx +++ b/src/view/com/posts/PostFeed.tsx @@ -1077,15 +1077,22 @@ let PostFeed = ({ onPostSeen(post) - // Only track the root post of each slice (index 0) to avoid double-counting thread items - if (indexInSlice === 0 && !seenPostUrisRef.current.has(post.uri)) { + // Track the post selected by the feed once it is actually visible. + if ( + post.uri === slice.feedPostUri && + !seenPostUrisRef.current.has(post.uri) + ) { seenPostUrisRef.current.add(post.uri) - const position = getPostPosition('sliceItem', item.key) + const position = getPostPosition( + 'sliceItem', + slice.items[0]._reactKey, + ) ax.metric('post:view', { uri: post.uri, authorDid: post.author.did, + isReply: !!postItem.record.reply, logContext: 'FeedItem', feedDescriptor: feedFeedback.feedDescriptor || feed, position, @@ -1121,6 +1128,7 @@ let PostFeed = ({ ax.metric('post:view', { uri: post.uri, authorDid: post.author.did, + isReply: !!postItem.record.reply, logContext: 'FeedItem', feedDescriptor: feedFeedback.feedDescriptor || feed, position,