add reason to log (#8381)
This commit is contained in:
@@ -5,7 +5,6 @@ import {useQueryClient} from '@tanstack/react-query'
|
|||||||
|
|
||||||
import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher'
|
import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher'
|
||||||
import {type NavigationProp} from '#/lib/routes/types'
|
import {type NavigationProp} from '#/lib/routes/types'
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
|
||||||
import {Logger} from '#/logger'
|
import {Logger} from '#/logger'
|
||||||
import {isAndroid} from '#/platform/detection'
|
import {isAndroid} from '#/platform/detection'
|
||||||
import {useCurrentConvoId} from '#/state/messages/current-convo-id'
|
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 {useCloseAllActiveElements} from '#/state/util'
|
||||||
import {resetToTab} from '#/Navigation'
|
import {resetToTab} from '#/Navigation'
|
||||||
|
|
||||||
type NotificationReason =
|
export type NotificationReason =
|
||||||
| 'like'
|
| 'like'
|
||||||
| 'repost'
|
| 'repost'
|
||||||
| 'follow'
|
| 'follow'
|
||||||
@@ -229,15 +228,18 @@ export function useNotificationsHandler() {
|
|||||||
'type' in e.notification.request.trigger &&
|
'type' in e.notification.request.trigger &&
|
||||||
e.notification.request.trigger.type === 'push'
|
e.notification.request.trigger.type === 'push'
|
||||||
) {
|
) {
|
||||||
|
const payload = e.notification.request.trigger
|
||||||
|
.payload as NotificationPayload
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'User pressed a notification, opening notifications tab',
|
'User pressed a notification, opening notifications tab',
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
logEvent('notifications:openApp', {})
|
logger.metric('notifications:openApp', {reason: payload.reason})
|
||||||
|
|
||||||
invalidateCachedUnreadPage()
|
invalidateCachedUnreadPage()
|
||||||
const payload = e.notification.request.trigger
|
|
||||||
.payload as NotificationPayload
|
|
||||||
truncateAndInvalidate(queryClient, RQKEY_NOTIFS('all'))
|
truncateAndInvalidate(queryClient, RQKEY_NOTIFS('all'))
|
||||||
|
|
||||||
if (
|
if (
|
||||||
payload.reason === 'mention' ||
|
payload.reason === 'mention' ||
|
||||||
payload.reason === 'quote' ||
|
payload.reason === 'quote' ||
|
||||||
@@ -245,10 +247,12 @@ export function useNotificationsHandler() {
|
|||||||
) {
|
) {
|
||||||
truncateAndInvalidate(queryClient, RQKEY_NOTIFS('mentions'))
|
truncateAndInvalidate(queryClient, RQKEY_NOTIFS('mentions'))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Notifications: handleNotification', {
|
logger.debug('Notifications: handleNotification', {
|
||||||
content: e.notification.request.content,
|
content: e.notification.request.content,
|
||||||
payload: e.notification.request.trigger.payload,
|
payload: e.notification.request.trigger.payload,
|
||||||
})
|
})
|
||||||
|
|
||||||
handleNotification(payload)
|
handleNotification(payload)
|
||||||
Notifications.dismissAllNotificationsAsync()
|
Notifications.dismissAllNotificationsAsync()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import {type NotificationReason} from '#/lib/hooks/useNotificationHandler'
|
||||||
import {type FeedDescriptor} from '#/state/queries/post-feed'
|
import {type FeedDescriptor} from '#/state/queries/post-feed'
|
||||||
|
|
||||||
export type MetricEvents = {
|
export type MetricEvents = {
|
||||||
@@ -23,7 +24,9 @@ export type MetricEvents = {
|
|||||||
| 'Takendown'
|
| 'Takendown'
|
||||||
scope: 'current' | 'every'
|
scope: 'current' | 'every'
|
||||||
}
|
}
|
||||||
'notifications:openApp': {}
|
'notifications:openApp': {
|
||||||
|
reason: NotificationReason
|
||||||
|
}
|
||||||
'notifications:request': {
|
'notifications:request': {
|
||||||
context: 'StartOnboarding' | 'AfterOnboarding' | 'Login' | 'Home'
|
context: 'StartOnboarding' | 'AfterOnboarding' | 'Login' | 'Home'
|
||||||
status: 'granted' | 'denied' | 'undetermined'
|
status: 'granted' | 'denied' | 'undetermined'
|
||||||
|
|||||||
Reference in New Issue
Block a user