Bluesky app fork with some witchin' additions 💫

Add metrics for composer threadgate (#9401)

* add metrics for composer threadgate

* add metrics to the in-thread version

* fix type error

authored by samuel.fm and committed by

GitHub bc62b3da 53b3bd93

+37 -1
+5
src/components/WhoCanReply.tsx
··· 17 17 18 18 import {HITSLOP_10} from '#/lib/constants' 19 19 import {makeListLink, makeProfileLink} from '#/lib/routes/links' 20 + import {logger} from '#/logger' 20 21 import {isNative} from '#/platform/detection' 21 22 import { 22 23 type ThreadgateAllowUISetting, ··· 89 90 Keyboard.dismiss() 90 91 } 91 92 if (isThreadAuthor) { 93 + logger.metric('thread:click:editOwnThreadgate', {}) 94 + 92 95 // wait on prefetch if it manages to resolve in under 200ms 93 96 // otherwise, proceed immediately and show the spinner -sfn 94 97 Promise.race([ ··· 98 101 editDialogControl.open() 99 102 }) 100 103 } else { 104 + logger.metric('thread:click:viewSomeoneElsesThreadgate', {}) 105 + 101 106 infoDialogControl.open() 102 107 } 103 108 }
+15 -1
src/components/dialogs/PostInteractionSettingsDialog.tsx
··· 10 10 import {useQueryClient} from '@tanstack/react-query' 11 11 12 12 import {useHaptics} from '#/lib/haptics' 13 + import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' 13 14 import {logger} from '#/logger' 14 15 import {isIOS} from '#/platform/detection' 15 16 import {STALE} from '#/state/queries' ··· 79 80 }: PostInteractionSettingsFormProps & { 80 81 control: Dialog.DialogControlProps 81 82 }) { 83 + const onClose = useNonReactiveCallback(() => { 84 + logger.metric('composer:threadgate:save', { 85 + hasChanged: !!rest.isDirty, 86 + persist: !!rest.persist, 87 + replyOptions: 88 + rest.threadgateAllowUISettings?.map(gate => gate.type)?.join(',') ?? '', 89 + quotesEnabled: !rest.postgate?.embeddingRules?.find( 90 + v => v.$type === embeddingRules.disableRule.$type, 91 + ), 92 + }) 93 + }) 94 + 82 95 return ( 83 96 <Dialog.Outer 84 97 control={control} 85 98 nativeOptions={{ 86 99 preventExpansion: true, 87 100 preventDismiss: rest.isDirty && rest.persist, 88 - }}> 101 + }} 102 + onClose={onClose}> 89 103 <Dialog.Handle /> 90 104 <DialogInner {...rest} /> 91 105 </Dialog.Outer>
+12
src/logger/metrics.ts
··· 203 203 'composer:gif:open': {} 204 204 'composer:gif:select': {} 205 205 206 + 'composer:threadgate:open': { 207 + nudged: boolean 208 + } 209 + 'composer:threadgate:save': { 210 + replyOptions: string 211 + quotesEnabled: boolean 212 + persist: boolean 213 + hasChanged: boolean 214 + } 215 + 206 216 // Data events 207 217 'account:create:begin': {} 208 218 'account:create:success': { ··· 514 524 [key: string]: any 515 525 } 516 526 'thread:click:headerMenuOpen': {} 527 + 'thread:click:editOwnThreadgate': {} 528 + 'thread:click:viewSomeoneElsesThreadgate': {} 517 529 'activitySubscription:enable': { 518 530 setting: 'posts' | 'posts_and_replies' 519 531 }
+5
src/view/com/composer/threadgate/ThreadgateBtn.tsx
··· 45 45 const control = Dialog.useDialogControl() 46 46 const [threadgateNudged, setThreadgateNudged] = useThreadgateNudged() 47 47 const [showTooltip, setShowTooltip] = useState(false) 48 + const [tooltipWasShown] = useState(!threadgateNudged) 48 49 49 50 useEffect(() => { 50 51 if (!threadgateNudged) { ··· 65 66 const [persist, setPersist] = useState(false) 66 67 67 68 const onPress = () => { 69 + logger.metric('composer:threadgate:open', { 70 + nudged: tooltipWasShown, 71 + }) 72 + 68 73 if (isNative && Keyboard.isVisible()) { 69 74 Keyboard.dismiss() 70 75 }