Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env var tweaks #7457

Merged
merged 7 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/components/FeedInterstitials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export function SuggestedFollowsProfile({did}: {did: string}) {
<ProfileGrid
isSuggestionsLoading={isSuggestionsLoading}
profiles={data?.suggestions ?? []}
recId={data?.recId}
error={error}
viewContext="profile"
/>
Expand All @@ -222,10 +223,12 @@ export function ProfileGrid({
isSuggestionsLoading,
error,
profiles,
recId,
viewContext = 'feed',
}: {
isSuggestionsLoading: boolean
profiles: AppBskyActorDefs.ProfileViewDetailed[]
recId?: number
error: Error | null
viewContext: 'profile' | 'feed'
}) {
Expand All @@ -249,12 +252,19 @@ export function ProfileGrid({
))
) : error || !profiles.length ? null : (
<>
{profiles.slice(0, maxLength).map(profile => (
{profiles.slice(0, maxLength).map((profile, index) => (
<ProfileCard.Link
key={profile.did}
profile={profile}
onPress={() => {
logEvent('feed:interstitial:profileCard:press', {})
logEvent('suggestedUser:press', {
logContext:
viewContext === 'feed'
? 'InterstitialDiscover'
: 'InterstitialProfile',
recId,
position: index,
})
}}
style={[
a.flex_1,
Expand Down Expand Up @@ -282,6 +292,17 @@ export function ProfileGrid({
logContext="FeedInterstitial"
shape="round"
colorInverted
onFollow={() => {
logEvent('suggestedUser:follow', {
logContext:
viewContext === 'feed'
? 'InterstitialDiscover'
: 'InterstitialProfile',
location: 'Card',
recId,
position: index,
})
}}
/>
</ProfileCard.Header>
<ProfileCard.Description profile={profile} numberOfLines={2} />
Expand Down
3 changes: 3 additions & 0 deletions src/components/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ export type FollowButtonProps = {
logContext: LogEvents['profile:follow']['logContext'] &
LogEvents['profile:unfollow']['logContext']
colorInverted?: boolean
onFollow?: () => void
} & Partial<ButtonProps>

export function FollowButton(props: FollowButtonProps) {
Expand All @@ -299,6 +300,7 @@ export function FollowButtonInner({
moderationOpts,
logContext,
onPress: onPressProp,
onFollow,
colorInverted,
...rest
}: FollowButtonProps) {
Expand All @@ -325,6 +327,7 @@ export function FollowButtonInner({
),
)
onPressProp?.(e)
onFollow?.()
} catch (err: any) {
if (err?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
Expand Down
21 changes: 20 additions & 1 deletion src/lib/statsig/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,26 @@ export type LogEvents = {
| 'PostOnboardingFindFollows'
| 'ImmersiveVideo'
}
'suggestedUser:follow': {
logContext:
| 'Explore'
| 'InterstitialDiscover'
| 'InterstitialProfile'
| 'Profile'
location: 'Card' | 'Profile'
recId?: number
position: number
}
'suggestedUser:press': {
logContext: 'Explore' | 'InterstitialDiscover' | 'InterstitialProfile'
recId?: number
position: number
}
'suggestedUser:seen': {
logContext: 'Explore' | 'InterstitialDiscover' | 'InterstitialProfile'
recId?: number
position: number
}
'profile:unfollow': {
logContext:
| 'RecommendedFollowsItem'
Expand Down Expand Up @@ -225,7 +245,6 @@ export type LogEvents = {
domain: string
}

'feed:interstitial:profileCard:press': {}
'feed:interstitial:feedCard:press': {}

'profile:header:suggestedFollowsCard:press': {}
Expand Down
2 changes: 1 addition & 1 deletion src/state/queries/suggested-follows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function useSuggestedFollowsByActorQuery({
const suggestions = res.data.isFallback
? []
: res.data.suggestions.filter(profile => !profile.viewer?.following)
return {suggestions}
return {suggestions, recId: res.data.recId}
},
enabled,
})
Expand Down
3 changes: 3 additions & 0 deletions src/view/com/profile/FollowButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ export function FollowButton({
profile,
labelStyle,
logContext,
onFollow,
}: {
unfollowedType?: ButtonType
followedType?: ButtonType
profile: Shadow<AppBskyActorDefs.ProfileViewBasic>
labelStyle?: StyleProp<TextStyle>
logContext: 'ProfileCard' | 'StarterPackProfilesList'
onFollow?: () => void
}) {
const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue(
profile,
Expand All @@ -30,6 +32,7 @@ export function FollowButton({
const onPressFollow = async () => {
try {
await queueFollow()
onFollow?.()
} catch (e: any) {
if (e?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
Expand Down
8 changes: 7 additions & 1 deletion src/view/com/profile/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,15 @@ export function ProfileCardWithFollowBtn({
noBg,
noBorder,
onPress,
onFollow,
logContext = 'ProfileCard',
showKnownFollowers,
}: {
profile: AppBskyActorDefs.ProfileView
noBg?: boolean
noBorder?: boolean
onPress?: () => void
onFollow?: () => void
logContext?: 'ProfileCard' | 'StarterPackProfilesList'
showKnownFollowers?: boolean
}) {
Expand All @@ -206,7 +208,11 @@ export function ProfileCardWithFollowBtn({
isMe
? undefined
: profileShadow => (
<FollowButton profile={profileShadow} logContext={logContext} />
<FollowButton
profile={profileShadow}
logContext={logContext}
onFollow={onFollow}
/>
)
}
onPress={onPress}
Expand Down
20 changes: 19 additions & 1 deletion src/view/screens/Search/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {logEvent} from '#/lib/statsig/statsig'
import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger'
import {isNative, isWeb} from '#/platform/detection'
Expand Down Expand Up @@ -259,6 +260,7 @@ type ExploreScreenItems =
type: 'profile'
key: string
profile: AppBskyActorDefs.ProfileView
recId?: number
}
| {
type: 'feed'
Expand Down Expand Up @@ -383,6 +385,7 @@ export function Explore() {
type: 'profile',
key: actor.did,
profile: actor,
recId: page.recId,
})
}
}
Expand Down Expand Up @@ -511,7 +514,7 @@ export function Explore() {
])

const renderItem = React.useCallback(
({item}: {item: ExploreScreenItems}) => {
({item, index}: {item: ExploreScreenItems; index: number}) => {
switch (item.type) {
case 'header': {
return (
Expand Down Expand Up @@ -540,6 +543,21 @@ export function Explore() {
noBg
noBorder
showKnownFollowers
onPress={() => {
logEvent('suggestedUser:press', {
logContext: 'Explore',
recId: item.recId,
position: index,
})
}}
onFollow={() => {
logEvent('suggestedUser:follow', {
logContext: 'Explore',
location: 'Card',
recId: item.recId,
position: index,
})
}}
/>
</View>
)
Expand Down
Loading