Fix post view attribution for feed replies (#11622)

This commit is contained in:
DS Boyce
2026-09-01 13:59:31 -07:00
committed by GitHub
parent 35705ff8bf
commit 2ffa02c82a
5 changed files with 15 additions and 3 deletions
+1
View File
@@ -450,6 +450,7 @@ export type Events = {
'post:view': {
uri: string
authorDid: string
isReply: boolean
logContext:
| 'FeedItem'
| 'PostThreadItem'
+1
View File
@@ -24,6 +24,7 @@ export function usePostViewTracking(
ax.metric('post:view', {
uri: post.uri,
authorDid: post.author.did,
isReply: !!post.record.reply,
logContext,
})
},
+1
View File
@@ -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,
})
+1
View File
@@ -508,6 +508,7 @@ let VideoItem = ({
ax.metric('post:view', {
uri: post.uri,
authorDid: post.author.did,
isReply: !!post.record.reply,
logContext: 'ImmersiveVideo',
feedDescriptor,
})
+11 -3
View File
@@ -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,