diff --git a/src/analytics/metrics/types.ts b/src/analytics/metrics/types.ts index d3d5d88f92..ff6219ad65 100644 --- a/src/analytics/metrics/types.ts +++ b/src/analytics/metrics/types.ts @@ -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': {} diff --git a/src/components/PostControls/PostMenu/PostMenuItems.tsx b/src/components/PostControls/PostMenu/PostMenuItems.tsx index 9f10838ef8..d2d0d9ad5e 100644 --- a/src/components/PostControls/PostMenu/PostMenuItems.tsx +++ b/src/components/PostControls/PostMenu/PostMenuItems.tsx @@ -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 = ({ mutedWordsDialogControl.open()}> + onPress={onToggleWordsAndTagsMute}> {l`Mute words & tags`} @@ -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, + }) + }} /> , ) { + 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, ) { + 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 }