Some metrics (#7294)

* Add trending metrics

* Progress guide events

* Fix naming, improve existing events
This commit is contained in:
Eric Bailey
2024-12-27 16:21:17 -06:00
committed by GitHub
parent 8b7a331815
commit c6d26a0a9c
9 changed files with 57 additions and 15 deletions
@@ -10,6 +10,7 @@ import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {logEvent} from '#/lib/statsig/statsig'
import {cleanError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isWeb} from '#/platform/detection' import {isWeb} from '#/platform/detection'
@@ -75,7 +76,10 @@ export function FollowDialog({guide}: {guide: Follow10ProgressGuide}) {
<> <>
<Button <Button
label={_(msg`Find people to follow`)} label={_(msg`Find people to follow`)}
onPress={control.open} onPress={() => {
control.open()
logEvent('progressGuide:followDialog:open', {})
}}
size={gtMobile ? 'small' : 'large'} size={gtMobile ? 'small' : 'large'}
color="primary" color="primary"
variant="solid"> variant="solid">
+6 -1
View File
@@ -88,7 +88,12 @@ export function Inner() {
) : !trending?.topics ? null : ( ) : !trending?.topics ? null : (
<> <>
{trending.topics.map(topic => ( {trending.topics.map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}> <TrendingTopicLink
key={topic.link}
topic={topic}
onPress={() => {
logEvent('trendingTopic:click', {context: 'interstitial'})
}}>
{({hovered}) => ( {({hovered}) => (
<TrendingTopic <TrendingTopic
topic={topic} topic={topic}
+13 -2
View File
@@ -237,8 +237,19 @@ export type LogEvents = {
'tmd:download': {} 'tmd:download': {}
'tmd:post': {} 'tmd:post': {}
'trendingTopics:show': {} 'trendingTopics:show': {
context: 'settings'
}
'trendingTopics:hide': { 'trendingTopics:hide': {
context: 'sidebar' | 'interstitial' | 'explore:trending' context: 'settings' | 'sidebar' | 'interstitial' | 'explore:trending'
} }
'trendingTopic:click': {
context: 'sidebar' | 'interstitial' | 'explore'
}
'recommendedTopic:click': {
context: 'explore'
}
'progressGuide:hide': {}
'progressGuide:followDialog:open': {}
} }
@@ -1,6 +1,7 @@
import {View} from 'react-native' import {View} from 'react-native'
import {Trans} from '@lingui/macro' import {Trans} from '@lingui/macro'
import {logEvent} from '#/lib/statsig/statsig'
import {isWeb} from '#/platform/detection' import {isWeb} from '#/platform/detection'
import { import {
DEFAULT_LIMIT as RECOMMENDATIONS_COUNT, DEFAULT_LIMIT as RECOMMENDATIONS_COUNT,
@@ -71,7 +72,12 @@ function Inner() {
) : !trending?.suggested ? null : ( ) : !trending?.suggested ? null : (
<> <>
{trending.suggested.map(topic => ( {trending.suggested.map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}> <TrendingTopicLink
key={topic.link}
topic={topic}
onPress={() => {
logEvent('recommendedTopic:click', {context: 'explore'})
}}>
{({hovered}) => ( {({hovered}) => (
<TrendingTopic <TrendingTopic
topic={topic} topic={topic}
@@ -106,7 +106,12 @@ function Inner() {
) : !trending?.topics ? null : ( ) : !trending?.topics ? null : (
<> <>
{trending.topics.map(topic => ( {trending.topics.map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}> <TrendingTopicLink
key={topic.link}
topic={topic}
onPress={() => {
logEvent('trendingTopic:click', {context: 'explore'})
}}>
{({hovered}) => ( {({hovered}) => (
<TrendingTopic <TrendingTopic
topic={topic} topic={topic}
@@ -3,6 +3,7 @@ import {useLingui} from '@lingui/react'
import {NativeStackScreenProps} from '@react-navigation/native-stack' import {NativeStackScreenProps} from '@react-navigation/native-stack'
import {CommonNavigatorParams} from '#/lib/routes/types' import {CommonNavigatorParams} from '#/lib/routes/types'
import {logEvent} from '#/lib/statsig/statsig'
import {isNative} from '#/platform/detection' import {isNative} from '#/platform/detection'
import {useAutoplayDisabled, useSetAutoplayDisabled} from '#/state/preferences' import {useAutoplayDisabled, useSetAutoplayDisabled} from '#/state/preferences'
import { import {
@@ -120,7 +121,15 @@ export function ContentAndMediaSettingsScreen({}: Props) {
name="show_trending_topics" name="show_trending_topics"
label={_(msg`Enable trending topics`)} label={_(msg`Enable trending topics`)}
value={!trendingDisabled} value={!trendingDisabled}
onChange={value => setTrendingDisabled(!value)}> onChange={value => {
const hide = Boolean(!value)
if (hide) {
logEvent('trendingTopics:hide', {context: 'settings'})
} else {
logEvent('trendingTopics:show', {context: 'settings'})
}
setTrendingDisabled(hide)
}}>
<SettingsList.Item> <SettingsList.Item>
<SettingsList.ItemIcon icon={Graph} /> <SettingsList.ItemIcon icon={Graph} />
<SettingsList.ItemText> <SettingsList.ItemText>
+1 -6
View File
@@ -1,6 +1,5 @@
import React from 'react' import React from 'react'
import {logEvent} from '#/lib/statsig/statsig'
import * as persisted from '#/state/persisted' import * as persisted from '#/state/persisted'
type StateContext = { type StateContext = {
@@ -27,11 +26,7 @@ function usePersistedBooleanValue<T extends keyof persisted.Schema>(key: T) {
(value: Exclude<persisted.Schema[T], undefined>) => void (value: Exclude<persisted.Schema[T], undefined>) => void
>( >(
hidden => { hidden => {
const hide = Boolean(hidden) _set(Boolean(hidden))
if (!hide) {
logEvent('trendingTopics:show', {})
}
_set(hide)
persisted.write(key, hidden) persisted.write(key, hidden)
}, },
[key, _set], [key, _set],
+2
View File
@@ -2,6 +2,7 @@ import React, {useMemo} from 'react'
import {msg} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {logEvent} from '#/lib/statsig/statsig'
import { import {
ProgressGuideToast, ProgressGuideToast,
ProgressGuideToastRef, ProgressGuideToastRef,
@@ -137,6 +138,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
endProgressGuide() { endProgressGuide() {
setLocalGuideState(undefined) setLocalGuideState(undefined)
mutateAsync(undefined) mutateAsync(undefined)
logEvent('progressGuide:hide', {})
}, },
captureAction(action: ProgressGuideAction, count = 1) { captureAction(action: ProgressGuideAction, count = 1) {
@@ -79,7 +79,12 @@ function Inner() {
) : !trending?.topics ? null : ( ) : !trending?.topics ? null : (
<> <>
{trending.topics.slice(0, TRENDING_LIMIT).map(topic => ( {trending.topics.slice(0, TRENDING_LIMIT).map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}> <TrendingTopicLink
key={topic.link}
topic={topic}
onPress={() => {
logEvent('trendingTopic:click', {context: 'sidebar'})
}}>
{({hovered}) => ( {({hovered}) => (
<TrendingTopic <TrendingTopic
size="small" size="small"