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

fix: notifications use better events #26410

Merged
merged 6 commits into from
Aug 14, 2024
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
3 changes: 1 addition & 2 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ export enum MetaMetricsEventName {
NotificationReceived = 'Notification Received',
NotificationsSettingsUpdated = 'Notifications Settings Updated',
NotificationClicked = 'Notification Clicked',
NotificationsEnablingFlowHandled = 'Notifications Enabling Flow Handled',
NotificationMenuOpened = 'Notification Menu Opened',

NftAutoDetectionEnableModal = 'Nft Autodetection Enabled from modal',
NftAutoDetectionDisableModal = 'Nft Autodetection Disabled from modal',
Expand Down Expand Up @@ -756,7 +756,6 @@ export enum MetaMetricsEventCategory {
Messages = 'Messages',
Navigation = 'Navigation',
Network = 'Network',
EnableNotifications = 'Enable Notifications',
Onboarding = 'Onboarding',
NotificationInteraction = 'Notification Interaction',
NotificationSettings = 'Notification Settings',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export default function TurnOnMetamaskNotifications() {
setButtonState(true);
await createNotifications();
trackEvent({
category: MetaMetricsEventCategory.EnableNotifications,
event: MetaMetricsEventName.NotificationsEnablingFlowHandled,
category: MetaMetricsEventCategory.NotificationInteraction,
event: MetaMetricsEventName.NotificationMenuOpened,
properties: {
is_profile_syncing_enabled: isProfileSyncingEnabled,
is_notifications_enabled: isNotificationEnabled,
Expand All @@ -74,8 +74,8 @@ export default function TurnOnMetamaskNotifications() {
const handleHideModal = () => {
hideModal();
trackEvent({
category: MetaMetricsEventCategory.EnableNotifications,
event: MetaMetricsEventName.NotificationsEnablingFlowHandled,
category: MetaMetricsEventCategory.NotificationInteraction,
event: MetaMetricsEventName.NotificationMenuOpened,
properties: {
is_profile_syncing_enabled: isProfileSyncingEnabled,
is_notifications_enabled: isNotificationEnabled,
Expand Down
13 changes: 11 additions & 2 deletions ui/components/multichain/global-menu/global-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,24 @@ export const GlobalMenu = ({ closeMenu, anchorElement, isOpen }) => {

if (shouldShowEnableModal) {
trackEvent({
category: MetaMetricsEventCategory.EnableNotifications,
event: MetaMetricsEventName.NotificationsEnablingFlowHandled,
category: MetaMetricsEventCategory.NotificationInteraction,
event: MetaMetricsEventName.NotificationMenuOpened,
properties: {
is_profile_syncing_enabled: isProfileSyncingEnabled,
is_notifications_enabled: isMetamaskNotificationsEnabled,
action_type: 'started',
},
});
trackEvent({
category: MetaMetricsEventCategory.NotificationInteraction,
event: MetaMetricsEventName.NotificationMenuOpened,
properties: {
is_profile_syncing_enabled: isProfileSyncingEnabled,
is_notifications_enabled: isMetamaskNotificationsEnabled,
},
});
dispatch(showConfirmTurnOnMetamaskNotifications());

closeMenu();
return;
}
Expand Down
22 changes: 22 additions & 0 deletions ui/pages/onboarding-flow/privacy-settings/privacy-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ export default function PrivacySettings() {
category: MetaMetricsEventCategory.Onboarding,
event: MetaMetricsEventName.OnboardingWalletAdvancedSettings,
properties: {
is_profile_syncing_enabled: profileSyncingProps.isProfileSyncingEnabled,
show_incoming_tx: incomingTransactionsPreferences,
use_phising_detection: usePhishingDetection,
turnon_token_detection: turnOnTokenDetection,
settings_group: 'advanced',
},
});

Expand All @@ -226,11 +228,31 @@ export default function PrivacySettings() {
name: 'CONFIRM_TURN_OFF_PROFILE_SYNCING',
turnOffProfileSyncing: () => {
profileSyncingProps.setIsProfileSyncingEnabled(false);
trackEvent({
category: MetaMetricsEventCategory.Onboarding,
event: MetaMetricsEventName.OnboardingWalletAdvancedSettings,
properties: {
settings_group: 'advanced',
settings_type: 'profile_syncing',
old_value: true,
new_value: false,
},
});
},
}),
);
} else {
profileSyncingProps.setIsProfileSyncingEnabled(true);
trackEvent({
category: MetaMetricsEventCategory.Onboarding,
event: MetaMetricsEventName.OnboardingWalletAdvancedSettings,
properties: {
settings_group: 'advanced',
settings_type: 'profile_syncing',
old_value: false,
new_value: true,
},
});
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import React, { useEffect } from 'react';
import React, { useContext, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { MetaMetricsContext } from '../../../../contexts/metametrics';
import {
useEnableProfileSyncing,
useDisableProfileSyncing,
useSetIsProfileSyncingEnabled,
} from '../../../../hooks/metamask-notifications/useProfileSyncing';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
} from '../../../../../shared/constants/metametrics';
import {
selectIsProfileSyncingEnabled,
selectIsProfileSyncingUpdateLoading,
Expand Down Expand Up @@ -40,6 +45,7 @@ function ProfileSyncBasicFunctionalitySetting() {
}

const ProfileSyncToggle = () => {
const trackEvent = useContext(MetaMetricsContext);
const t = useI18nContext();
const dispatch = useDispatch();
const { enableProfileSyncing, error: enableProfileSyncingError } =
Expand All @@ -63,11 +69,31 @@ const ProfileSyncToggle = () => {
name: 'CONFIRM_TURN_OFF_PROFILE_SYNCING',
turnOffProfileSyncing: () => {
disableProfileSyncing();
trackEvent({
category: MetaMetricsEventCategory.Settings,
event: MetaMetricsEventName.SettingsUpdated,
properties: {
settings_group: 'security',
settings_type: 'profile_syncing',
old_value: true,
new_value: false,
},
});
},
}),
);
} else {
await enableProfileSyncing();
trackEvent({
category: MetaMetricsEventCategory.Settings,
event: MetaMetricsEventName.SettingsUpdated,
properties: {
settings_group: 'security',
settings_type: 'profile_syncing',
old_value: false,
new_value: true,
},
});
}
};

Expand Down
Loading