@@ -45,13 +45,16 @@ import {
4545 resolveNotificationPreviewText ,
4646} from '$utils/notificationStyle' ;
4747import { mobileOrTablet } from '$utils/user-agent' ;
48+ import { createDebugLogger } from '$utils/debugLogger' ;
4849import { useSlidingSyncActiveRoom } from '$hooks/useSlidingSyncActiveRoom' ;
4950import { getSlidingSyncManager } from '$client/initMatrix' ;
5051import { NotificationBanner } from '$components/notification-banner' ;
5152import { useCallSignaling } from '$hooks/useCallSignaling' ;
5253import { getInboxInvitesPath } from '../pathUtils' ;
5354import { BackgroundNotifications } from './BackgroundNotifications' ;
5455
56+ const pushRelayLog = createDebugLogger ( 'push-relay' ) ;
57+
5558function 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