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

chore: implemented notification analytics #232

Merged
merged 2 commits into from
Mar 29, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,7 @@ export const NotificationItem: FunctionComponent<Props> = ({

const handleFlag = (e: React.MouseEvent<HTMLElement>) => {
e.stopPropagation();
amplitude.getInstance().logEvent("Notification flag click", {});
if (!flag) {
setFlag(true);
const item = document.getElementById(delivery_id);
Expand All @@ -41,6 +43,8 @@ export const NotificationItem: FunctionComponent<Props> = ({

const handleNavigateToUrl = () => {
if (elem.cta_url != null) {
amplitude.getInstance().logEvent("Notification click", {});

const localNotifications = JSON.parse(
localStorage.getItem(`notifications-${accountInfo.bech32Address}`) ||
JSON.stringify([])
Expand Down Expand Up @@ -69,6 +73,7 @@ export const NotificationItem: FunctionComponent<Props> = ({

const handleRead = (e: React.MouseEvent<HTMLElement>) => {
e.stopPropagation();
amplitude.getInstance().logEvent("Notification remove click", {});
const item = document.getElementById(delivery_id);
item?.classList.add(style.remove);
onCrossClick(delivery_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/pages/main/asset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const EmptyState = ({
</button>
{chainId == "fetchhub-4" && (
<a
href={"https://indacoin.io/buy-fetch.ai-with-card"}
href={"https://fetch.ai/get-fet/"}
target="_blank"
rel="noopener noreferrer"
className={styleAsset.buyButton}
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/pages/main/deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const DepositView: FunctionComponent = observer(() => {
</div>
<div style={{ flex: 1 }} />
<a
href={"https://indacoin.io/buy-fetch.ai-with-card"}
href={"https://fetch.ai/get-fet/"}
target="_blank"
rel="noopener noreferrer"
>
Expand Down
2 changes: 2 additions & 0 deletions packages/extension/src/pages/notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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: [] }));
};
Expand Down
11 changes: 11 additions & 0 deletions packages/extension/src/pages/setting/notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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({
Expand Down