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