diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 3f9b4eed..aa2cdc51 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -34,6 +34,7 @@ import { groupPath } from 'web/lib/firebase/groups' import { UNIQUE_BETTOR_BONUS_AMOUNT } from 'common/numeric-constants' import { groupBy, sum, uniq } from 'lodash' import Custom404 from 'web/pages/404' +import { track } from '@amplitude/analytics-browser' export const NOTIFICATIONS_PER_PAGE = 30 const MULTIPLE_USERS_KEY = 'multipleUsers' @@ -380,7 +381,7 @@ function IncomeNotificationItem(props: { {getReasonForShowingIncomeNotification(true)} - + @@ -421,7 +422,7 @@ function IncomeNotificationItem(props: { /> ))} {getReasonForShowingIncomeNotification(false)} {' on'} - + @@ -477,7 +478,7 @@ function NotificationGroupItem(props: {
Activity on - +
@@ -616,7 +617,22 @@ function NotificationItem(props: { highlighted && 'bg-indigo-200 hover:bg-indigo-100' )} > - + + track('Notification Clicked', { + type: 'notification item', + sourceType, + sourceUserName, + sourceUserAvatarUrl, + sourceUpdateType, + reasonText, + reason, + sourceUserUsername, + sourceText, + }) + } + > ) : ( - + )}
@@ -686,11 +702,11 @@ export const setNotificationsAsSeen = (notifications: Notification[]) => { return notifications } -function NotificationLink(props: { +function QuestionLink(props: { notification: Notification - noClick?: boolean + ignoreClick?: boolean }) { - const { notification, noClick } = props + const { notification, ignoreClick } = props const { sourceType, sourceContractTitle, @@ -699,7 +715,8 @@ function NotificationLink(props: { sourceSlug, sourceTitle, } = notification - if (noClick) + + if (ignoreClick) return ( {sourceContractTitle || sourceTitle} @@ -717,6 +734,17 @@ function NotificationLink(props: { ? `${groupPath(sourceSlug)}` : '' } + onClick={() => + track('Notification Clicked', { + type: 'question title', + sourceType, + sourceContractTitle, + sourceContractCreatorUsername, + sourceContractSlug, + sourceSlug, + sourceTitle, + }) + } > {sourceContractTitle || sourceTitle} @@ -969,6 +997,10 @@ function NotificationSettings() { newValue: notification_subscribe_types ) { if (!privateUser) return + track('In-App Notification Preferences Changed', { + newPreference: newValue, + oldPreference: privateUser.notificationPreferences, + }) toast.promise( updatePrivateUser(privateUser.id, { notificationPreferences: newValue,