From fc82355b65d07fe4a0177fd0c667ad37fa1a07af Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 18 Dec 2024 13:36:25 -0600 Subject: [PATCH] Add hide events to each location --- src/components/interstitials/Trending.tsx | 9 ++++++++- src/lib/statsig/events.ts | 2 +- .../Search/components/ExploreTrendingTopics.tsx | 11 +++++++++-- src/view/shell/desktop/SidebarTrendingTopics.tsx | 9 ++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/components/interstitials/Trending.tsx b/src/components/interstitials/Trending.tsx index 3944d92f07..ff41797f4a 100644 --- a/src/components/interstitials/Trending.tsx +++ b/src/components/interstitials/Trending.tsx @@ -1,7 +1,9 @@ +import React from 'react' import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {logEvent} from '#/lib/statsig/statsig' import { useTrendingSettings, useTrendingSettingsApi, @@ -39,6 +41,11 @@ export function Inner() { const {data: trending, error, isLoading} = useTrendingTopics() const noTopics = !isLoading && !error && !trending?.topics?.length + const onConfirmHide = React.useCallback(() => { + logEvent('trendingTopics:hide', {context: 'interstitial'}) + setTrendingDisabled(true) + }, [setTrendingDisabled]) + return error || noTopics ? null : ( setTrendingDisabled(true)} + onConfirm={onConfirmHide} /> ) diff --git a/src/lib/statsig/events.ts b/src/lib/statsig/events.ts index aeb6879373..76ba3257fa 100644 --- a/src/lib/statsig/events.ts +++ b/src/lib/statsig/events.ts @@ -239,6 +239,6 @@ export type LogEvents = { 'trendingTopics:show': {} 'trendingTopics:hide': { - context: 'sidebar' | 'discover' | 'explore' + context: 'sidebar' | 'interstitial' | 'explore' } } diff --git a/src/screens/Search/components/ExploreTrendingTopics.tsx b/src/screens/Search/components/ExploreTrendingTopics.tsx index 198adcb2a1..a4766a0f41 100644 --- a/src/screens/Search/components/ExploreTrendingTopics.tsx +++ b/src/screens/Search/components/ExploreTrendingTopics.tsx @@ -1,7 +1,9 @@ +import React from 'react' import {View} from 'react-native' -import {msg,Trans} from '@lingui/macro' +import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {logEvent} from '#/lib/statsig/statsig' import {isWeb} from '#/platform/detection' import { useTrendingSettings, @@ -40,6 +42,11 @@ function Inner() { const {setTrendingDisabled} = useTrendingSettingsApi() const trendingPrompt = Prompt.usePromptControl() + const onConfirmHide = React.useCallback(() => { + logEvent('trendingTopics:hide', {context: 'explore'}) + setTrendingDisabled(true) + }, [setTrendingDisabled]) + return error || noTopics ? null : ( <> setTrendingDisabled(true)} + onConfirm={onConfirmHide} /> ) diff --git a/src/view/shell/desktop/SidebarTrendingTopics.tsx b/src/view/shell/desktop/SidebarTrendingTopics.tsx index e22fad54d7..ef8227d1c6 100644 --- a/src/view/shell/desktop/SidebarTrendingTopics.tsx +++ b/src/view/shell/desktop/SidebarTrendingTopics.tsx @@ -1,7 +1,9 @@ +import React from 'react' import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {logEvent} from '#/lib/statsig/statsig' import { useTrendingSettings, useTrendingSettingsApi, @@ -37,6 +39,11 @@ function Inner() { const {data: trending, error, isLoading} = useTrendingTopics() const noTopics = !isLoading && !error && !trending?.topics?.length + const onConfirmHide = React.useCallback(() => { + logEvent('trendingTopics:hide', {context: 'sidebar'}) + setTrendingDisabled(true) + }, [setTrendingDisabled]) + return error || noTopics ? null : ( <> @@ -96,7 +103,7 @@ function Inner() { title={_(msg`Hide trending topics?`)} description={_(msg`You can update this later from your settings.`)} confirmButtonCta={_(msg`Hide`)} - onConfirm={() => setTrendingDisabled(true)} + onConfirm={onConfirmHide} />