Bluesky app fork with some witchin' additions 💫

Add metrics to reporting flow (#7871)

* Add metrics to reporting flow

* Remove vestigial state

authored by

Eric Bailey and committed by
GitHub
07dd57d1 1c582c59

+33 -2
+21 -2
src/components/moderation/ReportDialog/index.tsx
··· 8 8 import {wait} from '#/lib/async/wait' 9 9 import {getLabelingServiceTitle} from '#/lib/moderation' 10 10 import {sanitizeHandle} from '#/lib/strings/handles' 11 - import {logger} from '#/logger' 11 + import {Logger} from '#/logger' 12 12 import {isNative} from '#/platform/detection' 13 13 import {useMyLabelersQuery} from '#/state/queries/preferences' 14 14 import {CharProgress} from '#/view/com/composer/char-progress/CharProgress' ··· 39 39 40 40 export {useDialogControl as useReportDialogControl} from '#/components/Dialog' 41 41 42 + const logger = Logger.create(Logger.Context.ReportDialog) 43 + 42 44 export function ReportDialog( 43 45 props: Omit<ReportDialogProps, 'subject'> & { 44 46 subject: ReportSubject ··· 48 50 () => parseReportSubject(props.subject), 49 51 [props.subject], 50 52 ) 53 + const onClose = React.useCallback(() => { 54 + logger.metric('reportDialog:close', {}) 55 + }, []) 51 56 return ( 52 - <Dialog.Outer control={props.control}> 57 + <Dialog.Outer control={props.control} onClose={onClose}> 53 58 <Dialog.Handle /> 54 59 {subject ? <Inner {...props} subject={subject} /> : <Invalid />} 55 60 </Dialog.Outer> ··· 137 142 const onSubmit = React.useCallback(async () => { 138 143 dispatch({type: 'clearError'}) 139 144 145 + logger.info('submitting') 146 + 140 147 try { 141 148 setPending(true) 142 149 // wait at least 1s, make it feel substantial ··· 148 155 }), 149 156 ) 150 157 setSuccess(true) 158 + logger.metric('reportDialog:success', { 159 + reason: state.selectedOption?.reason!, 160 + labeler: state.selectedLabeler?.creator.handle!, 161 + details: !!state.details, 162 + }) 151 163 // give time for user feedback 152 164 setTimeout(() => { 153 165 props.control.close() 154 166 }, 1e3) 155 167 } catch (e: any) { 168 + logger.metric('reportDialog:failure', {}) 156 169 logger.error(e, { 157 170 source: 'ReportDialog', 158 171 }) ··· 164 177 setPending(false) 165 178 } 166 179 }, [_, submitReport, state, dispatch, props, setPending, setSuccess]) 180 + 181 + React.useEffect(() => { 182 + logger.metric('reportDialog:open', { 183 + subjectType: props.subject.type, 184 + }) 185 + }, [props.subject]) 167 186 168 187 return ( 169 188 <Dialog.ScrollableInner
+11
src/logger/metrics.ts
··· 305 305 306 306 'progressGuide:hide': {} 307 307 'progressGuide:followDialog:open': {} 308 + 309 + 'reportDialog:open': { 310 + subjectType: string 311 + } 312 + 'reportDialog:close': {} 313 + 'reportDialog:success': { 314 + reason: string 315 + labeler: string 316 + details: boolean 317 + } 318 + 'reportDialog:failure': {} 308 319 }
+1
src/logger/types.ts
··· 9 9 Notifications = 'notifications', 10 10 ConversationAgent = 'conversation-agent', 11 11 DMsAgent = 'dms-agent', 12 + ReportDialog = 'report-dialog', 12 13 13 14 /** 14 15 * METRIC IS FOR INTERNAL USE ONLY, don't create any other loggers using this