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