[Statsig] Track feed refresh (#3283)
parent
54f424d047
commit
b6c9d34e45
|
@ -9,6 +9,10 @@ export type LogEvents = {
|
||||||
feedType: string
|
feedType: string
|
||||||
itemCount: number
|
itemCount: number
|
||||||
}
|
}
|
||||||
|
'feed:refresh': {
|
||||||
|
feedType: string
|
||||||
|
reason: 'pull-to-refresh' | 'soft-reset' | 'load-latest'
|
||||||
|
}
|
||||||
'post:create': {
|
'post:create': {
|
||||||
imageCount: number
|
imageCount: number
|
||||||
isReply: boolean
|
isReply: boolean
|
||||||
|
|
|
@ -22,6 +22,7 @@ import {listenSoftReset} from '#/state/events'
|
||||||
import {truncateAndInvalidate} from '#/state/queries/util'
|
import {truncateAndInvalidate} from '#/state/queries/util'
|
||||||
import {TabState, getTabState, getRootNavigation} from '#/lib/routes/helpers'
|
import {TabState, getTabState, getRootNavigation} from '#/lib/routes/helpers'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
|
|
||||||
const POLL_FREQ = 60e3 // 60sec
|
const POLL_FREQ = 60e3 // 60sec
|
||||||
|
|
||||||
|
@ -68,6 +69,10 @@ export function FeedPage({
|
||||||
scrollToTop()
|
scrollToTop()
|
||||||
truncateAndInvalidate(queryClient, FEED_RQKEY(feed))
|
truncateAndInvalidate(queryClient, FEED_RQKEY(feed))
|
||||||
setHasNew(false)
|
setHasNew(false)
|
||||||
|
logEvent('feed:refresh', {
|
||||||
|
feedType: feed.split('|')[0],
|
||||||
|
reason: 'soft-reset',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}, [navigation, isPageFocused, scrollToTop, queryClient, feed, setHasNew])
|
}, [navigation, isPageFocused, scrollToTop, queryClient, feed, setHasNew])
|
||||||
|
|
||||||
|
@ -89,6 +94,10 @@ export function FeedPage({
|
||||||
scrollToTop()
|
scrollToTop()
|
||||||
truncateAndInvalidate(queryClient, FEED_RQKEY(feed))
|
truncateAndInvalidate(queryClient, FEED_RQKEY(feed))
|
||||||
setHasNew(false)
|
setHasNew(false)
|
||||||
|
logEvent('feed:refresh', {
|
||||||
|
feedType: feed.split('|')[0],
|
||||||
|
reason: 'load-latest',
|
||||||
|
})
|
||||||
}, [scrollToTop, feed, queryClient, setHasNew])
|
}, [scrollToTop, feed, queryClient, setHasNew])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -90,6 +90,7 @@ let Feed = ({
|
||||||
const [isPTRing, setIsPTRing] = React.useState(false)
|
const [isPTRing, setIsPTRing] = React.useState(false)
|
||||||
const checkForNewRef = React.useRef<(() => void) | null>(null)
|
const checkForNewRef = React.useRef<(() => void) | null>(null)
|
||||||
const lastFetchRef = React.useRef<number>(Date.now())
|
const lastFetchRef = React.useRef<number>(Date.now())
|
||||||
|
const feedType = feed.split('|')[0]
|
||||||
|
|
||||||
const opts = React.useMemo(
|
const opts = React.useMemo(
|
||||||
() => ({enabled, ignoreFilterFor}),
|
() => ({enabled, ignoreFilterFor}),
|
||||||
|
@ -214,6 +215,10 @@ let Feed = ({
|
||||||
|
|
||||||
const onRefresh = React.useCallback(async () => {
|
const onRefresh = React.useCallback(async () => {
|
||||||
track('Feed:onRefresh')
|
track('Feed:onRefresh')
|
||||||
|
logEvent('feed:refresh', {
|
||||||
|
feedType: feedType,
|
||||||
|
reason: 'pull-to-refresh',
|
||||||
|
})
|
||||||
setIsPTRing(true)
|
setIsPTRing(true)
|
||||||
try {
|
try {
|
||||||
await refetch()
|
await refetch()
|
||||||
|
@ -222,9 +227,8 @@ let Feed = ({
|
||||||
logger.error('Failed to refresh posts feed', {message: err})
|
logger.error('Failed to refresh posts feed', {message: err})
|
||||||
}
|
}
|
||||||
setIsPTRing(false)
|
setIsPTRing(false)
|
||||||
}, [refetch, track, setIsPTRing, onHasNew])
|
}, [refetch, track, setIsPTRing, onHasNew, feedType])
|
||||||
|
|
||||||
const feedType = feed.split('|')[0]
|
|
||||||
const onEndReached = React.useCallback(async () => {
|
const onEndReached = React.useCallback(async () => {
|
||||||
if (isFetching || !hasNextPage || isError) return
|
if (isFetching || !hasNextPage || isError) return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue