From 82706fbd19731152d76a9699595a52166cb0eae1 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 21 Jan 2026 14:50:08 -0600 Subject: [PATCH] Remove Metrics alias from logger --- src/components/FeedInterstitials.tsx | 41 +++++++++++++--------------- src/lib/hooks/usePostViewTracking.ts | 19 ++++++------- src/logger/index.tsx | 1 - src/screens/Search/Explore.tsx | 41 +++++++++++++--------------- 4 files changed, 46 insertions(+), 56 deletions(-) diff --git a/src/components/FeedInterstitials.tsx b/src/components/FeedInterstitials.tsx index 880dcd8643..37ed7ce21b 100644 --- a/src/components/FeedInterstitials.tsx +++ b/src/components/FeedInterstitials.tsx @@ -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({ { - 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({ { 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}) => ( ()) 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 diff --git a/src/logger/index.tsx b/src/logger/index.tsx index 83666b17bb..2c3398eab7 100644 --- a/src/logger/index.tsx +++ b/src/logger/index.tsx @@ -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) { diff --git a/src/screens/Search/Explore.tsx b/src/screens/Search/Explore.tsx index 6764ac2005..7b62f2223c 100644 --- a/src/screens/Search/Explore.tsx +++ b/src/screens/Search/Explore.tsx @@ -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 (