Add location attribute to profile:follow client event
This commit is contained in:
@@ -275,6 +275,7 @@ export type MetricEvents = {
|
|||||||
| 'ImmersiveVideo'
|
| 'ImmersiveVideo'
|
||||||
| 'ExploreSuggestedAccounts'
|
| 'ExploreSuggestedAccounts'
|
||||||
| 'OnboardingSuggestedAccounts'
|
| 'OnboardingSuggestedAccounts'
|
||||||
|
location?: string
|
||||||
}
|
}
|
||||||
'suggestedUser:follow': {
|
'suggestedUser:follow': {
|
||||||
logContext:
|
logContext:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
type ComAtprotoRepoUploadBlob,
|
type ComAtprotoRepoUploadBlob,
|
||||||
type Un$Typed,
|
type Un$Typed,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {useNavigationState} from '@react-navigation/native'
|
||||||
import {
|
import {
|
||||||
keepPreviousData,
|
keepPreviousData,
|
||||||
type QueryClient,
|
type QueryClient,
|
||||||
@@ -20,6 +21,7 @@ import {
|
|||||||
import {uploadBlob} from '#/lib/api'
|
import {uploadBlob} from '#/lib/api'
|
||||||
import {until} from '#/lib/async/until'
|
import {until} from '#/lib/async/until'
|
||||||
import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue'
|
import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue'
|
||||||
|
import {getCurrentRoute} from '#/lib/routes/helpers'
|
||||||
import {logEvent, type LogEvents, toClout} from '#/lib/statsig/statsig'
|
import {logEvent, type LogEvents, toClout} from '#/lib/statsig/statsig'
|
||||||
import {updateProfileShadow} from '#/state/cache/profile-shadow'
|
import {updateProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
import {type Shadow} from '#/state/cache/types'
|
import {type Shadow} from '#/state/cache/types'
|
||||||
@@ -320,6 +322,12 @@ function useProfileFollowMutation(
|
|||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const {captureAction} = useProgressGuideControls()
|
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}>({
|
return useMutation<{uri: string; cid: string}, Error, {did: string}>({
|
||||||
mutationFn: async ({did}) => {
|
mutationFn: async ({did}) => {
|
||||||
let ownProfile: AppBskyActorDefs.ProfileViewDetailed | undefined
|
let ownProfile: AppBskyActorDefs.ProfileViewDetailed | undefined
|
||||||
@@ -337,6 +345,8 @@ function useProfileFollowMutation(
|
|||||||
? toClout(profile.followersCount)
|
? toClout(profile.followersCount)
|
||||||
: undefined,
|
: undefined,
|
||||||
followerClout: toClout(ownProfile?.followersCount),
|
followerClout: toClout(ownProfile?.followersCount),
|
||||||
|
// Include location for all profile:follow events when available
|
||||||
|
...(currentRouteName ? {location: currentRouteName} : {}),
|
||||||
})
|
})
|
||||||
return await agent.follow(did)
|
return await agent.follow(did)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user