diff --git a/src/components/PostControls/BookmarkButton.tsx b/src/components/PostControls/BookmarkButton.tsx index 4eb749a0aa..b5390095e6 100644 --- a/src/components/PostControls/BookmarkButton.tsx +++ b/src/components/PostControls/BookmarkButton.tsx @@ -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 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( @@ -75,6 +80,8 @@ export const BookmarkButton = memo(function BookmarkButton({ uri: post.uri, }) + logger.metric('post:unbookmark', {logContext}) + toast.show( diff --git a/src/components/PostControls/index.tsx b/src/components/PostControls/index.tsx index 49157171bb..159a2c60d9 100644 --- a/src/components/PostControls/index.tsx +++ b/src/components/PostControls/index.tsx @@ -290,7 +290,7 @@ let PostControls = ({ - + { setMinimalShellMode(false) + logger.metric('bookmarks:view', {}) }, [setMinimalShellMode]), ) @@ -268,7 +270,15 @@ function renderItem({item, index}: {item: ListItem; index: number}) { return } case 'bookmark': { - return + return ( + { + logger.metric('bookmarks:post-clicked', {}) + }} + /> + ) } case 'bookmarkNotFound': { return ( diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index f41f48e40c..58cb40f711 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -43,11 +43,13 @@ export function Post({ showReplyLine, hideTopBorder, style, + onBeforePress, }: { post: AppBskyFeedDefs.PostView showReplyLine?: boolean hideTopBorder?: boolean style?: StyleProp + onBeforePress?: () => void }) { const moderationOpts = useModerationOpts() const record = useMemo( @@ -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 record: AppBskyFeedPost.Record @@ -107,6 +111,7 @@ function PostInner({ showReplyLine?: boolean hideTopBorder?: boolean style?: StyleProp + 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 (