An ATproto social media client -- with an independent Appview.

invert flag for sending to statsig (#8431)

authored by hailey.at and committed by

GitHub 2a453cd9 48906481

+154 -69
+8 -4
src/Navigation.tsx
··· 759 759 linking={LINKING} 760 760 theme={theme} 761 761 onStateChange={() => { 762 - logger.metric('router:navigate', { 763 - from: prevLoggedRouteName.current, 764 - }) 762 + logger.metric( 763 + 'router:navigate', 764 + { 765 + from: prevLoggedRouteName.current, 766 + }, 767 + {statsig: false}, 768 + ) 765 769 prevLoggedRouteName.current = getCurrentRouteName() 766 770 }} 767 771 onReady={() => { 768 772 attachRouteToLogEvents(getCurrentRouteName) 769 773 logModuleInitTime() 770 774 onReady() 771 - logger.metric('router:navigate', {}) 775 + logger.metric('router:navigate', {}, {statsig: false}) 772 776 }}> 773 777 {children} 774 778 </NavigationContainer>
+9 -5
src/components/PostControls/PostMenu/PostMenuItems.tsx
··· 242 242 AppBskyFeedPost.isRecord, 243 243 ) 244 244 ) { 245 - logger.metric('translate', { 246 - sourceLanguages: post.record.langs ?? [], 247 - targetLanguage: langPrefs.primaryLanguage, 248 - textLength: post.record.text.length, 249 - }) 245 + logger.metric( 246 + 'translate', 247 + { 248 + sourceLanguages: post.record.langs ?? [], 249 + targetLanguage: langPrefs.primaryLanguage, 250 + textLength: post.record.text.length, 251 + }, 252 + {statsig: false}, 253 + ) 250 254 } 251 255 } 252 256
+7 -3
src/components/dialogs/nuxs/InitialVerificationAnnouncement.tsx
··· 161 161 color="primary" 162 162 style={[a.justify_center, a.w_full]} 163 163 onPress={() => { 164 - logger.metric('verification:learn-more', { 165 - location: 'initialAnnouncementeNux', 166 - }) 164 + logger.metric( 165 + 'verification:learn-more', 166 + { 167 + location: 'initialAnnouncementeNux', 168 + }, 169 + {statsig: false}, 170 + ) 167 171 }}> 168 172 <ButtonText> 169 173 <Trans>Read blog post</Trans>
+9 -5
src/components/dms/MessageContextMenu.tsx
··· 63 63 ) 64 64 openLink(translatorUrl, true) 65 65 66 - logger.metric('translate', { 67 - sourceLanguages: [], 68 - targetLanguage: langPrefs.primaryLanguage, 69 - textLength: message.text.length, 70 - }) 66 + logger.metric( 67 + 'translate', 68 + { 69 + sourceLanguages: [], 70 + targetLanguage: langPrefs.primaryLanguage, 71 + textLength: message.text.length, 72 + }, 73 + {statsig: false}, 74 + ) 71 75 }, [langPrefs.primaryLanguage, message.text, openLink]) 72 76 73 77 const onDelete = useCallback(() => {
+10 -2
src/components/live/LiveStatusDialog.tsx
··· 158 158 color="primary" 159 159 variant="solid" 160 160 onPress={() => { 161 - logger.metric('live:card:watch', {subject: profile.did}) 161 + logger.metric( 162 + 'live:card:watch', 163 + {subject: profile.did}, 164 + {statsig: true}, 165 + ) 162 166 openLink(embed.external.uri, false) 163 167 }}> 164 168 <ButtonText> ··· 187 191 color="secondary" 188 192 variant="solid" 189 193 onPress={() => { 190 - logger.metric('live:card:openProfile', {subject: profile.did}) 194 + logger.metric( 195 + 'live:card:openProfile', 196 + {subject: profile.did}, 197 + {statsig: true}, 198 + ) 191 199 unstableCacheProfileView(queryClient, profile) 192 200 onPressOpenProfile() 193 201 }}>
+11 -3
src/components/live/queries.ts
··· 140 140 }, 141 141 onSuccess: ({record, image}) => { 142 142 if (createdAt) { 143 - logger.metric('live:edit', {duration: record.durationMinutes}) 143 + logger.metric( 144 + 'live:edit', 145 + {duration: record.durationMinutes}, 146 + {statsig: true}, 147 + ) 144 148 } else { 145 - logger.metric('live:create', {duration: record.durationMinutes}) 149 + logger.metric( 150 + 'live:create', 151 + {duration: record.durationMinutes}, 152 + {statsig: true}, 153 + ) 146 154 } 147 155 148 156 Toast.show(_(msg`You are now live!`)) ··· 199 207 }) 200 208 }, 201 209 onSuccess: () => { 202 - logger.metric('live:remove', {}) 210 + logger.metric('live:remove', {}, {statsig: true}) 203 211 Toast.show(_(msg`You are no longer live`)) 204 212 control.close(() => { 205 213 if (!currentAccount) return
+22 -14
src/components/moderation/ReportDialog/index.tsx
··· 1 1 import React from 'react' 2 2 import {Pressable, View} from 'react-native' 3 - import {ScrollView} from 'react-native-gesture-handler' 4 - import {AppBskyLabelerDefs} from '@atproto/api' 3 + import {type ScrollView} from 'react-native-gesture-handler' 4 + import {type AppBskyLabelerDefs} from '@atproto/api' 5 5 import {msg, Trans} from '@lingui/macro' 6 6 import {useLingui} from '@lingui/react' 7 7 ··· 33 33 import {DMCA_LINK} from './const' 34 34 import {useCopyForSubject} from './copy' 35 35 import {initialState, reducer} from './state' 36 - import {ReportDialogProps, ReportSubject} from './types' 36 + import {type ReportDialogProps, type ReportSubject} from './types' 37 37 import {parseReportSubject} from './utils/parseReportSubject' 38 - import {ReportOption, useReportOptions} from './utils/useReportOptions' 38 + import {type ReportOption, useReportOptions} from './utils/useReportOptions' 39 39 40 40 export {useDialogControl as useReportDialogControl} from '#/components/Dialog' 41 41 ··· 51 51 [props.subject], 52 52 ) 53 53 const onClose = React.useCallback(() => { 54 - logger.metric('reportDialog:close', {}) 54 + logger.metric('reportDialog:close', {}, {statsig: false}) 55 55 }, []) 56 56 return ( 57 57 <Dialog.Outer control={props.control} onClose={onClose}> ··· 155 155 }), 156 156 ) 157 157 setSuccess(true) 158 - logger.metric('reportDialog:success', { 159 - reason: state.selectedOption?.reason!, 160 - labeler: state.selectedLabeler?.creator.handle!, 161 - details: !!state.details, 162 - }) 158 + logger.metric( 159 + 'reportDialog:success', 160 + { 161 + reason: state.selectedOption?.reason!, 162 + labeler: state.selectedLabeler?.creator.handle!, 163 + details: !!state.details, 164 + }, 165 + {statsig: false}, 166 + ) 163 167 // give time for user feedback 164 168 setTimeout(() => { 165 169 props.control.close() 166 170 }, 1e3) 167 171 } catch (e: any) { 168 - logger.metric('reportDialog:failure', {}) 172 + logger.metric('reportDialog:failure', {}, {statsig: false}) 169 173 logger.error(e, { 170 174 source: 'ReportDialog', 171 175 }) ··· 179 183 }, [_, submitReport, state, dispatch, props, setPending, setSuccess]) 180 184 181 185 React.useEffect(() => { 182 - logger.metric('reportDialog:open', { 183 - subjectType: props.subject.type, 184 - }) 186 + logger.metric( 187 + 'reportDialog:open', 188 + { 189 + subjectType: props.subject.type, 190 + }, 191 + {statsig: false}, 192 + ) 185 193 }, [props.subject]) 186 194 187 195 return (
+1 -1
src/components/verification/VerificationCheckButton.tsx
··· 100 100 } 101 101 hitSlop={20} 102 102 onPress={() => { 103 - logger.metric('verification:badge:click', {}) 103 + logger.metric('verification:badge:click', {}, {statsig: true}) 104 104 if (state.profile.role === 'verifier') { 105 105 verifierDialogControl.open() 106 106 } else {
+7 -3
src/components/verification/VerificationsDialog.tsx
··· 153 153 color="secondary" 154 154 style={[a.justify_center]} 155 155 onPress={() => { 156 - logger.metric('verification:learn-more', { 157 - location: 'verificationsDialog', 158 - }) 156 + logger.metric( 157 + 'verification:learn-more', 158 + { 159 + location: 'verificationsDialog', 160 + }, 161 + {statsig: true}, 162 + ) 159 163 }}> 160 164 <ButtonText> 161 165 <Trans>Learn more</Trans>
+7 -3
src/components/verification/VerifierDialog.tsx
··· 120 120 color="primary" 121 121 style={[a.justify_center]} 122 122 onPress={() => { 123 - logger.metric('verification:learn-more', { 124 - location: 'verifierDialog', 125 - }) 123 + logger.metric( 124 + 'verification:learn-more', 125 + { 126 + location: 'verifierDialog', 127 + }, 128 + {statsig: true}, 129 + ) 126 130 }}> 127 131 <ButtonText> 128 132 <Trans>Learn more</Trans>
+5 -1
src/lib/hooks/useNotificationHandler.ts
··· 248 248 'User pressed a notification, opening notifications tab', 249 249 {}, 250 250 ) 251 - logger.metric('notifications:openApp', {reason: payload.reason}) 251 + logger.metric( 252 + 'notifications:openApp', 253 + {reason: payload.reason}, 254 + {statsig: false}, 255 + ) 252 256 253 257 invalidateCachedUnreadPage() 254 258 truncateAndInvalidate(queryClient, RQKEY_NOTIFS('all'))
+8 -3
src/logger/index.ts
··· 2 2 3 3 import {logEvent} from '#/lib/statsig/statsig' 4 4 import {add} from '#/logger/logDump' 5 - import {MetricEvents} from '#/logger/metrics' 5 + import {type MetricEvents} from '#/logger/metrics' 6 6 import {bitdriftTransport} from '#/logger/transports/bitdrift' 7 7 import {consoleTransport} from '#/logger/transports/console' 8 8 import {sentryTransport} from '#/logger/transports/sentry' 9 - import {LogContext, LogLevel, Metadata, Transport} from '#/logger/types' 9 + import { 10 + LogContext, 11 + LogLevel, 12 + type Metadata, 13 + type Transport, 14 + } from '#/logger/types' 10 15 import {enabledLogLevels} from '#/logger/util' 11 16 import {isNative} from '#/platform/detection' 12 17 ··· 99 104 * Optionally also send to StatSig 100 105 */ 101 106 statsig?: boolean 102 - } = {statsig: false}, 107 + } = {statsig: true}, 103 108 ) { 104 109 logEvent(event, metadata, { 105 110 lake: !options.statsig,
+7 -3
src/screens/Moderation/VerificationSettings.tsx
··· 46 46 to={urls.website.blog.initialVerificationAnnouncement} 47 47 label={_(msg`Learn more`)} 48 48 onPress={() => { 49 - logger.metric('verification:learn-more', { 50 - location: 'verificationSettings', 51 - }) 49 + logger.metric( 50 + 'verification:learn-more', 51 + { 52 + location: 'verificationSettings', 53 + }, 54 + {statsig: true}, 55 + ) 52 56 }}> 53 57 Learn more here. 54 58 </InlineLinkText>
+10 -2
src/screens/Profile/Header/Shell.tsx
··· 101 101 102 102 useEffect(() => { 103 103 if (live.isActive) { 104 - logger.metric('live:view:profile', {subject: profile.did}) 104 + logger.metric( 105 + 'live:view:profile', 106 + {subject: profile.did}, 107 + {statsig: true}, 108 + ) 105 109 } 106 110 }, [live.isActive, profile.did]) 107 111 108 112 const onPressAvi = React.useCallback(() => { 109 113 if (live.isActive) { 110 114 playHaptic('Light') 111 - logger.metric('live:card:open', {subject: profile.did, from: 'profile'}) 115 + logger.metric( 116 + 'live:card:open', 117 + {subject: profile.did, from: 'profile'}, 118 + {statsig: true}, 119 + ) 112 120 liveStatusControl.open() 113 121 } else { 114 122 const modui = moderation.ui('avatar')
+1 -1
src/screens/Search/Explore.tsx
··· 959 959 } 960 960 if (!alreadyReportedRef.current.has(module)) { 961 961 alreadyReportedRef.current.set(module, module) 962 - logger.metric('explore:module:seen', {module}) 962 + logger.metric('explore:module:seen', {module}, {statsig: false}) 963 963 } 964 964 }, []) 965 965
+5 -1
src/screens/Search/modules/ExploreTrendingTopics.tsx
··· 44 44 trend={trend} 45 45 rank={index + 1} 46 46 onPress={() => { 47 - logger.metric('trendingTopic:click', {context: 'explore'}) 47 + logger.metric( 48 + 'trendingTopic:click', 49 + {context: 'explore'}, 50 + {statsig: true}, 51 + ) 48 52 }} 49 53 /> 50 54 ))}
+1 -1
src/screens/Signup/StepHandle.tsx
··· 55 55 value: _(msg`That handle is already taken.`), 56 56 field: 'handle', 57 57 }) 58 - logger.metric('signup:handleTaken', {}) 58 + logger.metric('signup:handleTaken', {}, {statsig: true}) 59 59 return 60 60 } 61 61 } catch (e) {
+2 -2
src/state/queries/preferences/index.ts
··· 416 416 mutationFn: async prefs => { 417 417 await agent.setVerificationPrefs(prefs) 418 418 if (prefs.hideBadges) { 419 - logger.metric('verification:settings:hideBadges', {}) 419 + logger.metric('verification:settings:hideBadges', {}, {statsig: true}) 420 420 } else { 421 - logger.metric('verification:settings:unHideBadges', {}) 421 + logger.metric('verification:settings:unHideBadges', {}, {statsig: true}) 422 422 } 423 423 // triggers a refetch 424 424 await queryClient.invalidateQueries({
+1 -1
src/state/queries/verification/useVerificationCreateMutation.tsx
··· 46 46 ) 47 47 }, 48 48 async onSuccess(_, {profile}) { 49 - logger.metric('verification:create', {}) 49 + logger.metric('verification:create', {}, {statsig: true}) 50 50 await updateProfileVerificationCache({profile}) 51 51 }, 52 52 })
+1 -1
src/state/queries/verification/useVerificationsRemoveMutation.tsx
··· 56 56 ) 57 57 }, 58 58 async onSuccess(_, {profile}) { 59 - logger.metric('verification:revoke', {}) 59 + logger.metric('verification:revoke', {}, {statsig: true}) 60 60 await updateProfileVerificationCache({profile}) 61 61 }, 62 62 })
+9 -5
src/view/com/post-thread/PostThreadItem.tsx
··· 841 841 AppBskyFeedPost.isRecord, 842 842 ) 843 843 ) { 844 - logger.metric('translate', { 845 - sourceLanguages: post.record.langs ?? [], 846 - targetLanguage: langPrefs.primaryLanguage, 847 - textLength: post.record.text.length, 848 - }) 844 + logger.metric( 845 + 'translate', 846 + { 847 + sourceLanguages: post.record.langs ?? [], 848 + targetLanguage: langPrefs.primaryLanguage, 849 + textLength: post.record.text.length, 850 + }, 851 + {statsig: false}, 852 + ) 849 853 } 850 854 851 855 return false
+8 -4
src/view/com/posts/PostFeed.tsx
··· 796 796 ) { 797 797 if (!seenActorWithStatusRef.current.has(actor.did)) { 798 798 seenActorWithStatusRef.current.add(actor.did) 799 - logger.metric('live:view:post', { 800 - subject: actor.did, 801 - feed, 802 - }) 799 + logger.metric( 800 + 'live:view:post', 801 + { 802 + subject: actor.did, 803 + feed, 804 + }, 805 + {statsig: false}, 806 + ) 803 807 } 804 808 } 805 809 }
+5 -1
src/view/com/util/UserAvatar.tsx
··· 530 530 531 531 const onOpenLiveStatus = useCallback(() => { 532 532 playHaptic('Light') 533 - logger.metric('live:card:open', {subject: profile.did, from: 'post'}) 533 + logger.metric( 534 + 'live:card:open', 535 + {subject: profile.did, from: 'post'}, 536 + {statsig: true}, 537 + ) 534 538 liveControl.open() 535 539 }, [liveControl, playHaptic, profile.did]) 536 540