From 30afe1133484bbecbbaa972c5df075ffbad7a040 Mon Sep 17 00:00:00 2001
From: DS Boyce <260543580+ds-boyce@users.noreply.github.com>
Date: Thu, 15 Oct 2026 09:41:45 -0700
Subject: [PATCH] Wire up Moderation Inbox analytics (#11971)
---
src/analytics/metrics/types.ts | 22 +++++++
src/screens/ModerationInbox/Notice.tsx | 57 ++++++++++++++-----
src/screens/ModerationInbox/Report.tsx | 20 +++++--
.../components/AccountStatus.tsx | 7 ++-
.../ModerationInbox/components/FilterMenu.tsx | 12 +++-
src/screens/ModerationInbox/index.tsx | 25 ++++++--
6 files changed, 118 insertions(+), 25 deletions(-)
diff --git a/src/analytics/metrics/types.ts b/src/analytics/metrics/types.ts
index bd1da4c81..46ee23fe6 100644
--- a/src/analytics/metrics/types.ts
+++ b/src/analytics/metrics/types.ts
@@ -1031,6 +1031,28 @@ export type Events = {
listType: 'mute' | 'block'
}
+ 'moderation:inbox:view': {
+ tab: 'reports' | 'account'
+ }
+ 'moderation:inbox:filter': {
+ tab: 'reports' | 'account'
+ filter: 'all' | 'pending' | 'resolved' | 'unread'
+ }
+ 'moderation:inbox:markAllAsRead': {
+ tab: 'reports' | 'account'
+ }
+ 'moderation:inbox:viewAccountStatus': {
+ status: 'warning' | 'atRisk'
+ }
+ 'moderation:inbox:viewReport': {}
+ 'moderation:inbox:viewNotice': {}
+ 'moderation:inbox:startAppeal': {
+ type?: string
+ }
+ 'moderation:inbox:submitAppeal': {
+ type?: string
+ }
+
'reportDialog:open': {
subjectType: string
}
diff --git a/src/screens/ModerationInbox/Notice.tsx b/src/screens/ModerationInbox/Notice.tsx
index 7ae3729ef..c4588ecb0 100644
--- a/src/screens/ModerationInbox/Notice.tsx
+++ b/src/screens/ModerationInbox/Notice.tsx
@@ -1,8 +1,9 @@
-import {useRef, useState} from 'react'
+import {useCallback, useRef, useState} from 'react'
import {View} from 'react-native'
import {AtUri, isAtUriString, isValidDid} from '@atproto/syntax'
import {moderateProfile} from '@bsky/sdk/moderation'
import {Plural, Trans, useLingui} from '@lingui/react/macro'
+import {useFocusEffect} from '@react-navigation/native'
import {countGraphemes} from 'unicode-segmenter/grapheme'
import {MAX_REPORT_REASON_GRAPHEME_LENGTH, webLinks} from '#/lib/constants'
@@ -90,6 +91,20 @@ export function ModerationInboxNoticeDetailsScreen({
matchXrpcError(subjectQuery.error, tools.ozone.inbox.getActionedSubject) ===
'NotFound'
+ useFocusEffect(
+ useCallback(() => {
+ if (
+ isEnabled &&
+ hasSession &&
+ moderationService &&
+ subject &&
+ !notFound
+ ) {
+ ax.metric('moderation:inbox:viewNotice', {})
+ }
+ }, [ax, isEnabled, hasSession, moderationService, subject, notFound]),
+ )
+
if (!isEnabled || !hasSession || !moderationService || !subject || notFound) {
return
}
@@ -168,6 +183,7 @@ function NoticeDetails({
}) {
const t = useTheme()
const {i18n, t: l} = useLingui()
+ const ax = useAnalytics()
const appealDialogControl = Dialog.useDialogControl()
const labels = getNoticeLabels(data)
const actionLabels = useActionedSubjectLabels({
@@ -179,6 +195,16 @@ function NoticeDetails({
const policies = data.actions[0]?.policies ?? []
const canAppeal = data.availableActions?.includes('appeal') ?? false
const isAccount = 'did' in data.subject
+ const appealedAction = actions.find(
+ action =>
+ !action.reversedAt &&
+ [
+ 'contentRemoved',
+ 'accountSuspended',
+ 'accountTakedown',
+ 'labelApplied',
+ ].includes(action.type),
+ )
return (
<>
@@ -271,7 +297,12 @@ function NoticeDetails({
size="tiny"
variant="outline"
color="secondary"
- onPress={appealDialogControl.open}>
+ onPress={() => {
+ ax.metric('moderation:inbox:startAppeal', {
+ type: appealedAction?.type,
+ })
+ appealDialogControl.open()
+ }}>
Appeal this decision
@@ -285,7 +316,11 @@ function NoticeDetails({
) : null}
-
+
>
)
}
@@ -293,26 +328,19 @@ function NoticeDetails({
function AppealDialog({
control,
data,
+ appealedAction,
}: {
control: Dialog.DialogControlProps
data: tools.ozone.inbox.getActionedSubject.$OutputBody
+ appealedAction: tools.ozone.inbox.defs.ActionView | undefined
}) {
const t = useTheme()
const {i18n, t: l} = useLingui()
+ const ax = useAnalytics()
const [details, setDetails] = useState('')
const submitting = useRef(false)
const appeal = useAppealModerationInboxSubjectMutation(data.src)
const invalidateInbox = useModerationInboxCacheMutation()
- const appealedAction = data.actions.find(
- action =>
- !action.reversedAt &&
- [
- 'contentRemoved',
- 'accountSuspended',
- 'accountTakedown',
- 'labelApplied',
- ].includes(action.type),
- )
const errorCode = matchXrpcError(
appeal.error,
tools.ozone.inbox.appealActionedSubject,
@@ -359,6 +387,9 @@ function AppealDialog({
}
: undefined,
})
+ ax.metric('moderation:inbox:submitAppeal', {
+ type: appealedAction?.type,
+ })
control.close(() => {
void invalidateInbox(updatedSubject)
Toast.show(l`Appeal submitted`)
diff --git a/src/screens/ModerationInbox/Report.tsx b/src/screens/ModerationInbox/Report.tsx
index bd0d51bb4..fc1ce6470 100644
--- a/src/screens/ModerationInbox/Report.tsx
+++ b/src/screens/ModerationInbox/Report.tsx
@@ -1,7 +1,9 @@
+import {useCallback} from 'react'
import {View} from 'react-native'
import {isValidDid} from '@atproto/syntax'
import {moderateProfile} from '@bsky/sdk/moderation'
import {Trans, useLingui} from '@lingui/react/macro'
+import {useFocusEffect} from '@react-navigation/native'
import {isAppLabeler} from '#/lib/moderation'
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
@@ -65,13 +67,19 @@ export function ModerationInboxReportDetailsScreen({
: moderationService
const isLoading = !reportQuery.isError && !reportQuery.data
- if (
- !isEnabled ||
- !moderationService ||
- id === undefined ||
+ const notFound =
matchXrpcError(reportQuery.error, tools.ozone.inbox.getReport) ===
- 'NotFound'
- ) {
+ 'NotFound'
+
+ useFocusEffect(
+ useCallback(() => {
+ if (isEnabled && moderationService && id !== undefined && !notFound) {
+ ax.metric('moderation:inbox:viewReport', {})
+ }
+ }, [ax, isEnabled, moderationService, id, notFound]),
+ )
+
+ if (!isEnabled || !moderationService || id === undefined || notFound) {
return
}
diff --git a/src/screens/ModerationInbox/components/AccountStatus.tsx b/src/screens/ModerationInbox/components/AccountStatus.tsx
index 80f19c8c9..2d11e3e0a 100644
--- a/src/screens/ModerationInbox/components/AccountStatus.tsx
+++ b/src/screens/ModerationInbox/components/AccountStatus.tsx
@@ -7,6 +7,7 @@ import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfoIcon} from '#/components
import {ExclamationCircle_Stroke2_Corner0_Rounded as ExclamationCircleIcon} from '#/components/icons/ExclamationCircle'
import * as Prompt from '#/components/Prompt'
import {Text} from '#/components/Typography'
+import {useAnalytics} from '#/analytics'
export function AccountStatus({
status,
@@ -15,6 +16,7 @@ export function AccountStatus({
}) {
const t = useTheme()
const {t: l} = useLingui()
+ const ax = useAnalytics()
const control = Prompt.usePromptControl()
@@ -61,7 +63,10 @@ export function AccountStatus({
accessibilityRole="button"
accessibilityLabel={l`Show account status`}
accessibilityHint=""
- onPress={control.open}
+ onPress={() => {
+ ax.metric('moderation:inbox:viewAccountStatus', {status})
+ control.open()
+ }}
style={[
a.p_lg,
a.flex_row,
diff --git a/src/screens/ModerationInbox/components/FilterMenu.tsx b/src/screens/ModerationInbox/components/FilterMenu.tsx
index d94237494..571355dae 100644
--- a/src/screens/ModerationInbox/components/FilterMenu.tsx
+++ b/src/screens/ModerationInbox/components/FilterMenu.tsx
@@ -5,18 +5,22 @@ import {atoms as a, useTheme} from '#/alf'
import {ChevronBottom_Stroke2_Corner0_Rounded as ChevronDownIcon} from '#/components/icons/Chevron'
import * as Menu from '#/components/Menu'
import {Text} from '#/components/Typography'
+import {useAnalytics} from '#/analytics'
type ReportFilter = 'all' | 'pending' | 'resolved' | 'unread'
export function FilterMenu({
+ tab,
filter,
setFilter,
}: {
+ tab: 'reports' | 'account'
filter: ReportFilter
setFilter: React.Dispatch>
}) {
const t = useTheme()
const {t: l} = useLingui()
+ const ax = useAnalytics()
const labels: Record = {
all: l({context: 'moderation-report-filter', message: 'All'}),
@@ -54,7 +58,13 @@ export function FilterMenu({
setFilter(option.value)}>
+ onPress={() => {
+ ax.metric('moderation:inbox:filter', {
+ tab,
+ filter: option.value,
+ })
+ setFilter(option.value)
+ }}>
{option.label}
diff --git a/src/screens/ModerationInbox/index.tsx b/src/screens/ModerationInbox/index.tsx
index 93004b6a6..53a7fdb19 100644
--- a/src/screens/ModerationInbox/index.tsx
+++ b/src/screens/ModerationInbox/index.tsx
@@ -1,7 +1,12 @@
-import {useEffect, useRef, useState} from 'react'
+import {useCallback, useEffect, useRef, useState} from 'react'
import {type ListRenderItemInfo, View} from 'react-native'
import {Trans, useLingui} from '@lingui/react/macro'
-import {type RouteProp, useNavigation, useRoute} from '@react-navigation/native'
+import {
+ type RouteProp,
+ useFocusEffect,
+ useNavigation,
+ useRoute,
+} from '@react-navigation/native'
import {
type CommonNavigatorParams,
@@ -65,6 +70,14 @@ export function ModerationInboxScreen() {
const isEnabled = ax.features.enabled(ax.features.ModerationInboxEnable)
+ useFocusEffect(
+ useCallback(() => {
+ if (isEnabled) {
+ ax.metric('moderation:inbox:view', {tab: routeTab})
+ }
+ }, [ax, isEnabled, routeTab]),
+ )
+
if (!isEnabled) {
return
}
@@ -117,6 +130,7 @@ export function ModerationInboxScreen() {
function YourReports() {
const t = useTheme()
const {t: l} = useLingui()
+ const ax = useAnalytics()
const [isPTRing, setIsPTRing] = useState(false)
const [filter, setFilter] = useState('all')
@@ -174,12 +188,13 @@ function YourReports() {
t.atoms.border_contrast_low,
{minHeight: 48},
]}>
-
+
{hasUnread ? (
{
+ ax.metric('moderation:inbox:markAllAsRead', {tab: 'reports'})
markSeen.mutate(['reports'])
})}>
Mark all as read
@@ -235,6 +250,7 @@ function YourReports() {
function YourAccount() {
const t = useTheme()
const {t: l} = useLingui()
+ const ax = useAnalytics()
const [isPTRing, setIsPTRing] = useState(false)
const [filter, setFilter] = useState('all')
@@ -304,12 +320,13 @@ function YourAccount() {
t.atoms.border_contrast_low,
{minHeight: 48},
]}>
-
+
{hasUnread ? (
{
+ ax.metric('moderation:inbox:markAllAsRead', {tab: 'account'})
markSeen.mutate(['subjects', 'accountStatus'])
})}>
Mark all as read
--
knotmirror 0.0.1