Add metrics
This commit is contained in:
@@ -5,6 +5,7 @@ import {useLingui} from '@lingui/react'
|
||||
import type React from 'react'
|
||||
|
||||
import {useCleanError} from '#/lib/hooks/useCleanError'
|
||||
import {logger} from '#/logger'
|
||||
import {type Shadow} from '#/state/cache/post-shadow'
|
||||
import {useBookmarkMutation} from '#/state/queries/bookmarks/useBookmarkMutation'
|
||||
import {useTheme} from '#/alf'
|
||||
@@ -16,9 +17,11 @@ import {PostControlButton, PostControlButtonIcon} from './PostControlButton'
|
||||
export const BookmarkButton = memo(function BookmarkButton({
|
||||
post,
|
||||
big,
|
||||
logContext,
|
||||
}: {
|
||||
post: Shadow<AppBskyFeedDefs.PostView>
|
||||
big?: boolean
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||
}): React.ReactNode {
|
||||
const t = useTheme()
|
||||
const {_} = useLingui()
|
||||
@@ -42,6 +45,8 @@ export const BookmarkButton = memo(function BookmarkButton({
|
||||
post,
|
||||
})
|
||||
|
||||
logger.metric('post:bookmark', {logContext})
|
||||
|
||||
toast.show(
|
||||
<toast.Outer>
|
||||
<toast.Icon />
|
||||
@@ -75,6 +80,8 @@ export const BookmarkButton = memo(function BookmarkButton({
|
||||
uri: post.uri,
|
||||
})
|
||||
|
||||
logger.metric('post:unbookmark', {logContext})
|
||||
|
||||
toast.show(
|
||||
<toast.Outer>
|
||||
<toast.Icon icon={TrashIcon} />
|
||||
|
||||
@@ -290,7 +290,7 @@ let PostControls = ({
|
||||
<View />
|
||||
</View>
|
||||
<View style={[a.flex_row, a.justify_end, (big || gtPhone) && a.gap_sm]}>
|
||||
<BookmarkButton post={post} big={big} />
|
||||
<BookmarkButton post={post} big={big} logContext={logContext} />
|
||||
<ShareMenuButton
|
||||
testID="postShareBtn"
|
||||
post={post}
|
||||
|
||||
@@ -238,6 +238,14 @@ export type MetricEvents = {
|
||||
'post:unmute': {}
|
||||
'post:pin': {}
|
||||
'post:unpin': {}
|
||||
'post:bookmark': {
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||
}
|
||||
'post:unbookmark': {
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||
}
|
||||
'bookmarks:view': {}
|
||||
'bookmarks:post-clicked': {}
|
||||
'profile:follow': {
|
||||
didBecomeMutual: boolean | undefined
|
||||
followeeClout: number | undefined
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
type CommonNavigatorParams,
|
||||
type NativeStackScreenProps,
|
||||
} from '#/lib/routes/types'
|
||||
import {logger} from '#/logger'
|
||||
import {isIOS} from '#/platform/detection'
|
||||
import {useBookmarkMutation} from '#/state/queries/bookmarks/useBookmarkMutation'
|
||||
import {useBookmarksQuery} from '#/state/queries/bookmarks/useBookmarksQuery'
|
||||
@@ -41,6 +42,7 @@ export function BookmarksScreen({}: Props) {
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
setMinimalShellMode(false)
|
||||
logger.metric('bookmarks:view', {})
|
||||
}, [setMinimalShellMode]),
|
||||
)
|
||||
|
||||
@@ -268,7 +270,15 @@ function renderItem({item, index}: {item: ListItem; index: number}) {
|
||||
return <EmptyState />
|
||||
}
|
||||
case 'bookmark': {
|
||||
return <Post post={item.bookmark.item} hideTopBorder={index === 0} />
|
||||
return (
|
||||
<Post
|
||||
post={item.bookmark.item}
|
||||
hideTopBorder={index === 0}
|
||||
onBeforePress={() => {
|
||||
logger.metric('bookmarks:post-clicked', {})
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
case 'bookmarkNotFound': {
|
||||
return (
|
||||
|
||||
@@ -43,11 +43,13 @@ export function Post({
|
||||
showReplyLine,
|
||||
hideTopBorder,
|
||||
style,
|
||||
onBeforePress,
|
||||
}: {
|
||||
post: AppBskyFeedDefs.PostView
|
||||
showReplyLine?: boolean
|
||||
hideTopBorder?: boolean
|
||||
style?: StyleProp<ViewStyle>
|
||||
onBeforePress?: () => void
|
||||
}) {
|
||||
const moderationOpts = useModerationOpts()
|
||||
const record = useMemo<AppBskyFeedPost.Record | undefined>(
|
||||
@@ -85,6 +87,7 @@ export function Post({
|
||||
showReplyLine={showReplyLine}
|
||||
hideTopBorder={hideTopBorder}
|
||||
style={style}
|
||||
onBeforePress={onBeforePress}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -99,6 +102,7 @@ function PostInner({
|
||||
showReplyLine,
|
||||
hideTopBorder,
|
||||
style,
|
||||
onBeforePress: outerOnBeforePress,
|
||||
}: {
|
||||
post: Shadow<AppBskyFeedDefs.PostView>
|
||||
record: AppBskyFeedPost.Record
|
||||
@@ -107,6 +111,7 @@ function PostInner({
|
||||
showReplyLine?: boolean
|
||||
hideTopBorder?: boolean
|
||||
style?: StyleProp<ViewStyle>
|
||||
onBeforePress?: () => void
|
||||
}) {
|
||||
const queryClient = useQueryClient()
|
||||
const pal = usePalette('default')
|
||||
@@ -142,7 +147,8 @@ function PostInner({
|
||||
|
||||
const onBeforePress = useCallback(() => {
|
||||
unstableCacheProfileView(queryClient, post.author)
|
||||
}, [queryClient, post.author])
|
||||
outerOnBeforePress?.()
|
||||
}, [queryClient, post.author, outerOnBeforePress])
|
||||
|
||||
const [hover, setHover] = useState(false)
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user