invert flag for sending to statsig (#8431)

This commit is contained in:
hailey
2025-05-30 12:13:44 -07:00
committed by GitHub
parent 4890648116
commit 2a453cd9ca
23 changed files with 154 additions and 69 deletions
+7 -3
View File
@@ -759,16 +759,20 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
linking={LINKING} linking={LINKING}
theme={theme} theme={theme}
onStateChange={() => { onStateChange={() => {
logger.metric('router:navigate', { logger.metric(
'router:navigate',
{
from: prevLoggedRouteName.current, from: prevLoggedRouteName.current,
}) },
{statsig: false},
)
prevLoggedRouteName.current = getCurrentRouteName() prevLoggedRouteName.current = getCurrentRouteName()
}} }}
onReady={() => { onReady={() => {
attachRouteToLogEvents(getCurrentRouteName) attachRouteToLogEvents(getCurrentRouteName)
logModuleInitTime() logModuleInitTime()
onReady() onReady()
logger.metric('router:navigate', {}) logger.metric('router:navigate', {}, {statsig: false})
}}> }}>
{children} {children}
</NavigationContainer> </NavigationContainer>
@@ -242,11 +242,15 @@ let PostMenuItems = ({
AppBskyFeedPost.isRecord, AppBskyFeedPost.isRecord,
) )
) { ) {
logger.metric('translate', { logger.metric(
'translate',
{
sourceLanguages: post.record.langs ?? [], sourceLanguages: post.record.langs ?? [],
targetLanguage: langPrefs.primaryLanguage, targetLanguage: langPrefs.primaryLanguage,
textLength: post.record.text.length, textLength: post.record.text.length,
}) },
{statsig: false},
)
} }
} }
@@ -161,9 +161,13 @@ export function InitialVerificationAnnouncement() {
color="primary" color="primary"
style={[a.justify_center, a.w_full]} style={[a.justify_center, a.w_full]}
onPress={() => { onPress={() => {
logger.metric('verification:learn-more', { logger.metric(
'verification:learn-more',
{
location: 'initialAnnouncementeNux', location: 'initialAnnouncementeNux',
}) },
{statsig: false},
)
}}> }}>
<ButtonText> <ButtonText>
<Trans>Read blog post</Trans> <Trans>Read blog post</Trans>
+6 -2
View File
@@ -63,11 +63,15 @@ export let MessageContextMenu = ({
) )
openLink(translatorUrl, true) openLink(translatorUrl, true)
logger.metric('translate', { logger.metric(
'translate',
{
sourceLanguages: [], sourceLanguages: [],
targetLanguage: langPrefs.primaryLanguage, targetLanguage: langPrefs.primaryLanguage,
textLength: message.text.length, textLength: message.text.length,
}) },
{statsig: false},
)
}, [langPrefs.primaryLanguage, message.text, openLink]) }, [langPrefs.primaryLanguage, message.text, openLink])
const onDelete = useCallback(() => { const onDelete = useCallback(() => {
+10 -2
View File
@@ -158,7 +158,11 @@ export function LiveStatus({
color="primary" color="primary"
variant="solid" variant="solid"
onPress={() => { onPress={() => {
logger.metric('live:card:watch', {subject: profile.did}) logger.metric(
'live:card:watch',
{subject: profile.did},
{statsig: true},
)
openLink(embed.external.uri, false) openLink(embed.external.uri, false)
}}> }}>
<ButtonText> <ButtonText>
@@ -187,7 +191,11 @@ export function LiveStatus({
color="secondary" color="secondary"
variant="solid" variant="solid"
onPress={() => { onPress={() => {
logger.metric('live:card:openProfile', {subject: profile.did}) logger.metric(
'live:card:openProfile',
{subject: profile.did},
{statsig: true},
)
unstableCacheProfileView(queryClient, profile) unstableCacheProfileView(queryClient, profile)
onPressOpenProfile() onPressOpenProfile()
}}> }}>
+11 -3
View File
@@ -140,9 +140,17 @@ export function useUpsertLiveStatusMutation(
}, },
onSuccess: ({record, image}) => { onSuccess: ({record, image}) => {
if (createdAt) { if (createdAt) {
logger.metric('live:edit', {duration: record.durationMinutes}) logger.metric(
'live:edit',
{duration: record.durationMinutes},
{statsig: true},
)
} else { } else {
logger.metric('live:create', {duration: record.durationMinutes}) logger.metric(
'live:create',
{duration: record.durationMinutes},
{statsig: true},
)
} }
Toast.show(_(msg`You are now live!`)) Toast.show(_(msg`You are now live!`))
@@ -199,7 +207,7 @@ export function useRemoveLiveStatusMutation() {
}) })
}, },
onSuccess: () => { onSuccess: () => {
logger.metric('live:remove', {}) logger.metric('live:remove', {}, {statsig: true})
Toast.show(_(msg`You are no longer live`)) Toast.show(_(msg`You are no longer live`))
control.close(() => { control.close(() => {
if (!currentAccount) return if (!currentAccount) return
@@ -1,7 +1,7 @@
import React from 'react' import React from 'react'
import {Pressable, View} from 'react-native' import {Pressable, View} from 'react-native'
import {ScrollView} from 'react-native-gesture-handler' import {type ScrollView} from 'react-native-gesture-handler'
import {AppBskyLabelerDefs} from '@atproto/api' import {type AppBskyLabelerDefs} from '@atproto/api'
import {msg, Trans} from '@lingui/macro' import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
@@ -33,9 +33,9 @@ import {useSubmitReportMutation} from './action'
import {DMCA_LINK} from './const' import {DMCA_LINK} from './const'
import {useCopyForSubject} from './copy' import {useCopyForSubject} from './copy'
import {initialState, reducer} from './state' import {initialState, reducer} from './state'
import {ReportDialogProps, ReportSubject} from './types' import {type ReportDialogProps, type ReportSubject} from './types'
import {parseReportSubject} from './utils/parseReportSubject' import {parseReportSubject} from './utils/parseReportSubject'
import {ReportOption, useReportOptions} from './utils/useReportOptions' import {type ReportOption, useReportOptions} from './utils/useReportOptions'
export {useDialogControl as useReportDialogControl} from '#/components/Dialog' export {useDialogControl as useReportDialogControl} from '#/components/Dialog'
@@ -51,7 +51,7 @@ export function ReportDialog(
[props.subject], [props.subject],
) )
const onClose = React.useCallback(() => { const onClose = React.useCallback(() => {
logger.metric('reportDialog:close', {}) logger.metric('reportDialog:close', {}, {statsig: false})
}, []) }, [])
return ( return (
<Dialog.Outer control={props.control} onClose={onClose}> <Dialog.Outer control={props.control} onClose={onClose}>
@@ -155,17 +155,21 @@ function Inner(props: ReportDialogProps) {
}), }),
) )
setSuccess(true) setSuccess(true)
logger.metric('reportDialog:success', { logger.metric(
'reportDialog:success',
{
reason: state.selectedOption?.reason!, reason: state.selectedOption?.reason!,
labeler: state.selectedLabeler?.creator.handle!, labeler: state.selectedLabeler?.creator.handle!,
details: !!state.details, details: !!state.details,
}) },
{statsig: false},
)
// give time for user feedback // give time for user feedback
setTimeout(() => { setTimeout(() => {
props.control.close() props.control.close()
}, 1e3) }, 1e3)
} catch (e: any) { } catch (e: any) {
logger.metric('reportDialog:failure', {}) logger.metric('reportDialog:failure', {}, {statsig: false})
logger.error(e, { logger.error(e, {
source: 'ReportDialog', source: 'ReportDialog',
}) })
@@ -179,9 +183,13 @@ function Inner(props: ReportDialogProps) {
}, [_, submitReport, state, dispatch, props, setPending, setSuccess]) }, [_, submitReport, state, dispatch, props, setPending, setSuccess])
React.useEffect(() => { React.useEffect(() => {
logger.metric('reportDialog:open', { logger.metric(
'reportDialog:open',
{
subjectType: props.subject.type, subjectType: props.subject.type,
}) },
{statsig: false},
)
}, [props.subject]) }, [props.subject])
return ( return (
@@ -100,7 +100,7 @@ export function Badge({
} }
hitSlop={20} hitSlop={20}
onPress={() => { onPress={() => {
logger.metric('verification:badge:click', {}) logger.metric('verification:badge:click', {}, {statsig: true})
if (state.profile.role === 'verifier') { if (state.profile.role === 'verifier') {
verifierDialogControl.open() verifierDialogControl.open()
} else { } else {
@@ -153,9 +153,13 @@ function Inner({
color="secondary" color="secondary"
style={[a.justify_center]} style={[a.justify_center]}
onPress={() => { onPress={() => {
logger.metric('verification:learn-more', { logger.metric(
'verification:learn-more',
{
location: 'verificationsDialog', location: 'verificationsDialog',
}) },
{statsig: true},
)
}}> }}>
<ButtonText> <ButtonText>
<Trans>Learn more</Trans> <Trans>Learn more</Trans>
@@ -120,9 +120,13 @@ function Inner({
color="primary" color="primary"
style={[a.justify_center]} style={[a.justify_center]}
onPress={() => { onPress={() => {
logger.metric('verification:learn-more', { logger.metric(
'verification:learn-more',
{
location: 'verifierDialog', location: 'verifierDialog',
}) },
{statsig: true},
)
}}> }}>
<ButtonText> <ButtonText>
<Trans>Learn more</Trans> <Trans>Learn more</Trans>
+5 -1
View File
@@ -248,7 +248,11 @@ export function useNotificationsHandler() {
'User pressed a notification, opening notifications tab', 'User pressed a notification, opening notifications tab',
{}, {},
) )
logger.metric('notifications:openApp', {reason: payload.reason}) logger.metric(
'notifications:openApp',
{reason: payload.reason},
{statsig: false},
)
invalidateCachedUnreadPage() invalidateCachedUnreadPage()
truncateAndInvalidate(queryClient, RQKEY_NOTIFS('all')) truncateAndInvalidate(queryClient, RQKEY_NOTIFS('all'))
+8 -3
View File
@@ -2,11 +2,16 @@ import {nanoid} from 'nanoid/non-secure'
import {logEvent} from '#/lib/statsig/statsig' import {logEvent} from '#/lib/statsig/statsig'
import {add} from '#/logger/logDump' import {add} from '#/logger/logDump'
import {MetricEvents} from '#/logger/metrics' import {type MetricEvents} from '#/logger/metrics'
import {bitdriftTransport} from '#/logger/transports/bitdrift' import {bitdriftTransport} from '#/logger/transports/bitdrift'
import {consoleTransport} from '#/logger/transports/console' import {consoleTransport} from '#/logger/transports/console'
import {sentryTransport} from '#/logger/transports/sentry' import {sentryTransport} from '#/logger/transports/sentry'
import {LogContext, LogLevel, Metadata, Transport} from '#/logger/types' import {
LogContext,
LogLevel,
type Metadata,
type Transport,
} from '#/logger/types'
import {enabledLogLevels} from '#/logger/util' import {enabledLogLevels} from '#/logger/util'
import {isNative} from '#/platform/detection' import {isNative} from '#/platform/detection'
@@ -99,7 +104,7 @@ export class Logger {
* Optionally also send to StatSig * Optionally also send to StatSig
*/ */
statsig?: boolean statsig?: boolean
} = {statsig: false}, } = {statsig: true},
) { ) {
logEvent(event, metadata, { logEvent(event, metadata, {
lake: !options.statsig, lake: !options.statsig,
@@ -46,9 +46,13 @@ export function Screen() {
to={urls.website.blog.initialVerificationAnnouncement} to={urls.website.blog.initialVerificationAnnouncement}
label={_(msg`Learn more`)} label={_(msg`Learn more`)}
onPress={() => { onPress={() => {
logger.metric('verification:learn-more', { logger.metric(
'verification:learn-more',
{
location: 'verificationSettings', location: 'verificationSettings',
}) },
{statsig: true},
)
}}> }}>
Learn more here. Learn more here.
</InlineLinkText> </InlineLinkText>
+10 -2
View File
@@ -101,14 +101,22 @@ let ProfileHeaderShell = ({
useEffect(() => { useEffect(() => {
if (live.isActive) { if (live.isActive) {
logger.metric('live:view:profile', {subject: profile.did}) logger.metric(
'live:view:profile',
{subject: profile.did},
{statsig: true},
)
} }
}, [live.isActive, profile.did]) }, [live.isActive, profile.did])
const onPressAvi = React.useCallback(() => { const onPressAvi = React.useCallback(() => {
if (live.isActive) { if (live.isActive) {
playHaptic('Light') playHaptic('Light')
logger.metric('live:card:open', {subject: profile.did, from: 'profile'}) logger.metric(
'live:card:open',
{subject: profile.did, from: 'profile'},
{statsig: true},
)
liveStatusControl.open() liveStatusControl.open()
} else { } else {
const modui = moderation.ui('avatar') const modui = moderation.ui('avatar')
+1 -1
View File
@@ -959,7 +959,7 @@ export function Explore({
} }
if (!alreadyReportedRef.current.has(module)) { if (!alreadyReportedRef.current.has(module)) {
alreadyReportedRef.current.set(module, module) alreadyReportedRef.current.set(module, module)
logger.metric('explore:module:seen', {module}) logger.metric('explore:module:seen', {module}, {statsig: false})
} }
}, []) }, [])
@@ -44,7 +44,11 @@ function Inner() {
trend={trend} trend={trend}
rank={index + 1} rank={index + 1}
onPress={() => { onPress={() => {
logger.metric('trendingTopic:click', {context: 'explore'}) logger.metric(
'trendingTopic:click',
{context: 'explore'},
{statsig: true},
)
}} }}
/> />
))} ))}
+1 -1
View File
@@ -55,7 +55,7 @@ export function StepHandle() {
value: _(msg`That handle is already taken.`), value: _(msg`That handle is already taken.`),
field: 'handle', field: 'handle',
}) })
logger.metric('signup:handleTaken', {}) logger.metric('signup:handleTaken', {}, {statsig: true})
return return
} }
} catch (e) { } catch (e) {
+2 -2
View File
@@ -416,9 +416,9 @@ export function useSetVerificationPrefsMutation() {
mutationFn: async prefs => { mutationFn: async prefs => {
await agent.setVerificationPrefs(prefs) await agent.setVerificationPrefs(prefs)
if (prefs.hideBadges) { if (prefs.hideBadges) {
logger.metric('verification:settings:hideBadges', {}) logger.metric('verification:settings:hideBadges', {}, {statsig: true})
} else { } else {
logger.metric('verification:settings:unHideBadges', {}) logger.metric('verification:settings:unHideBadges', {}, {statsig: true})
} }
// triggers a refetch // triggers a refetch
await queryClient.invalidateQueries({ await queryClient.invalidateQueries({
@@ -46,7 +46,7 @@ export function useVerificationCreateMutation() {
) )
}, },
async onSuccess(_, {profile}) { async onSuccess(_, {profile}) {
logger.metric('verification:create', {}) logger.metric('verification:create', {}, {statsig: true})
await updateProfileVerificationCache({profile}) await updateProfileVerificationCache({profile})
}, },
}) })
@@ -56,7 +56,7 @@ export function useVerificationsRemoveMutation() {
) )
}, },
async onSuccess(_, {profile}) { async onSuccess(_, {profile}) {
logger.metric('verification:revoke', {}) logger.metric('verification:revoke', {}, {statsig: true})
await updateProfileVerificationCache({profile}) await updateProfileVerificationCache({profile})
}, },
}) })
+6 -2
View File
@@ -841,11 +841,15 @@ function ExpandedPostDetails({
AppBskyFeedPost.isRecord, AppBskyFeedPost.isRecord,
) )
) { ) {
logger.metric('translate', { logger.metric(
'translate',
{
sourceLanguages: post.record.langs ?? [], sourceLanguages: post.record.langs ?? [],
targetLanguage: langPrefs.primaryLanguage, targetLanguage: langPrefs.primaryLanguage,
textLength: post.record.text.length, textLength: post.record.text.length,
}) },
{statsig: false},
)
} }
return false return false
+6 -2
View File
@@ -796,10 +796,14 @@ let PostFeed = ({
) { ) {
if (!seenActorWithStatusRef.current.has(actor.did)) { if (!seenActorWithStatusRef.current.has(actor.did)) {
seenActorWithStatusRef.current.add(actor.did) seenActorWithStatusRef.current.add(actor.did)
logger.metric('live:view:post', { logger.metric(
'live:view:post',
{
subject: actor.did, subject: actor.did,
feed, feed,
}) },
{statsig: false},
)
} }
} }
} }
+5 -1
View File
@@ -530,7 +530,11 @@ let PreviewableUserAvatar = ({
const onOpenLiveStatus = useCallback(() => { const onOpenLiveStatus = useCallback(() => {
playHaptic('Light') playHaptic('Light')
logger.metric('live:card:open', {subject: profile.did, from: 'post'}) logger.metric(
'live:card:open',
{subject: profile.did, from: 'post'},
{statsig: true},
)
liveControl.open() liveControl.open()
}, [liveControl, playHaptic, profile.did]) }, [liveControl, playHaptic, profile.did])