add some metrics for labelers (#7747)
* add some metrics * add label pref switch metric * Update src/screens/Profile/Header/ProfileHeaderLabeler.tsx * Use new logger.metric * Fix conflicting types * Remove duplicate toasts * Move metric to try body * Move metric to try body --------- Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -306,6 +306,19 @@ export type MetricEvents = {
|
|||||||
'progressGuide:hide': {}
|
'progressGuide:hide': {}
|
||||||
'progressGuide:followDialog:open': {}
|
'progressGuide:followDialog:open': {}
|
||||||
|
|
||||||
|
'moderation:subscribedToLabeler': {}
|
||||||
|
'moderation:unsubscribedFromLabeler': {}
|
||||||
|
'moderation:changeLabelPreference': {
|
||||||
|
preference: string
|
||||||
|
}
|
||||||
|
|
||||||
|
'moderation:subscribedToList': {
|
||||||
|
listType: 'mute' | 'block'
|
||||||
|
}
|
||||||
|
'moderation:unsubscribedFromList': {
|
||||||
|
listType: 'mute' | 'block'
|
||||||
|
}
|
||||||
|
|
||||||
'reportDialog:open': {
|
'reportDialog:open': {
|
||||||
subjectType: string
|
subjectType: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,11 +134,21 @@ let ProfileHeaderLabeler = ({
|
|||||||
const onPressSubscribe = React.useCallback(
|
const onPressSubscribe = React.useCallback(
|
||||||
() =>
|
() =>
|
||||||
requireAuth(async (): Promise<void> => {
|
requireAuth(async (): Promise<void> => {
|
||||||
|
const subscribe = !isSubscribed
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await toggleSubscription({
|
await toggleSubscription({
|
||||||
did: profile.did,
|
did: profile.did,
|
||||||
subscribe: !isSubscribed,
|
subscribe,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
logger.metric(
|
||||||
|
subscribe
|
||||||
|
? 'moderation:subscribedToLabeler'
|
||||||
|
: 'moderation:unsubscribedFromLabeler',
|
||||||
|
{},
|
||||||
|
{statsig: true},
|
||||||
|
)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
reset()
|
reset()
|
||||||
if (e.message === 'MAX_LABELERS') {
|
if (e.message === 'MAX_LABELERS') {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
|||||||
import {PROD_DEFAULT_FEED} from '#/lib/constants'
|
import {PROD_DEFAULT_FEED} from '#/lib/constants'
|
||||||
import {replaceEqualDeep} from '#/lib/functions'
|
import {replaceEqualDeep} from '#/lib/functions'
|
||||||
import {getAge} from '#/lib/strings/time'
|
import {getAge} from '#/lib/strings/time'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {
|
import {
|
||||||
DEFAULT_HOME_FEED_PREFS,
|
DEFAULT_HOME_FEED_PREFS,
|
||||||
@@ -96,6 +97,11 @@ export function usePreferencesSetContentLabelMutation() {
|
|||||||
>({
|
>({
|
||||||
mutationFn: async ({label, visibility, labelerDid}) => {
|
mutationFn: async ({label, visibility, labelerDid}) => {
|
||||||
await agent.setContentLabelPref(label, visibility, labelerDid)
|
await agent.setContentLabelPref(label, visibility, labelerDid)
|
||||||
|
logger.metric(
|
||||||
|
'moderation:changeLabelPreference',
|
||||||
|
{preference: visibility},
|
||||||
|
{statsig: true},
|
||||||
|
)
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
queryKey: preferencesQueryKey,
|
queryKey: preferencesQueryKey,
|
||||||
|
|||||||
@@ -393,6 +393,11 @@ function Header({
|
|||||||
try {
|
try {
|
||||||
await listMuteMutation.mutateAsync({uri: list.uri, mute: true})
|
await listMuteMutation.mutateAsync({uri: list.uri, mute: true})
|
||||||
Toast.show(_(msg({message: 'List muted', context: 'toast'})))
|
Toast.show(_(msg({message: 'List muted', context: 'toast'})))
|
||||||
|
logger.metric(
|
||||||
|
'moderation:subscribedToList',
|
||||||
|
{listType: 'mute'},
|
||||||
|
{statsig: true},
|
||||||
|
)
|
||||||
} catch {
|
} catch {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
_(
|
_(
|
||||||
@@ -406,6 +411,11 @@ function Header({
|
|||||||
try {
|
try {
|
||||||
await listMuteMutation.mutateAsync({uri: list.uri, mute: false})
|
await listMuteMutation.mutateAsync({uri: list.uri, mute: false})
|
||||||
Toast.show(_(msg({message: 'List unmuted', context: 'toast'})))
|
Toast.show(_(msg({message: 'List unmuted', context: 'toast'})))
|
||||||
|
logger.metric(
|
||||||
|
'moderation:unsubscribedFromList',
|
||||||
|
{listType: 'mute'},
|
||||||
|
{statsig: true},
|
||||||
|
)
|
||||||
} catch {
|
} catch {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
_(
|
_(
|
||||||
@@ -419,6 +429,11 @@ function Header({
|
|||||||
try {
|
try {
|
||||||
await listBlockMutation.mutateAsync({uri: list.uri, block: true})
|
await listBlockMutation.mutateAsync({uri: list.uri, block: true})
|
||||||
Toast.show(_(msg({message: 'List blocked', context: 'toast'})))
|
Toast.show(_(msg({message: 'List blocked', context: 'toast'})))
|
||||||
|
logger.metric(
|
||||||
|
'moderation:subscribedToList',
|
||||||
|
{listType: 'block'},
|
||||||
|
{statsig: true},
|
||||||
|
)
|
||||||
} catch {
|
} catch {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
_(
|
_(
|
||||||
@@ -432,6 +447,11 @@ function Header({
|
|||||||
try {
|
try {
|
||||||
await listBlockMutation.mutateAsync({uri: list.uri, block: false})
|
await listBlockMutation.mutateAsync({uri: list.uri, block: false})
|
||||||
Toast.show(_(msg({message: 'List unblocked', context: 'toast'})))
|
Toast.show(_(msg({message: 'List unblocked', context: 'toast'})))
|
||||||
|
logger.metric(
|
||||||
|
'moderation:unsubscribedFromList',
|
||||||
|
{listType: 'block'},
|
||||||
|
{statsig: true},
|
||||||
|
)
|
||||||
} catch {
|
} catch {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
_(
|
_(
|
||||||
|
|||||||
Reference in New Issue
Block a user