Add new metrics for post menu interactions (#10022)
Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -470,6 +470,10 @@ export type Events = {
|
||||
profileDid: string
|
||||
position?: number
|
||||
}
|
||||
'profile:mute': {}
|
||||
'profile:unmute': {}
|
||||
'profile:block': {}
|
||||
'profile:unblock': {}
|
||||
'suggestedUser:follow': {
|
||||
logContext:
|
||||
| 'Explore'
|
||||
@@ -719,6 +723,37 @@ export type Events = {
|
||||
targetLanguage: string
|
||||
}
|
||||
|
||||
'postMenu:openMuteWordsDialog': {
|
||||
uri: string
|
||||
authorDid: string
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||
feedDescriptor?: string
|
||||
}
|
||||
'postMenu:muteAccount': {
|
||||
uri: string
|
||||
authorDid: string
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||
feedDescriptor?: string
|
||||
}
|
||||
'postMenu:unmuteAccount': {
|
||||
uri: string
|
||||
authorDid: string
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||
feedDescriptor?: string
|
||||
}
|
||||
'postMenu:blockAccount': {
|
||||
uri: string
|
||||
authorDid: string
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||
feedDescriptor?: string
|
||||
}
|
||||
'postMenu:reportPost': {
|
||||
uri: string
|
||||
authorDid: string
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||
feedDescriptor?: string
|
||||
}
|
||||
|
||||
'verification:create': {}
|
||||
'verification:revoke': {}
|
||||
'verification:badge:click': {}
|
||||
|
||||
@@ -251,6 +251,16 @@ let PostMenuItems = ({
|
||||
}
|
||||
}
|
||||
|
||||
const onToggleWordsAndTagsMute = () => {
|
||||
ax.metric('postMenu:openMuteWordsDialog', {
|
||||
uri: postUri,
|
||||
authorDid: postAuthor.did,
|
||||
logContext,
|
||||
feedDescriptor: feedFeedback.feedDescriptor,
|
||||
})
|
||||
mutedWordsDialogControl.open()
|
||||
}
|
||||
|
||||
const onCopyPostText = () => {
|
||||
const str = richTextToString(richText, true)
|
||||
|
||||
@@ -426,6 +436,13 @@ let PostMenuItems = ({
|
||||
logger.error('Failed to block account', {message: e})
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, 'xmark')
|
||||
}
|
||||
} finally {
|
||||
ax.metric('postMenu:blockAccount', {
|
||||
uri: postUri,
|
||||
authorDid: postAuthor.did,
|
||||
logContext,
|
||||
feedDescriptor: feedFeedback.feedDescriptor,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,6 +457,13 @@ let PostMenuItems = ({
|
||||
logger.error('Failed to unmute account', {message: e})
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, 'xmark')
|
||||
}
|
||||
} finally {
|
||||
ax.metric('postMenu:unmuteAccount', {
|
||||
uri: postUri,
|
||||
authorDid: postAuthor.did,
|
||||
logContext,
|
||||
feedDescriptor: feedFeedback.feedDescriptor,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@@ -451,6 +475,13 @@ let PostMenuItems = ({
|
||||
logger.error('Failed to mute account', {message: e})
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, 'xmark')
|
||||
}
|
||||
} finally {
|
||||
ax.metric('postMenu:muteAccount', {
|
||||
uri: postUri,
|
||||
authorDid: postAuthor.did,
|
||||
logContext,
|
||||
feedDescriptor: feedFeedback.feedDescriptor,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -601,7 +632,7 @@ let PostMenuItems = ({
|
||||
<Menu.Item
|
||||
testID="postDropdownMuteWordsBtn"
|
||||
label={l`Mute words & tags`}
|
||||
onPress={() => mutedWordsDialogControl.open()}>
|
||||
onPress={onToggleWordsAndTagsMute}>
|
||||
<Menu.ItemText>{l`Mute words & tags`}</Menu.ItemText>
|
||||
<Menu.ItemIcon icon={Filter} position="right" />
|
||||
</Menu.Item>
|
||||
@@ -785,6 +816,14 @@ let PostMenuItems = ({
|
||||
...post,
|
||||
$type: 'app.bsky.feed.defs#postView',
|
||||
}}
|
||||
onAfterSubmit={() => {
|
||||
ax.metric('postMenu:reportPost', {
|
||||
uri: postUri,
|
||||
authorDid: postAuthor.did,
|
||||
logContext,
|
||||
feedDescriptor: feedFeedback.feedDescriptor,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<PostInteractionSettingsDialog
|
||||
control={postInteractionSettingsDialogControl}
|
||||
|
||||
@@ -417,6 +417,7 @@ function useProfileUnfollowMutation(
|
||||
export function useProfileMuteMutationQueue(
|
||||
profile: Shadow<bsky.profile.AnyProfileView>,
|
||||
) {
|
||||
const ax = useAnalytics()
|
||||
const queryClient = useQueryClient()
|
||||
const did = profile.did
|
||||
const initialMuted = profile.viewer?.muted
|
||||
@@ -430,11 +431,13 @@ export function useProfileMuteMutationQueue(
|
||||
await muteMutation.mutateAsync({
|
||||
did,
|
||||
})
|
||||
ax.metric('profile:mute', {})
|
||||
return true
|
||||
} else {
|
||||
await unmuteMutation.mutateAsync({
|
||||
did,
|
||||
})
|
||||
ax.metric('profile:unmute', {})
|
||||
return false
|
||||
}
|
||||
},
|
||||
@@ -492,6 +495,7 @@ function useProfileUnmuteMutation() {
|
||||
export function useProfileBlockMutationQueue(
|
||||
profile: Shadow<bsky.profile.AnyProfileView>,
|
||||
) {
|
||||
const ax = useAnalytics()
|
||||
const queryClient = useQueryClient()
|
||||
const did = profile.did
|
||||
const initialBlockingUri = profile.viewer?.blocking
|
||||
@@ -505,6 +509,7 @@ export function useProfileBlockMutationQueue(
|
||||
const {uri} = await blockMutation.mutateAsync({
|
||||
did,
|
||||
})
|
||||
ax.metric('profile:block', {})
|
||||
return uri
|
||||
} else {
|
||||
if (prevBlockUri) {
|
||||
@@ -512,6 +517,7 @@ export function useProfileBlockMutationQueue(
|
||||
did,
|
||||
blockUri: prevBlockUri,
|
||||
})
|
||||
ax.metric('profile:unblock', {})
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user