Log additional context for post:* events (#11035)

This commit is contained in:
DS Boyce
2026-07-15 12:52:53 -07:00
committed by GitHub
parent a0c75944a3
commit 48fecae677
+41 -1
View File
@@ -14,7 +14,11 @@ import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
import {usePostViewTracking} from '#/lib/hooks/usePostViewTracking'
import {useFeedFeedback} from '#/state/feed-feedback'
import {
FeedFeedbackProvider,
type StateContext as FeedFeedbackStateContext,
useFeedFeedback,
} from '#/state/feed-feedback'
import {type ThreadViewOption} from '#/state/queries/preferences/useThreadPreferences'
import {
PostThreadContextProvider,
@@ -56,6 +60,9 @@ import {IS_NATIVE} from '#/env'
const PARENT_CHUNK_SIZE = IS_NATIVE ? 5 : 20
const CHILDREN_CHUNK_SIZE = 50
const analyticsOnlyOnItemSeen: FeedFeedbackStateContext['onItemSeen'] = () => {}
const analyticsOnlySendInteraction: FeedFeedbackStateContext['sendInteraction'] =
() => {}
export function PostThread({uri}: {uri: string}) {
const ax = useAnalytics()
@@ -569,6 +576,8 @@ export function PostThread({uri}: {uri: string}) {
onRetry={thread.actions.refetch}
/>
) : (
<AnalyticsOnlyFeedFeedbackProvider
feedDescriptor={feedFeedback.feedDescriptor}>
<List
ref={listRef}
data={deferredSlices}
@@ -631,6 +640,7 @@ export function PostThread({uri}: {uri: string}) {
*/
updateCellsBatchingPeriod={100}
/>
</AnalyticsOnlyFeedFeedbackProvider>
)}
{!gtMobile && canReply && hasSession && (
@@ -640,6 +650,36 @@ export function PostThread({uri}: {uri: string}) {
)
}
function AnalyticsOnlyFeedFeedbackProvider({
children,
feedDescriptor,
}: React.PropsWithChildren<{
feedDescriptor: FeedFeedbackStateContext['feedDescriptor']
}>) {
/*
* Non-anchor posts (parents and replies) are not the post the user tapped
* from a feed, so they should not report feed interactions. But they should
* still carry the originating feedDescriptor for analytics, so events like
* post:clickQuotePost can be attributed to the feed the thread was opened
* from. This inert context value provides feedDescriptor while keeping
* interaction reporting disabled (enabled: false makes sendInteraction and
* onItemSeen no-ops). The anchor renders its own full provider that nests
* inside and overrides this for its subtree.
*/
const value = useMemo<FeedFeedbackStateContext>(
() => ({
enabled: false,
onItemSeen: analyticsOnlyOnItemSeen,
sendInteraction: analyticsOnlySendInteraction,
feedDescriptor,
feedSourceInfo: undefined,
}),
[feedDescriptor],
)
return <FeedFeedbackProvider value={value}>{children}</FeedFeedbackProvider>
}
function MobileComposePrompt({onPressReply}: {onPressReply: () => unknown}) {
const {footerHeight} = useShellLayout()