Log additional context for post:* events (#11035)
This commit is contained in:
@@ -14,7 +14,11 @@ import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
|||||||
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||||
import {usePostViewTracking} from '#/lib/hooks/usePostViewTracking'
|
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 {type ThreadViewOption} from '#/state/queries/preferences/useThreadPreferences'
|
||||||
import {
|
import {
|
||||||
PostThreadContextProvider,
|
PostThreadContextProvider,
|
||||||
@@ -56,6 +60,9 @@ import {IS_NATIVE} from '#/env'
|
|||||||
|
|
||||||
const PARENT_CHUNK_SIZE = IS_NATIVE ? 5 : 20
|
const PARENT_CHUNK_SIZE = IS_NATIVE ? 5 : 20
|
||||||
const CHILDREN_CHUNK_SIZE = 50
|
const CHILDREN_CHUNK_SIZE = 50
|
||||||
|
const analyticsOnlyOnItemSeen: FeedFeedbackStateContext['onItemSeen'] = () => {}
|
||||||
|
const analyticsOnlySendInteraction: FeedFeedbackStateContext['sendInteraction'] =
|
||||||
|
() => {}
|
||||||
|
|
||||||
export function PostThread({uri}: {uri: string}) {
|
export function PostThread({uri}: {uri: string}) {
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
@@ -569,6 +576,8 @@ export function PostThread({uri}: {uri: string}) {
|
|||||||
onRetry={thread.actions.refetch}
|
onRetry={thread.actions.refetch}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
<AnalyticsOnlyFeedFeedbackProvider
|
||||||
|
feedDescriptor={feedFeedback.feedDescriptor}>
|
||||||
<List
|
<List
|
||||||
ref={listRef}
|
ref={listRef}
|
||||||
data={deferredSlices}
|
data={deferredSlices}
|
||||||
@@ -631,6 +640,7 @@ export function PostThread({uri}: {uri: string}) {
|
|||||||
*/
|
*/
|
||||||
updateCellsBatchingPeriod={100}
|
updateCellsBatchingPeriod={100}
|
||||||
/>
|
/>
|
||||||
|
</AnalyticsOnlyFeedFeedbackProvider>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!gtMobile && canReply && hasSession && (
|
{!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}) {
|
function MobileComposePrompt({onPressReply}: {onPressReply: () => unknown}) {
|
||||||
const {footerHeight} = useShellLayout()
|
const {footerHeight} = useShellLayout()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user