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': { 'post:view': {
uri: string uri: string
authorDid: string authorDid: string
isReply: boolean
logContext: logContext:
| 'FeedItem' | 'FeedItem'
| 'PostThreadItem' | 'PostThreadItem'
+1
View File
@@ -24,6 +24,7 @@ export function usePostViewTracking(
ax.metric('post:view', { ax.metric('post:view', {
uri: post.uri, uri: post.uri,
authorDid: post.author.did, authorDid: post.author.did,
isReply: !!post.record.reply,
logContext, logContext,
}) })
}, },
+1
View File
@@ -104,6 +104,7 @@ export function PostThread({uri}: {uri: string}) {
ax.metric('post:view', { ax.metric('post:view', {
uri: post.uri, uri: post.uri,
authorDid: post.author.did, authorDid: post.author.did,
isReply: !!post.record.reply,
logContext: 'Post', logContext: 'Post',
feedDescriptor: feedFeedback.feedDescriptor, feedDescriptor: feedFeedback.feedDescriptor,
}) })
+1
View File
@@ -508,6 +508,7 @@ let VideoItem = ({
ax.metric('post:view', { ax.metric('post:view', {
uri: post.uri, uri: post.uri,
authorDid: post.author.did, authorDid: post.author.did,
isReply: !!post.record.reply,
logContext: 'ImmersiveVideo', logContext: 'ImmersiveVideo',
feedDescriptor, feedDescriptor,
}) })
+11 -3
View File
@@ -1077,15 +1077,22 @@ let PostFeed = ({
onPostSeen(post) onPostSeen(post)
// Only track the root post of each slice (index 0) to avoid double-counting thread items // Track the post selected by the feed once it is actually visible.
if (indexInSlice === 0 && !seenPostUrisRef.current.has(post.uri)) { if (
post.uri === slice.feedPostUri &&
!seenPostUrisRef.current.has(post.uri)
) {
seenPostUrisRef.current.add(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', { ax.metric('post:view', {
uri: post.uri, uri: post.uri,
authorDid: post.author.did, authorDid: post.author.did,
isReply: !!postItem.record.reply,
logContext: 'FeedItem', logContext: 'FeedItem',
feedDescriptor: feedFeedback.feedDescriptor || feed, feedDescriptor: feedFeedback.feedDescriptor || feed,
position, position,
@@ -1121,6 +1128,7 @@ let PostFeed = ({
ax.metric('post:view', { ax.metric('post:view', {
uri: post.uri, uri: post.uri,
authorDid: post.author.did, authorDid: post.author.did,
isReply: !!postItem.record.reply,
logContext: 'FeedItem', logContext: 'FeedItem',
feedDescriptor: feedFeedback.feedDescriptor || feed, feedDescriptor: feedFeedback.feedDescriptor || feed,
position, position,