Skip to content

Commit c6d26a0

Browse files
Some metrics (bluesky-social#7294)
* Add trending metrics * Progress guide events * Fix naming, improve existing events
1 parent 8b7a331 commit c6d26a0

File tree

9 files changed

+56
-14
lines changed

9 files changed

+56
-14
lines changed

src/components/ProgressGuide/FollowDialog.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {msg, Trans} from '@lingui/macro'
1010
import {useLingui} from '@lingui/react'
1111

1212
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
13+
import {logEvent} from '#/lib/statsig/statsig'
1314
import {cleanError} from '#/lib/strings/errors'
1415
import {logger} from '#/logger'
1516
import {isWeb} from '#/platform/detection'
@@ -75,7 +76,10 @@ export function FollowDialog({guide}: {guide: Follow10ProgressGuide}) {
7576
<>
7677
<Button
7778
label={_(msg`Find people to follow`)}
78-
onPress={control.open}
79+
onPress={() => {
80+
control.open()
81+
logEvent('progressGuide:followDialog:open', {})
82+
}}
7983
size={gtMobile ? 'small' : 'large'}
8084
color="primary"
8185
variant="solid">

src/components/interstitials/Trending.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ export function Inner() {
8888
) : !trending?.topics ? null : (
8989
<>
9090
{trending.topics.map(topic => (
91-
<TrendingTopicLink key={topic.link} topic={topic}>
91+
<TrendingTopicLink
92+
key={topic.link}
93+
topic={topic}
94+
onPress={() => {
95+
logEvent('trendingTopic:click', {context: 'interstitial'})
96+
}}>
9297
{({hovered}) => (
9398
<TrendingTopic
9499
topic={topic}

src/lib/statsig/events.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,19 @@ export type LogEvents = {
237237
'tmd:download': {}
238238
'tmd:post': {}
239239

240-
'trendingTopics:show': {}
240+
'trendingTopics:show': {
241+
context: 'settings'
242+
}
241243
'trendingTopics:hide': {
242-
context: 'sidebar' | 'interstitial' | 'explore:trending'
244+
context: 'settings' | 'sidebar' | 'interstitial' | 'explore:trending'
245+
}
246+
'trendingTopic:click': {
247+
context: 'sidebar' | 'interstitial' | 'explore'
243248
}
249+
'recommendedTopic:click': {
250+
context: 'explore'
251+
}
252+
253+
'progressGuide:hide': {}
254+
'progressGuide:followDialog:open': {}
244255
}

src/screens/Search/components/ExploreRecommendations.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {View} from 'react-native'
22
import {Trans} from '@lingui/macro'
33

4+
import {logEvent} from '#/lib/statsig/statsig'
45
import {isWeb} from '#/platform/detection'
56
import {
67
DEFAULT_LIMIT as RECOMMENDATIONS_COUNT,
@@ -71,7 +72,12 @@ function Inner() {
7172
) : !trending?.suggested ? null : (
7273
<>
7374
{trending.suggested.map(topic => (
74-
<TrendingTopicLink key={topic.link} topic={topic}>
75+
<TrendingTopicLink
76+
key={topic.link}
77+
topic={topic}
78+
onPress={() => {
79+
logEvent('recommendedTopic:click', {context: 'explore'})
80+
}}>
7581
{({hovered}) => (
7682
<TrendingTopic
7783
topic={topic}

src/screens/Search/components/ExploreTrendingTopics.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ function Inner() {
106106
) : !trending?.topics ? null : (
107107
<>
108108
{trending.topics.map(topic => (
109-
<TrendingTopicLink key={topic.link} topic={topic}>
109+
<TrendingTopicLink
110+
key={topic.link}
111+
topic={topic}
112+
onPress={() => {
113+
logEvent('trendingTopic:click', {context: 'explore'})
114+
}}>
110115
{({hovered}) => (
111116
<TrendingTopic
112117
topic={topic}

src/screens/Settings/ContentAndMediaSettings.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {useLingui} from '@lingui/react'
33
import {NativeStackScreenProps} from '@react-navigation/native-stack'
44

55
import {CommonNavigatorParams} from '#/lib/routes/types'
6+
import {logEvent} from '#/lib/statsig/statsig'
67
import {isNative} from '#/platform/detection'
78
import {useAutoplayDisabled, useSetAutoplayDisabled} from '#/state/preferences'
89
import {
@@ -120,7 +121,15 @@ export function ContentAndMediaSettingsScreen({}: Props) {
120121
name="show_trending_topics"
121122
label={_(msg`Enable trending topics`)}
122123
value={!trendingDisabled}
123-
onChange={value => setTrendingDisabled(!value)}>
124+
onChange={value => {
125+
const hide = Boolean(!value)
126+
if (hide) {
127+
logEvent('trendingTopics:hide', {context: 'settings'})
128+
} else {
129+
logEvent('trendingTopics:show', {context: 'settings'})
130+
}
131+
setTrendingDisabled(hide)
132+
}}>
124133
<SettingsList.Item>
125134
<SettingsList.ItemIcon icon={Graph} />
126135
<SettingsList.ItemText>

src/state/preferences/trending.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
22

3-
import {logEvent} from '#/lib/statsig/statsig'
43
import * as persisted from '#/state/persisted'
54

65
type StateContext = {
@@ -27,11 +26,7 @@ function usePersistedBooleanValue<T extends keyof persisted.Schema>(key: T) {
2726
(value: Exclude<persisted.Schema[T], undefined>) => void
2827
>(
2928
hidden => {
30-
const hide = Boolean(hidden)
31-
if (!hide) {
32-
logEvent('trendingTopics:show', {})
33-
}
34-
_set(hide)
29+
_set(Boolean(hidden))
3530
persisted.write(key, hidden)
3631
},
3732
[key, _set],

src/state/shell/progress-guide.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {useMemo} from 'react'
22
import {msg} from '@lingui/macro'
33
import {useLingui} from '@lingui/react'
44

5+
import {logEvent} from '#/lib/statsig/statsig'
56
import {
67
ProgressGuideToast,
78
ProgressGuideToastRef,
@@ -137,6 +138,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
137138
endProgressGuide() {
138139
setLocalGuideState(undefined)
139140
mutateAsync(undefined)
141+
logEvent('progressGuide:hide', {})
140142
},
141143

142144
captureAction(action: ProgressGuideAction, count = 1) {

src/view/shell/desktop/SidebarTrendingTopics.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ function Inner() {
7979
) : !trending?.topics ? null : (
8080
<>
8181
{trending.topics.slice(0, TRENDING_LIMIT).map(topic => (
82-
<TrendingTopicLink key={topic.link} topic={topic}>
82+
<TrendingTopicLink
83+
key={topic.link}
84+
topic={topic}
85+
onPress={() => {
86+
logEvent('trendingTopic:click', {context: 'sidebar'})
87+
}}>
8388
{({hovered}) => (
8489
<TrendingTopic
8590
size="small"

0 commit comments

Comments
 (0)