starter pack metrics (#9116)

* starter pack metrics

* emit starterpack:add/remove user event with starterpack uri in starter pack dialog

* rename metadata field
This commit is contained in:
Chenyu
2025-10-03 10:17:59 -07:00
committed by GitHub
parent 885356256e
commit 12e09a9bd1
4 changed files with 20 additions and 1 deletions
@@ -13,6 +13,7 @@ import {useLingui} from '@lingui/react'
import {DISCOVER_FEED_URI, STARTER_PACK_MAX_SIZE} from '#/lib/constants' import {DISCOVER_FEED_URI, STARTER_PACK_MAX_SIZE} from '#/lib/constants'
import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeDisplayName} from '#/lib/strings/display-names'
import {sanitizeHandle} from '#/lib/strings/handles' import {sanitizeHandle} from '#/lib/strings/handles'
import {logger} from '#/logger'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {UserAvatar} from '#/view/com/util/UserAvatar' import {UserAvatar} from '#/view/com/util/UserAvatar'
import { import {
@@ -150,8 +151,10 @@ export function WizardProfileCard({
if (profile.did === targetProfileDid) return if (profile.did === targetProfileDid) return
if (!included) { if (!included) {
logger.metric('starterPack:addUser', {})
dispatch({type: 'AddProfile', profile}) dispatch({type: 'AddProfile', profile})
} else { } else {
logger.metric('starterPack:removeUser', {})
dispatch({type: 'RemoveProfile', profileDid: profile.did}) dispatch({type: 'RemoveProfile', profileDid: profile.did})
} }
} }
@@ -11,6 +11,7 @@ import {useQueryClient} from '@tanstack/react-query'
import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification' import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
import {type NavigationProp} from '#/lib/routes/types' import {type NavigationProp} from '#/lib/routes/types'
import {logger} from '#/logger'
import {isWeb} from '#/platform/detection' import {isWeb} from '#/platform/detection'
import { import {
invalidateActorStarterPacksWithMembershipQuery, invalidateActorStarterPacksWithMembershipQuery,
@@ -294,6 +295,7 @@ function StarterPackItem({
if (!starterPack.list?.uri || isPendingRefresh) return if (!starterPack.list?.uri || isPendingRefresh) return
const listUri = starterPack.list.uri const listUri = starterPack.list.uri
const starterPackUri = starterPack.uri
setIsPendingRefresh(true) setIsPendingRefresh(true)
@@ -302,6 +304,7 @@ function StarterPackItem({
listUri: listUri, listUri: listUri,
actorDid: targetDid, actorDid: targetDid,
}) })
logger.metric('starterPack:addUser', {starterPack: starterPackUri})
} else { } else {
if (!starterPackWithMembership.listItem?.uri) { if (!starterPackWithMembership.listItem?.uri) {
console.error('Cannot remove: missing membership URI') console.error('Cannot remove: missing membership URI')
@@ -313,6 +316,7 @@ function StarterPackItem({
actorDid: targetDid, actorDid: targetDid,
membershipUri: starterPackWithMembership.listItem.uri, membershipUri: starterPackWithMembership.listItem.uri,
}) })
logger.metric('starterPack:removeUser', {starterPack: starterPackUri})
} }
} }
+7
View File
@@ -326,6 +326,12 @@ export type MetricEvents = {
| 'ChatsList' | 'ChatsList'
| 'SendViaChatDialog' | 'SendViaChatDialog'
} }
'starterPack:addUser': {
starterPack?: string
}
'starterPack:removeUser': {
starterPack?: string
}
'starterPack:share': { 'starterPack:share': {
starterPack: string starterPack: string
shareType: 'link' | 'qrcode' shareType: 'link' | 'qrcode'
@@ -357,6 +363,7 @@ export type MetricEvents = {
'feed:interstitial:feedCard:press': {} 'feed:interstitial:feedCard:press': {}
'profile:header:suggestedFollowsCard:press': {} 'profile:header:suggestedFollowsCard:press': {}
'profile:addToStarterPack': {}
'test:all:always': {} 'test:all:always': {}
'test:all:sometimes': {} 'test:all:sometimes': {}
+6 -1
View File
@@ -105,6 +105,11 @@ let ProfileMenu = ({
}) })
}, [queryClient, profile.did]) }, [queryClient, profile.did])
const onPressAddToStarterPacks = React.useCallback(() => {
logger.metric('profile:addToStarterPack', {})
addToStarterPacksDialogControl.open()
}, [addToStarterPacksDialogControl])
const onPressShare = React.useCallback(() => { const onPressShare = React.useCallback(() => {
shareUrl(toShareUrl(makeProfileLink(profile))) shareUrl(toShareUrl(makeProfileLink(profile)))
}, [profile]) }, [profile])
@@ -306,7 +311,7 @@ let ProfileMenu = ({
<Menu.Item <Menu.Item
testID="profileHeaderDropdownStarterPackAddRemoveBtn" testID="profileHeaderDropdownStarterPackAddRemoveBtn"
label={_(msg`Add to starter packs`)} label={_(msg`Add to starter packs`)}
onPress={addToStarterPacksDialogControl.open}> onPress={onPressAddToStarterPacks}>
<Menu.ItemText> <Menu.ItemText>
<Trans>Add to starter packs</Trans> <Trans>Add to starter packs</Trans>
</Menu.ItemText> </Menu.ItemText>