Add search event analytics (#9949)

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
DS Boyce
2026-03-03 12:49:38 -08:00
committed by GitHub
parent 37a82761f5
commit 7dc3b4fa8e
10 changed files with 291 additions and 120 deletions
+42 -46
View File
@@ -11,8 +11,7 @@ import {
type ModerationOpts,
RichText as RichTextApi,
} from '@atproto/api'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {useLingui} from '@lingui/react/macro'
import {getModerationCauseKey} from '#/lib/moderation'
import {forceLTR} from '#/lib/strings/bidi'
@@ -56,6 +55,7 @@ export function Default({
testID,
position,
contextProfileDid,
onPress,
}: {
profile: bsky.profile.AnyProfileView
moderationOpts: ModerationOpts
@@ -63,9 +63,10 @@ export function Default({
testID?: string
position?: number
contextProfileDid?: string
onPress?: (e: GestureResponderEvent) => void
}) {
return (
<Link testID={testID} profile={profile}>
<Link testID={testID} profile={profile} onPress={onPress}>
<Card
profile={profile}
moderationOpts={moderationOpts}
@@ -135,14 +136,13 @@ export function Link({
}: {
profile: bsky.profile.AnyProfileView
} & Omit<LinkProps, 'to' | 'label'>) {
const {_} = useLingui()
const {t: l} = useLingui()
return (
<InternalLink
label={_(
msg`View ${
profile.displayName || sanitizeHandle(profile.handle)
}'s profile`,
)}
label={l`View ${
profile.displayName || sanitizeHandle(profile.handle)
}s profile`}
to={{
screen: 'Profile',
params: {name: profile.did},
@@ -488,7 +488,7 @@ export function FollowButtonInner({
contextProfileDid,
...rest
}: FollowButtonProps) {
const {_} = useLingui()
const {t: l} = useLingui()
const profile = useProfileShadow(profileUnshadowed)
const moderation = moderateProfile(profile, moderationOpts)
const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue(
@@ -505,18 +505,17 @@ export function FollowButtonInner({
try {
await queueFollow()
Toast.show(
_(
msg`Following ${sanitizeDisplayName(
profile.displayName || profile.handle,
moderation.ui('displayName'),
)}`,
),
l`Following ${sanitizeDisplayName(
profile.displayName || profile.handle,
moderation.ui('displayName'),
)}`,
)
onPressProp?.(e)
onFollow?.()
} catch (err: any) {
} catch (e) {
const err = e as Error
if (err?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
Toast.show(l`An issue occurred, please try again.`, 'xmark')
}
}
}
@@ -527,40 +526,33 @@ export function FollowButtonInner({
try {
await queueUnfollow()
Toast.show(
_(
msg`No longer following ${sanitizeDisplayName(
profile.displayName || profile.handle,
moderation.ui('displayName'),
)}`,
),
l`No longer following ${sanitizeDisplayName(
profile.displayName || profile.handle,
moderation.ui('displayName'),
)}`,
)
onPressProp?.(e)
} catch (err: any) {
} catch (e) {
const err = e as Error
if (err?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
Toast.show(l`An issue occurred, please try again.`, 'xmark')
}
}
}
const unfollowLabel = _(
msg({
message: 'Following',
comment: 'User is following this account, click to unfollow',
}),
)
const unfollowLabel = l({
message: 'Following',
comment: 'User is following this account, click to unfollow',
})
const followLabel = profile.viewer?.followedBy
? _(
msg({
message: 'Follow back',
comment: 'User is not following this account, click to follow back',
}),
)
: _(
msg({
message: 'Follow',
comment: 'User is not following this account, click to follow',
}),
)
? l({
message: 'Follow back',
comment: 'User is not following this account, click to follow back',
})
: l({
message: 'Follow',
comment: 'User is not following this account, click to follow',
})
if (!profile.viewer) return null
if (
@@ -579,7 +571,9 @@ export function FollowButtonInner({
variant="solid"
color="secondary"
{...rest}
onPress={onPressUnfollow}>
onPress={(e: GestureResponderEvent) => {
void onPressUnfollow(e)
}}>
{withIcon && (
<ButtonIcon icon={Check} position={isRound ? undefined : 'left'} />
)}
@@ -592,7 +586,9 @@ export function FollowButtonInner({
variant="solid"
color={colorInverted ? 'secondary_inverted' : 'primary'}
{...rest}
onPress={onPressFollow}>
onPress={(e: GestureResponderEvent) => {
void onPressFollow(e)
}}>
{withIcon && (
<ButtonIcon icon={Plus} position={isRound ? undefined : 'left'} />
)}