about summary refs log tree commit diff
path: root/src/lib/hooks/useNotificationHandler.ts
diff options
context:
space:
mode:
authorhailey <me@haileyok.com>2025-05-19 09:33:55 -0700
committerGitHub <noreply@github.com>2025-05-19 09:33:55 -0700
commit4ef7a6b64cdc9e8cb02975a2d14fa5406626756c (patch)
treea6e7a8ad42eca798f17ba645c17976506bc32218 /src/lib/hooks/useNotificationHandler.ts
parentf3bc962494e55de8a4fa6805db73c081a07b47d4 (diff)
downloadvoidsky-4ef7a6b64cdc9e8cb02975a2d14fa5406626756c.tar.zst
add reason to log (#8381)
Diffstat (limited to 'src/lib/hooks/useNotificationHandler.ts')
-rw-r--r--src/lib/hooks/useNotificationHandler.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/hooks/useNotificationHandler.ts b/src/lib/hooks/useNotificationHandler.ts
index 9c9522aa5..9ddad7a16 100644
--- a/src/lib/hooks/useNotificationHandler.ts
+++ b/src/lib/hooks/useNotificationHandler.ts
@@ -5,7 +5,6 @@ import {useQueryClient} from '@tanstack/react-query'
 
 import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher'
 import {type NavigationProp} from '#/lib/routes/types'
-import {logEvent} from '#/lib/statsig/statsig'
 import {Logger} from '#/logger'
 import {isAndroid} from '#/platform/detection'
 import {useCurrentConvoId} from '#/state/messages/current-convo-id'
@@ -17,7 +16,7 @@ import {useLoggedOutViewControls} from '#/state/shell/logged-out'
 import {useCloseAllActiveElements} from '#/state/util'
 import {resetToTab} from '#/Navigation'
 
-type NotificationReason =
+export type NotificationReason =
   | 'like'
   | 'repost'
   | 'follow'
@@ -229,15 +228,18 @@ export function useNotificationsHandler() {
           'type' in e.notification.request.trigger &&
           e.notification.request.trigger.type === 'push'
         ) {
+          const payload = e.notification.request.trigger
+            .payload as NotificationPayload
+
           logger.debug(
             'User pressed a notification, opening notifications tab',
             {},
           )
-          logEvent('notifications:openApp', {})
+          logger.metric('notifications:openApp', {reason: payload.reason})
+
           invalidateCachedUnreadPage()
-          const payload = e.notification.request.trigger
-            .payload as NotificationPayload
           truncateAndInvalidate(queryClient, RQKEY_NOTIFS('all'))
+
           if (
             payload.reason === 'mention' ||
             payload.reason === 'quote' ||
@@ -245,10 +247,12 @@ export function useNotificationsHandler() {
           ) {
             truncateAndInvalidate(queryClient, RQKEY_NOTIFS('mentions'))
           }
+
           logger.debug('Notifications: handleNotification', {
             content: e.notification.request.content,
             payload: e.notification.request.trigger.payload,
           })
+
           handleNotification(payload)
           Notifications.dismissAllNotificationsAsync()
         }