Remove Metrics alias from logger

This commit is contained in:
Eric Bailey
2026-01-21 14:50:08 -06:00
parent 6b33423d14
commit 82706fbd19
4 changed files with 46 additions and 56 deletions
+19 -22
View File
@@ -7,8 +7,6 @@ import {useLingui} from '@lingui/react'
import {useNavigation} from '@react-navigation/native'
import {type NavigationProp} from '#/lib/routes/types'
import {logEvent} from '#/lib/statsig/statsig'
import {logger, type Metrics} from '#/logger'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useGetPopularFeedsQuery} from '#/state/queries/feed'
import {type FeedDescriptor} from '#/state/queries/post-feed'
@@ -37,6 +35,7 @@ import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
import {InlineLinkText} from '#/components/Link'
import * as ProfileCard from '#/components/ProfileCard'
import {Text} from '#/components/Typography'
import {type Metrics, useAnalytics} from '#/analytics'
import {IS_IOS} from '#/env'
import type * as bsky from '#/types/bsky'
import {FollowDialogWithoutGuide} from './ProgressGuide/FollowDialog'
@@ -433,6 +432,7 @@ export function ProfileGrid({
isVisible?: boolean
}) {
const t = useTheme()
const ax = useAnalytics()
const {_} = useLingui()
const moderationOpts = useModerationOpts()
const {gtMobile} = useBreakpoints()
@@ -465,20 +465,16 @@ export function ProfileGrid({
profilesToShow.forEach((profile, index) => {
if (!seenProfilesRef.current.has(profile.did)) {
seenProfilesRef.current.add(profile.did)
logger.metric(
'suggestedUser:seen',
{
logContext,
recId,
position: index,
suggestedDid: profile.did,
category: null,
},
{statsig: true},
)
ax.metric('suggestedUser:seen', {
logContext,
recId,
position: index,
suggestedDid: profile.did,
category: null,
})
}
})
}, [isLoading, error, profiles, maxLength, logContext, recId])
}, [ax, isLoading, error, profiles, maxLength, logContext, recId])
// For profile header, fire when isVisible becomes true
useEffect(() => {
@@ -563,7 +559,7 @@ export function ProfileGrid({
<ProfileCard.Link
profile={profile}
onPress={() => {
logEvent('suggestedUser:press', {
ax.metric('suggestedUser:press', {
logContext: isFeedContext
? 'InterstitialDiscover'
: 'InterstitialProfile',
@@ -586,7 +582,7 @@ export function ProfileGrid({
onPress={e => {
e.preventDefault()
onDismiss(profile.did)
logEvent('suggestedUser:dismiss', {
ax.metric('suggestedUser:dismiss', {
logContext: isFeedContext
? 'InterstitialDiscover'
: 'InterstitialProfile',
@@ -654,7 +650,7 @@ export function ProfileGrid({
withIcon={false}
style={[a.rounded_sm]}
onFollow={() => {
logEvent('suggestedUser:follow', {
ax.metric('suggestedUser:follow', {
logContext: isFeedContext
? 'InterstitialDiscover'
: 'InterstitialProfile',
@@ -676,7 +672,7 @@ export function ProfileGrid({
// Use totalProfileCount (before dismissals) for minLength check on initial render.
const profileCountForMinCheck = totalProfileCount ?? profiles.length
if (error || (!isLoading && profileCountForMinCheck < minLength)) {
logger.debug(`Not enough profiles to show suggested follows`)
ax.logger.debug(`Not enough profiles to show suggested follows`)
return null
}
@@ -710,7 +706,7 @@ export function ProfileGrid({
label={_(msg`See more suggested profiles`)}
onPress={() => {
followDialogControl.open()
logEvent('suggestedUser:seeMore', {
ax.metric('suggestedUser:seeMore', {
logContext: isFeedContext ? 'Explore' : 'Profile',
})
}}>
@@ -754,7 +750,7 @@ export function ProfileGrid({
<SeeMoreSuggestedProfilesCard
onPress={() => {
followDialogControl.open()
logger.metric('suggestedUser:seeMore', {
ax.metric('suggestedUser:seeMore', {
logContext: 'Explore',
})
}}
@@ -792,9 +788,10 @@ function SeeMoreSuggestedProfilesCard({onPress}: {onPress: () => void}) {
)
}
const numFeedsToDisplay = 3
export function SuggestedFeeds() {
const numFeedsToDisplay = 3
const t = useTheme()
const ax = useAnalytics()
const {_} = useLingui()
const {data, isLoading, error} = useGetPopularFeedsQuery({
limit: numFeedsToDisplay,
@@ -827,7 +824,7 @@ export function SuggestedFeeds() {
key={feed.uri}
view={feed}
onPress={() => {
logEvent('feed:interstitial:feedCard:press', {})
ax.metric('feed:interstitial:feedCard:press', {})
}}>
{({hovered, pressed}) => (
<CardOuter
+8 -11
View File
@@ -1,7 +1,7 @@
import {useCallback, useRef} from 'react'
import {type AppBskyFeedDefs} from '@atproto/api'
import {logger, type Metrics} from '#/logger'
import {type Metrics, useAnalytics} from '#/analytics'
/**
* Hook that returns a callback to track post:view events.
@@ -13,6 +13,7 @@ import {logger, type Metrics} from '#/logger'
export function usePostViewTracking(
logContext: Metrics['post:view']['logContext'],
) {
const ax = useAnalytics()
const seenUrisRef = useRef(new Set<string>())
const trackPostView = useCallback(
@@ -20,17 +21,13 @@ export function usePostViewTracking(
if (seenUrisRef.current.has(post.uri)) return
seenUrisRef.current.add(post.uri)
logger.metric(
'post:view',
{
uri: post.uri,
authorDid: post.author.did,
logContext,
},
{statsig: false},
)
ax.metric('post:view', {
uri: post.uri,
authorDid: post.author.did,
logContext,
})
},
[logContext],
[ax, logContext],
)
return trackPostView
-1
View File
@@ -12,7 +12,6 @@ import {
import {enabledLogLevels} from '#/logger/util'
import {type Events as Metrics} from '#/analytics/metrics/types'
import {ENV} from '#/env'
export {type Events as Metrics} from '#/analytics/metrics/types'
const TRANSPORTS: Transport[] = (function configureTransports() {
switch (ENV) {
+19 -22
View File
@@ -13,7 +13,6 @@ import * as bcp47Match from 'bcp-47-match'
import {popularInterests, useInterestsDisplayNames} from '#/lib/interests'
import {cleanError} from '#/lib/strings/errors'
import {sanitizeHandle} from '#/lib/strings/handles'
import {logger, type Metrics} from '#/logger'
import {useLanguagePrefs} from '#/state/preferences/languages'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {RQKEY_ROOT as useActorSearchQueryKeyRoot} from '#/state/queries/actor-search'
@@ -67,6 +66,7 @@ import {Loader} from '#/components/Loader'
import * as ProfileCard from '#/components/ProfileCard'
import {SubtleHover} from '#/components/SubtleHover'
import {Text} from '#/components/Typography'
import {type Metrics, useAnalytics} from '#/analytics'
import {ExploreScreenLiveEventFeedsBanner} from '#/features/liveEvents/components/ExploreScreenLiveEventFeedsBanner'
import * as ModuleHeader from './components/ModuleHeader'
import {
@@ -212,6 +212,7 @@ export function Explore({
focusSearchInput: (tab: 'user' | 'profile' | 'feed') => void
headerHeight: number
}) {
const ax = useAnalytics()
const {_} = useLingui()
const t = useTheme()
const {data: preferences, error: preferencesError} = usePreferencesQuery()
@@ -272,9 +273,10 @@ export function Explore({
try {
await fetchNextFeedsPage()
} catch (err) {
logger.error('Failed to load more suggested follows', {message: err})
ax.logger.error('Failed to load more suggested follows', {message: err})
}
}, [
ax,
isFetchingNextFeedsPage,
hasNextFeedsPage,
feedsError,
@@ -332,9 +334,10 @@ export function Explore({
try {
await fetchNextPageFeedPreviews()
} catch (err) {
logger.error('Failed to load more feed previews', {message: err})
ax.logger.error('Failed to load more feed previews', {message: err})
}
}, [
ax,
isPendingFeedPreviews,
isFetchingNextPageFeedPreviews,
hasNextPageFeedPreviews,
@@ -491,11 +494,7 @@ export function Explore({
if (hasPressedLoadMoreFeeds && index < 6) {
continue
}
logger.metric(
'feed:suggestion:seen',
{feedUrl: item.feed.uri},
{statsig: false},
)
ax.metric('feed:suggestion:seen', {feedUrl: item.feed.uri})
}
}
if (!hasPressedLoadMoreFeeds) {
@@ -608,6 +607,7 @@ export function Explore({
return i
}, [
_,
ax,
useFullExperience,
suggestedFeeds,
preferences,
@@ -811,7 +811,7 @@ export function Explore({
if (!useFullExperience) {
return
}
logger.metric('feed:suggestion:press', {
ax.metric('feed:suggestion:press', {
feedUrl: item.feed.uri,
})
}}
@@ -1000,6 +1000,7 @@ export function Explore({
}
},
[
ax,
t.atoms.border_contrast_low,
t.atoms.bg_contrast_25,
t.atoms.text_contrast_medium,
@@ -1043,17 +1044,13 @@ export function Explore({
const position = suggestedFollowsModule.findIndex(
i => i.type === 'profile' && i.profile.did === item.profile.did,
)
logger.metric(
'suggestedUser:seen',
{
logContext: 'Explore',
recId: item.recId,
position: position !== -1 ? position - 1 : 0, // -1 to account for header
suggestedDid: item.profile.did,
category: null,
},
{statsig: true},
)
ax.metric('suggestedUser:seen', {
logContext: 'Explore',
recId: item.recId,
position: position !== -1 ? position - 1 : 0, // -1 to account for header
suggestedDid: item.profile.did,
category: null,
})
}
} else if (item.type === 'feed') {
module = 'suggestedFeeds'
@@ -1066,10 +1063,10 @@ export function Explore({
}
if (!alreadyReportedRef.current.has(module)) {
alreadyReportedRef.current.set(module, module)
logger.metric('explore:module:seen', {module}, {statsig: false})
ax.metric('explore:module:seen', {module})
}
},
[suggestedFollowsModule],
[ax, suggestedFollowsModule],
)
return (