From 889c4637adb7c1f3331b96e0065a90c2fe69de96 Mon Sep 17 00:00:00 2001 From: imvinay84 Date: Tue, 28 Mar 2023 16:14:09 +0530 Subject: [PATCH 1/2] chore: implemented notification analytics --- .../notification-messages/notification-item/index.tsx | 5 +++++ .../src/components/notification-modal/index.tsx | 3 +++ packages/extension/src/pages/notification/index.tsx | 2 ++ .../src/pages/setting/notification/index.tsx | 11 +++++++++++ 4 files changed, 21 insertions(+) diff --git a/packages/extension/src/components/notification-messages/notification-item/index.tsx b/packages/extension/src/components/notification-messages/notification-item/index.tsx index 0bd5679d9e..345a3cca67 100644 --- a/packages/extension/src/components/notification-messages/notification-item/index.tsx +++ b/packages/extension/src/components/notification-messages/notification-item/index.tsx @@ -7,6 +7,7 @@ import jazzicon from "@metamask/jazzicon"; import { markDeliveryAsClicked } from "@utils/fetch-notification"; import { useStore } from "../../../stores"; import { FormattedMessage } from "react-intl"; +import amplitude from "amplitude-js"; interface Props { elem: NotyphiNotification; onCrossClick: (deliveryId: string) => void; @@ -27,6 +28,7 @@ export const NotificationItem: FunctionComponent = ({ const handleFlag = (e: React.MouseEvent) => { e.stopPropagation(); + amplitude.getInstance().logEvent("Notification flag click", {}); if (!flag) { setFlag(true); const item = document.getElementById(delivery_id); @@ -41,6 +43,8 @@ export const NotificationItem: FunctionComponent = ({ const handleNavigateToUrl = () => { if (elem.cta_url != null) { + amplitude.getInstance().logEvent("Notification click", {}); + const localNotifications = JSON.parse( localStorage.getItem(`notifications-${accountInfo.bech32Address}`) || JSON.stringify([]) @@ -69,6 +73,7 @@ export const NotificationItem: FunctionComponent = ({ const handleRead = (e: React.MouseEvent) => { e.stopPropagation(); + amplitude.getInstance().logEvent("Notification remove click", {}); const item = document.getElementById(delivery_id); item?.classList.add(style.remove); onCrossClick(delivery_id); diff --git a/packages/extension/src/components/notification-modal/index.tsx b/packages/extension/src/components/notification-modal/index.tsx index fa4033c89b..5227923f73 100644 --- a/packages/extension/src/components/notification-modal/index.tsx +++ b/packages/extension/src/components/notification-modal/index.tsx @@ -12,6 +12,7 @@ import { NotificationSetup, NotyphiNotification } from "@notificationTypes"; import { store } from "@chatStore/index"; import { notificationsDetails, setNotifications } from "@chatStore/user-slice"; import { useSelector } from "react-redux"; +import amplitude from "amplitude-js"; interface NotificationPayload { modalType: NotificationModalType; notificationList?: NotyphiNotification[]; @@ -52,6 +53,8 @@ export const NotificationModal: FunctionComponent = () => { } else if ( notificationPayload?.modalType === NotificationModalType.notificationOff ) { + amplitude.getInstance().logEvent("Notification on", {}); + localStorage.setItem( `turnNotifications-${accountInfo.bech32Address}`, "true" diff --git a/packages/extension/src/pages/notification/index.tsx b/packages/extension/src/pages/notification/index.tsx index 1ba33fc529..c115335bb5 100644 --- a/packages/extension/src/pages/notification/index.tsx +++ b/packages/extension/src/pages/notification/index.tsx @@ -11,6 +11,7 @@ import { useStore } from "../../stores"; import { store } from "@chatStore/index"; import { Menu } from "../main/menu"; import { NotificationSetup } from "@notificationTypes"; +import amplitude from "amplitude-js"; export const NotificationPage: FunctionComponent = () => { const notificationInfo: NotificationSetup = useSelector(notificationsDetails); const history = useHistory(); @@ -23,6 +24,7 @@ export const NotificationPage: FunctionComponent = () => { }; const handleClearAll = () => { + amplitude.getInstance().logEvent("Notification clear all click", {}); localStorage.removeItem(`notifications-${accountInfo.bech32Address}`); store.dispatch(setNotifications({ allNotifications: [] })); }; diff --git a/packages/extension/src/pages/setting/notification/index.tsx b/packages/extension/src/pages/setting/notification/index.tsx index ab0fc95fb1..fa668e6018 100644 --- a/packages/extension/src/pages/setting/notification/index.tsx +++ b/packages/extension/src/pages/setting/notification/index.tsx @@ -9,6 +9,7 @@ import { NotificationSetup } from "@notificationTypes"; import { useSelector } from "react-redux"; import { useStore } from "../../../stores"; import { store } from "@chatStore/index"; +import amplitude from "amplitude-js"; export const SettingNotifications: FunctionComponent = () => { const history = useHistory(); @@ -28,10 +29,20 @@ export const SettingNotifications: FunctionComponent = () => { const orgSuffix = orgInfo.length > 1 ? "s" : ""; const handleOnChange = () => { + amplitude + .getInstance() + .logEvent( + notificationInfo.isNotificationOn + ? "Notification off" + : "Notification on", + {} + ); + localStorage.setItem( `turnNotifications-${accountInfo.bech32Address}`, notificationInfo.isNotificationOn ? "false" : "true" ); + /// Updating the notification status in redux store.dispatch( setNotifications({ From 429b7ac4e6c077be293c2eacd1edb460dfe8ac88 Mon Sep 17 00:00:00 2001 From: Pratap Mahey Date: Wed, 29 Mar 2023 14:02:18 +0530 Subject: [PATCH 2/2] chore: update get fet url --- packages/extension/src/pages/main/asset.tsx | 2 +- packages/extension/src/pages/main/deposit.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/extension/src/pages/main/asset.tsx b/packages/extension/src/pages/main/asset.tsx index 8bd205c270..88cd500822 100644 --- a/packages/extension/src/pages/main/asset.tsx +++ b/packages/extension/src/pages/main/asset.tsx @@ -135,7 +135,7 @@ const EmptyState = ({ {chainId == "fetchhub-4" && ( {