Skip to content

Commit 05e1d81

Browse files
committed
feat(push): instrument decryption relay with debugLogger for Sentry forwarding
1 parent fd9a1fa commit 05e1d81

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/app/pages/client/ClientNonUIFeatures.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ import {
4545
resolveNotificationPreviewText,
4646
} from '$utils/notificationStyle';
4747
import { mobileOrTablet } from '$utils/user-agent';
48+
import { createDebugLogger } from '$utils/debugLogger';
4849
import { useSlidingSyncActiveRoom } from '$hooks/useSlidingSyncActiveRoom';
4950
import { getSlidingSyncManager } from '$client/initMatrix';
5051
import { NotificationBanner } from '$components/notification-banner';
5152
import { useCallSignaling } from '$hooks/useCallSignaling';
5253
import { getInboxInvitesPath } from '../pathUtils';
5354
import { BackgroundNotifications } from './BackgroundNotifications';
5455

56+
const pushRelayLog = createDebugLogger('push-relay');
57+
5558
function clearMediaSessionQuickly(): void {
5659
if (!('mediaSession' in navigator)) return;
5760
// iOS registers the lock screen media player as a side-effect of
@@ -639,6 +642,7 @@ function HandleDecryptPushEvent() {
639642
const { rawEvent } = data as { rawEvent: Record<string, unknown> };
640643
const eventId = rawEvent.event_id as string;
641644
const roomId = rawEvent.room_id as string;
645+
const decryptStart = performance.now();
642646

643647
try {
644648
const mxEvent = new MatrixEvent(rawEvent as any);
@@ -652,6 +656,14 @@ function HandleDecryptPushEvent() {
652656
if (room) senderName = getMemberDisplayName(room, sender) ?? senderName;
653657
}
654658

659+
const decryptMs = Math.round(performance.now() - decryptStart);
660+
const visible = document.visibilityState === 'visible';
661+
pushRelayLog.info('notification', 'Push relay decryption succeeded', {
662+
eventType: mxEvent.getType(),
663+
decryptMs,
664+
appVisible: visible,
665+
});
666+
655667
navigator.serviceWorker.controller?.postMessage({
656668
type: 'pushDecryptResult',
657669
eventId,
@@ -664,6 +676,11 @@ function HandleDecryptPushEvent() {
664676
});
665677
} catch (err) {
666678
console.warn('[app] HandleDecryptPushEvent: failed to decrypt push event', err);
679+
pushRelayLog.error(
680+
'notification',
681+
'Push relay decryption failed',
682+
err instanceof Error ? err : new Error(String(err))
683+
);
667684
navigator.serviceWorker.controller?.postMessage({
668685
type: 'pushDecryptResult',
669686
eventId,

0 commit comments

Comments
 (0)