From 05e1d810a90279e85f42d5362be2f2aa1c54caa2 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Mon, 16 Mar 2026 10:16:17 -0400 Subject: [PATCH] feat(push): instrument decryption relay with debugLogger for Sentry forwarding --- src/app/pages/client/ClientNonUIFeatures.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/app/pages/client/ClientNonUIFeatures.tsx b/src/app/pages/client/ClientNonUIFeatures.tsx index c4179c1b..541545da 100644 --- a/src/app/pages/client/ClientNonUIFeatures.tsx +++ b/src/app/pages/client/ClientNonUIFeatures.tsx @@ -45,6 +45,7 @@ import { resolveNotificationPreviewText, } from '$utils/notificationStyle'; import { mobileOrTablet } from '$utils/user-agent'; +import { createDebugLogger } from '$utils/debugLogger'; import { useSlidingSyncActiveRoom } from '$hooks/useSlidingSyncActiveRoom'; import { getSlidingSyncManager } from '$client/initMatrix'; import { NotificationBanner } from '$components/notification-banner'; @@ -52,6 +53,8 @@ import { useCallSignaling } from '$hooks/useCallSignaling'; import { getInboxInvitesPath } from '../pathUtils'; import { BackgroundNotifications } from './BackgroundNotifications'; +const pushRelayLog = createDebugLogger('push-relay'); + function clearMediaSessionQuickly(): void { if (!('mediaSession' in navigator)) return; // iOS registers the lock screen media player as a side-effect of @@ -639,6 +642,7 @@ function HandleDecryptPushEvent() { const { rawEvent } = data as { rawEvent: Record }; const eventId = rawEvent.event_id as string; const roomId = rawEvent.room_id as string; + const decryptStart = performance.now(); try { const mxEvent = new MatrixEvent(rawEvent as any); @@ -652,6 +656,14 @@ function HandleDecryptPushEvent() { if (room) senderName = getMemberDisplayName(room, sender) ?? senderName; } + const decryptMs = Math.round(performance.now() - decryptStart); + const visible = document.visibilityState === 'visible'; + pushRelayLog.info('notification', 'Push relay decryption succeeded', { + eventType: mxEvent.getType(), + decryptMs, + appVisible: visible, + }); + navigator.serviceWorker.controller?.postMessage({ type: 'pushDecryptResult', eventId, @@ -664,6 +676,11 @@ function HandleDecryptPushEvent() { }); } catch (err) { console.warn('[app] HandleDecryptPushEvent: failed to decrypt push event', err); + pushRelayLog.error( + 'notification', + 'Push relay decryption failed', + err instanceof Error ? err : new Error(String(err)) + ); navigator.serviceWorker.controller?.postMessage({ type: 'pushDecryptResult', eventId,