From 7738fc7cbab0251a65bc7b9c0de23a03890b8427 Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Fri, 6 Sep 2024 12:13:25 -0600 Subject: [PATCH 1/2] chore: added new event for tracking when a user enbables or disables their basic functionality --- .../BasicFunctionalityModal.tsx | 14 +++++++++++--- app/core/Analytics/MetaMetrics.events.ts | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/components/UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.tsx b/app/components/UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.tsx index 300cd8a1c48..9b5dae03b28 100644 --- a/app/components/UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.tsx +++ b/app/components/UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.tsx @@ -30,7 +30,9 @@ import { asyncAlert, requestPushNotificationsPermission, } from '../../../../util/notifications'; +import { MetaMetricsEvents } from '../../../../core/Analytics'; import { useEnableNotifications } from '../../../../util/notifications/hooks/useNotifications'; +import { useMetrics } from '../../../hooks/useMetrics'; interface Props { route: { @@ -41,6 +43,7 @@ interface Props { } const BasicFunctionalityModal = ({ route }: Props) => { + const { trackEvent } = useMetrics(); const { colors } = useTheme(); const styles = createStyles(colors); const bottomSheetRef = useRef(null); @@ -68,9 +71,14 @@ const BasicFunctionalityModal = ({ route }: Props) => { }, [enableNotifications]); const closeBottomSheet = async () => { - bottomSheetRef.current?.onCloseBottomSheet(() => - dispatch(toggleBasicFunctionality(!isEnabled)), - ); + bottomSheetRef.current?.onCloseBottomSheet(() => { + dispatch(toggleBasicFunctionality(!isEnabled)); + trackEvent( + isEnabled + ? MetaMetricsEvents.BASIC_FUNCTIONALITY_ENABLED + : MetaMetricsEvents.BASIC_FUNCTIONALITY_DISABLED, + ); + }); if ( route.params.caller === Routes.SETTINGS.NOTIFICATIONS || diff --git a/app/core/Analytics/MetaMetrics.events.ts b/app/core/Analytics/MetaMetrics.events.ts index bfec76362b4..f8da8d5d757 100644 --- a/app/core/Analytics/MetaMetrics.events.ts +++ b/app/core/Analytics/MetaMetrics.events.ts @@ -159,6 +159,8 @@ enum EVENT_NAME { // Security & Privacy Settings VIEW_SECURITY_SETTINGS = 'Views Security & Privacy', + BASIC_FUNCTIONALITY_ENABLED = 'Basic Functionality Enabled', + BASIC_FUNCTIONALITY_DISABLED = 'Basic Functionality Disabled', // Settings SETTINGS_VIEWED = 'Settings Viewed', @@ -576,6 +578,12 @@ const events = { DAPP_VIEWED: generateOpt(EVENT_NAME.DAPP_VIEWED), // Security & Privacy Settings VIEW_SECURITY_SETTINGS: generateOpt(EVENT_NAME.VIEW_SECURITY_SETTINGS), + BASIC_FUNCTIONALITY_ENABLED: generateOpt( + EVENT_NAME.BASIC_FUNCTIONALITY_ENABLED, + ), + BASIC_FUNCTIONALITY_DISABLED: generateOpt( + EVENT_NAME.BASIC_FUNCTIONALITY_DISABLED, + ), // Reveal SRP REVEAL_SRP_CTA: generateOpt(EVENT_NAME.REVEAL_SRP_CTA), REVEAL_SRP_SCREEN: generateOpt(EVENT_NAME.REVEAL_SRP_SCREEN), From 519347d94829781bf6e5c770f084df8cb19db089 Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Fri, 6 Sep 2024 12:31:16 -0600 Subject: [PATCH 2/2] chore: fix ternary --- .../BasicFunctionalityModal/BasicFunctionalityModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.tsx b/app/components/UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.tsx index 9b5dae03b28..99642d1249e 100644 --- a/app/components/UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.tsx +++ b/app/components/UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.tsx @@ -74,7 +74,7 @@ const BasicFunctionalityModal = ({ route }: Props) => { bottomSheetRef.current?.onCloseBottomSheet(() => { dispatch(toggleBasicFunctionality(!isEnabled)); trackEvent( - isEnabled + !isEnabled ? MetaMetricsEvents.BASIC_FUNCTIONALITY_ENABLED : MetaMetricsEvents.BASIC_FUNCTIONALITY_DISABLED, );