diff --git a/WireDomain/Sources/WireDomain/Notifications/GenerateNotificationUseCase.swift b/WireDomain/Sources/WireDomain/Notifications/GenerateNotificationUseCase.swift index 339cae09f39..6e2bf6a6df0 100644 --- a/WireDomain/Sources/WireDomain/Notifications/GenerateNotificationUseCase.swift +++ b/WireDomain/Sources/WireDomain/Notifications/GenerateNotificationUseCase.swift @@ -56,14 +56,14 @@ struct GenerateNotificationUseCase: GenerateNotificationUseCaseProtocol { for await events in updateEvents { logger.info( "Processing \(events.count) pending events...", - attributes: .newNSE + attributes: .newNSE, .safePublic ) for event in events { if let notification = await generateNotification(for: event) { logger.info( "Generated a notification from an event", - attributes: .newNSE + attributes: .newNSE, .safePublic ) notifications.append(notification) } @@ -83,7 +83,7 @@ struct GenerateNotificationUseCase: GenerateNotificationUseCaseProtocol { event: conversationEvent ) } catch { - var attributes = LogAttributes.newNSE + var attributes = LogAttributes.newNSE + .safePublic attributes[.eventId] = eventID.safeForLoggingDescription logger.error( diff --git a/WireDomain/Sources/WireDomain/Notifications/NotificationServiceExtension.swift b/WireDomain/Sources/WireDomain/Notifications/NotificationServiceExtension.swift index d86e19b307f..df344388f99 100644 --- a/WireDomain/Sources/WireDomain/Notifications/NotificationServiceExtension.swift +++ b/WireDomain/Sources/WireDomain/Notifications/NotificationServiceExtension.swift @@ -62,7 +62,7 @@ public final class NotificationServiceExtension: NotificationServiceProtocol { self.minTLSVersion = minTLSVersion self.preferredAPIVersion = preferredAPIVersion registerProviderFactories() - logger.info("initializing new notification service", attributes: .newNSE) + logger.info("initializing new notification service", attributes: .newNSE, .safePublic) } // MARK: - Notifications @@ -75,7 +75,7 @@ public final class NotificationServiceExtension: NotificationServiceProtocol { if onGoingTask != nil { logger.warn( "onGoingtask not null: a notification is already being processed", - attributes: .newNSE + attributes: .newNSE, .safePublic ) } @@ -90,6 +90,7 @@ public final class NotificationServiceExtension: NotificationServiceProtocol { } catch { // With the "filtering" entitlement, we can tell iOS to not display a user notification by passing empty // content to the content handler. See https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_usernotifications_filtering + logger.warn("onGoingtask got cancelled: showing no notifications", attributes: .newNSE, .safePublic) return notificationContentHandler(.emptyNotification) } @@ -131,7 +132,7 @@ public final class NotificationServiceExtension: NotificationServiceProtocol { } public func serviceExtensionTimeWillExpire() { - logger.warn("new notification service will expire", attributes: .newNSE) + logger.warn("new notification service will expire", attributes: .newNSE, .safePublic) onGoingTask?.cancel() } } @@ -182,7 +183,7 @@ extension NotificationServiceExtension { ) case let .unableToLoadStores(loadStoresError): logger.error( - "Loading coreDataStack with error: \(loadStoresError.localizedDescription)", + "Loading coreDataStack with error: \(String(describing: loadStoresError))", attributes: .newNSE, .safePublic ) } @@ -192,8 +193,8 @@ extension NotificationServiceExtension { switch error { case let .unableToPullPendingEvents(error): logger.error( - "Could not pull pending events: \(error.localizedDescription)", - attributes: .newNSE + "Could not pull pending events: \(String(describing: error))", + attributes: .newNSE, .safePublic ) } } @@ -270,7 +271,7 @@ extension NotificationServiceExtension { private func logDefaultError(_ error: any Error) { logger.error( - "Unable to create a session: \(error.localizedDescription)", + "Unable to create a session: \(String(describing: error))", attributes: .newNSE, .safePublic ) } diff --git a/WireDomain/Sources/WireDomain/Notifications/PullEventsUseCase.swift b/WireDomain/Sources/WireDomain/Notifications/PullEventsUseCase.swift index 4fd5d2d6b8d..1916c86f875 100644 --- a/WireDomain/Sources/WireDomain/Notifications/PullEventsUseCase.swift +++ b/WireDomain/Sources/WireDomain/Notifications/PullEventsUseCase.swift @@ -43,7 +43,7 @@ struct PullEventsUseCase: PullEventsUseCaseProtocol { func invoke() async throws -> AsyncStream<[UpdateEvent]> { logger.info( "Attempting to fetch pending events", - attributes: .newNSE + attributes: .newNSE, .safePublic ) do { diff --git a/WireDomain/Sources/WireDomain/Notifications/ShowNotificationUseCase.swift b/WireDomain/Sources/WireDomain/Notifications/ShowNotificationUseCase.swift index 37d172b06d6..a42796db53c 100644 --- a/WireDomain/Sources/WireDomain/Notifications/ShowNotificationUseCase.swift +++ b/WireDomain/Sources/WireDomain/Notifications/ShowNotificationUseCase.swift @@ -64,14 +64,14 @@ struct ShowNotificationUseCase: ShowNotificationUseCaseProtocol { WireLogger.calling.info( "Detected a call event", - attributes: .newNSE + attributes: .newNSE, .safePublic ) try await CXProvider.reportNewIncomingVoIPPushPayload(callKitContent) } catch { WireLogger.calling.error( - "failed to wake up main app: \(error.localizedDescription)", - attributes: .newNSE + "failed to wake up main app: \(String(describing: error))", + attributes: .newNSE, .safePublic ) } } @@ -102,7 +102,7 @@ struct ShowNotificationUseCase: ShowNotificationUseCaseProtocol { WireLogger.notifications.info( "Showing notification to the user", - attributes: .newNSE + attributes: .newNSE, .safePublic ) // Displays the notification to the user diff --git a/WireNetwork/Sources/WireNetwork/Authentication/AuthenticationManager.swift b/WireNetwork/Sources/WireNetwork/Authentication/AuthenticationManager.swift index 7e78aed1e49..02b5bf2a75c 100644 --- a/WireNetwork/Sources/WireNetwork/Authentication/AuthenticationManager.swift +++ b/WireNetwork/Sources/WireNetwork/Authentication/AuthenticationManager.swift @@ -113,7 +113,7 @@ public actor AuthenticationManager: AuthenticationManagerProtocol { return newToken } catch { WireLogger.authentication.error( - "Failed to renew access token with error: \(error.localizedDescription)" + "Failed to renew access token with error: \(String(describing: error))", attributes: .safePublic ) currentToken = nil @@ -124,6 +124,10 @@ public actor AuthenticationManager: AuthenticationManagerProtocol { case .invalidCredentials: // can't recover, deleting cookies and logging out try await cookieStorage.removeCookies() + WireLogger.authentication.info( + "Removed cookies (invalidCredentials)", attributes: .safePublic + ) + onAuthenticationFailure() } diff --git a/wire-ios-request-strategy/Sources/Notifications/Push Notifications/Notification Types/Content/ZMLocalNotification+Events.swift b/wire-ios-request-strategy/Sources/Notifications/Push Notifications/Notification Types/Content/ZMLocalNotification+Events.swift index ea160a5cd36..00eb0970a62 100644 --- a/wire-ios-request-strategy/Sources/Notifications/Push Notifications/Notification Types/Content/ZMLocalNotification+Events.swift +++ b/wire-ios-request-strategy/Sources/Notifications/Push Notifications/Notification Types/Content/ZMLocalNotification+Events.swift @@ -342,7 +342,8 @@ private class NewMessageNotificationBuilder: EventNotificationBuilder { conversation.isMessageSilenced(message, senderID: senderUUID) { WireLogger.push .info( - "Not creating local notification for message with nonce = \(event.messageNonce?.safeForLoggingDescription) because conversation is silenced" + "Not creating local notification for message with nonce = \(event.messageNonce?.safeForLoggingDescription) because conversation is silenced", + attributes: .safePublic ) return false } else if conversation == nil { diff --git a/wire-ios-sync-engine/Source/SessionManager/PushTokenService.swift b/wire-ios-sync-engine/Source/SessionManager/PushTokenService.swift index 49f928d3483..b833844e442 100644 --- a/wire-ios-sync-engine/Source/SessionManager/PushTokenService.swift +++ b/wire-ios-sync-engine/Source/SessionManager/PushTokenService.swift @@ -39,6 +39,9 @@ public final class PushTokenService: PushTokenServiceInterface { // MARK: - Methods public func storeLocalToken(_ token: PushToken?) { + if PushTokenStorage.pushToken != nil, token != PushTokenStorage.pushToken { + WireLogger.push.info("updating token \(token == nil ? "to nil" : "")", attributes: .safePublic) + } PushTokenStorage.pushToken = token onTokenChange?(token) } diff --git a/wire-ios-sync-engine/Source/SessionManager/SessionManager+PushToken.swift b/wire-ios-sync-engine/Source/SessionManager/SessionManager+PushToken.swift index 94a07def0fd..5cd216c7181 100644 --- a/wire-ios-sync-engine/Source/SessionManager/SessionManager+PushToken.swift +++ b/wire-ios-sync-engine/Source/SessionManager/SessionManager+PushToken.swift @@ -59,7 +59,7 @@ extension SessionManager { WireLogger.push.info("syncLocalTokenWithRemote") guard let clientID = session.selfUserClient?.remoteIdentifier else { - WireLogger.push.info("syncLocalTokenWithRemote: failed: no self client id") + WireLogger.push.info("syncLocalTokenWithRemote: failed: no self client id", attributes: .safePublic) return } @@ -72,11 +72,14 @@ extension SessionManager { in: notificationContext ) - WireLogger.push.info("syncLocalTokenWithRemote: success") + WireLogger.push.info("syncLocalTokenWithRemote: success", attributes: .safePublic) } catch { WireLogger.push - .error("syncLocalTokenWithRemote: failed: pushTokenService failed: \(error.localizedDescription)") + .error( + "syncLocalTokenWithRemote: failed: pushTokenService failed: \(String(describing: error))", + attributes: .safePublic + ) } session.syncManagedObjectContext.leaveAllGroups(groups) } diff --git a/wire-ios/Wire-iOS/Sources/UserInterface/PermissionDeniedHint/NotificationAuthorizationStatusDeniedUseCases/ShouldPresentNotificationPermissionHintUseCase.swift b/wire-ios/Wire-iOS/Sources/UserInterface/PermissionDeniedHint/NotificationAuthorizationStatusDeniedUseCases/ShouldPresentNotificationPermissionHintUseCase.swift index 0b0f7e8d181..7c88e90a136 100644 --- a/wire-ios/Wire-iOS/Sources/UserInterface/PermissionDeniedHint/NotificationAuthorizationStatusDeniedUseCases/ShouldPresentNotificationPermissionHintUseCase.swift +++ b/wire-ios/Wire-iOS/Sources/UserInterface/PermissionDeniedHint/NotificationAuthorizationStatusDeniedUseCases/ShouldPresentNotificationPermissionHintUseCase.swift @@ -18,6 +18,7 @@ import UserNotifications import WireFoundation +import WireLogging import WireUtilities struct ShouldPresentNotificationPermissionHintUseCase< @@ -33,8 +34,16 @@ struct ShouldPresentNotificationPermissionHintUseCase< // show hint only if `authorizationStatus` is `.denied` let notificationSettings = await userNotificationCenter.notificationSettings() - guard notificationSettings.authorizationStatus == .denied else { return false } + guard notificationSettings.authorizationStatus == .denied else { + WireLogger.push.info( + "notifications authorizationStatus settings: \(notificationSettings.authorizationStatus)", + attributes: .safePublic + ) + return false + } + + WireLogger.push.info("notifications authorizationStatus settings are denied", attributes: .safePublic) let lastPresentationDate = userDefaults.value(for: .lastTimeNotificationPermissionHintWasShown) if let lastPresentationDate, lastPresentationDate > currentDateProvider.now.addingTimeInterval(-.oneDay) { // hint has already been shown within the last 24 hours