diff --git a/Packages/PushNotifications/Sources/PushNotifications/PushManager.swift b/Packages/PushNotifications/Sources/PushNotifications/PushManager.swift index 58e61bff..437c836d 100644 --- a/Packages/PushNotifications/Sources/PushNotifications/PushManager.swift +++ b/Packages/PushNotifications/Sources/PushNotifications/PushManager.swift @@ -7,9 +7,6 @@ import Foundation import OSLog -#if canImport(Sentry) -import Sentry -#endif import Pachyderm import UserAccounts @@ -18,6 +15,9 @@ public struct PushManager { public static let shared = createPushManager() public static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "PushManager") + + @MainActor + public static var captureError: ((any Error) -> Void)? private init() {} diff --git a/Packages/PushNotifications/Sources/PushNotifications/PushManagerImpl.swift b/Packages/PushNotifications/Sources/PushNotifications/PushManagerImpl.swift index bdc138f3..20b5f74b 100644 --- a/Packages/PushNotifications/Sources/PushNotifications/PushManagerImpl.swift +++ b/Packages/PushNotifications/Sources/PushNotifications/PushManagerImpl.swift @@ -7,9 +7,6 @@ import UIKit import UserAccounts -#if canImport(Sentry) -import Sentry -#endif import CryptoKit class PushManagerImpl: _PushManager { @@ -150,9 +147,7 @@ class PushManagerImpl: _PushManager { } } catch { PushManager.logger.error("Failed to update push registration: \(String(describing: error), privacy: .public)") - #if canImport(Sentry) - SentrySDK.capture(error: error) - #endif + PushManager.captureError?(error) } } diff --git a/Tusker/AppDelegate.swift b/Tusker/AppDelegate.swift index 6a7cc075..bd2f3e95 100644 --- a/Tusker/AppDelegate.swift +++ b/Tusker/AppDelegate.swift @@ -85,6 +85,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { BackgroundManager.shared.registerHandlers() Task { + PushManager.captureError = { SentrySDK.capture(error: $0) } await PushManager.shared.updateIfNecessary() }