diff --git a/src/lib/statsig/events.ts b/src/lib/statsig/events.ts index 2014f31f53..7d72633266 100644 --- a/src/lib/statsig/events.ts +++ b/src/lib/statsig/events.ts @@ -287,4 +287,17 @@ export type LogEvents = { 'progressGuide:hide': {} 'progressGuide:followDialog:open': {} + + 'moderation:subscribedToLabeler': {} + 'moderation:unsubscribedFromLabeler': {} + 'moderation:changeLabelPreference': { + preference: string + } + + 'moderation:subscribedToList': { + type: 'mute' | 'block' + } + 'moderation:unsubscribedFromList': { + type: 'mute' | 'block' + } } diff --git a/src/screens/Profile/Header/ProfileHeaderLabeler.tsx b/src/screens/Profile/Header/ProfileHeaderLabeler.tsx index 1725c4aaca..07dc19b7fa 100644 --- a/src/screens/Profile/Header/ProfileHeaderLabeler.tsx +++ b/src/screens/Profile/Header/ProfileHeaderLabeler.tsx @@ -14,6 +14,7 @@ import {useLingui} from '@lingui/react' import {MAX_LABELERS} from '#/lib/constants' import {useHaptics} from '#/lib/haptics' import {isAppLabeler} from '#/lib/moderation' +import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {isIOS, isWeb} from '#/platform/detection' import {useProfileShadow} from '#/state/cache/profile-shadow' @@ -134,6 +135,7 @@ let ProfileHeaderLabeler = ({ const onPressSubscribe = React.useCallback( () => requireAuth(async (): Promise => { + const willSubscribe = !isSubscribed try { await toggleSubscription({ did: profile.did, @@ -146,6 +148,13 @@ let ProfileHeaderLabeler = ({ return } logger.error(`Failed to subscribe to labeler`, {message: e.message}) + return + } + + if (willSubscribe) { + logEvent('moderation:subscribedToLabeler', {}) + } else { + logEvent('moderation:unbuscribedFromLabeler', {}) } }), [ diff --git a/src/view/screens/ProfileList.tsx b/src/view/screens/ProfileList.tsx index 435b09c07d..7336095419 100644 --- a/src/view/screens/ProfileList.tsx +++ b/src/view/screens/ProfileList.tsx @@ -24,6 +24,7 @@ import {makeListLink} from '#/lib/routes/links' import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types' import {NavigationProp} from '#/lib/routes/types' import {shareUrl} from '#/lib/sharing' +import {logEvent} from '#/lib/statsig/statsig' import {cleanError} from '#/lib/strings/errors' import {toShareUrl} from '#/lib/strings/url-helpers' import {s} from '#/lib/styles' @@ -389,53 +390,61 @@ function Header({ const onSubscribeMute = useCallback(async () => { try { await listMuteMutation.mutateAsync({uri: list.uri, mute: true}) - Toast.show(_(msg`List muted`)) } catch { Toast.show( _( msg`There was an issue. Please check your internet connection and try again.`, ), ) + return } + Toast.show(_(msg`List muted`)) + logEvent('moderation:subscribedToList', {type: 'mute'}) }, [list, listMuteMutation, _]) const onUnsubscribeMute = useCallback(async () => { try { await listMuteMutation.mutateAsync({uri: list.uri, mute: false}) - Toast.show(_(msg`List unmuted`)) } catch { Toast.show( _( msg`There was an issue. Please check your internet connection and try again.`, ), ) + return } + Toast.show(_(msg`List unmuted`)) + logEvent('moderation:unsubscribedFromList', {type: 'mute'}) }, [list, listMuteMutation, _]) const onSubscribeBlock = useCallback(async () => { try { await listBlockMutation.mutateAsync({uri: list.uri, block: true}) - Toast.show(_(msg`List blocked`)) } catch { Toast.show( _( msg`There was an issue. Please check your internet connection and try again.`, ), ) + return } + Toast.show(_(msg`List blocked`)) + logEvent('moderation:subscribedToList', {type: 'block'}) }, [list, listBlockMutation, _]) const onUnsubscribeBlock = useCallback(async () => { try { await listBlockMutation.mutateAsync({uri: list.uri, block: false}) - Toast.show(_(msg`List unblocked`)) } catch { Toast.show( _( msg`There was an issue. Please check your internet connection and try again.`, ), ) + return } + Toast.show(_(msg`List unblocked`)) + logEvent('moderation:unsubscribedFromList', {type: 'block'}) }, [list, listBlockMutation, _]) const onPressEdit = useCallback(() => {