From 49d9a6fb3451d0443552e55629c5cfe9b82d8715 Mon Sep 17 00:00:00 2001 From: Alex Benzer Date: Sat, 8 Nov 2025 16:22:10 -0800 Subject: [PATCH] Add location attribute to profile:follow client event --- src/logger/metrics.ts | 1 + src/state/queries/profile.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/logger/metrics.ts b/src/logger/metrics.ts index 70ce627fa0..3d72bc4e2c 100644 --- a/src/logger/metrics.ts +++ b/src/logger/metrics.ts @@ -275,6 +275,7 @@ export type MetricEvents = { | 'ImmersiveVideo' | 'ExploreSuggestedAccounts' | 'OnboardingSuggestedAccounts' + location?: string } 'suggestedUser:follow': { logContext: diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts index eb65fef7c2..6da7771cd1 100644 --- a/src/state/queries/profile.ts +++ b/src/state/queries/profile.ts @@ -9,6 +9,7 @@ import { type ComAtprotoRepoUploadBlob, type Un$Typed, } from '@atproto/api' +import {useNavigationState} from '@react-navigation/native' import { keepPreviousData, type QueryClient, @@ -20,6 +21,7 @@ import { import {uploadBlob} from '#/lib/api' import {until} from '#/lib/async/until' import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue' +import {getCurrentRoute} from '#/lib/routes/helpers' import {logEvent, type LogEvents, toClout} from '#/lib/statsig/statsig' import {updateProfileShadow} from '#/state/cache/profile-shadow' import {type Shadow} from '#/state/cache/types' @@ -320,6 +322,12 @@ function useProfileFollowMutation( const queryClient = useQueryClient() const {captureAction} = useProgressGuideControls() + // Get current route name for automatic location detection + const currentRouteName = useNavigationState(state => { + const route = getCurrentRoute(state) + return route?.name + }) + return useMutation<{uri: string; cid: string}, Error, {did: string}>({ mutationFn: async ({did}) => { let ownProfile: AppBskyActorDefs.ProfileViewDetailed | undefined @@ -337,6 +345,8 @@ function useProfileFollowMutation( ? toClout(profile.followersCount) : undefined, followerClout: toClout(ownProfile?.followersCount), + // Include location for all profile:follow events when available + ...(currentRouteName ? {location: currentRouteName} : {}), }) return await agent.follow(did) },