From 840b83012a5bde2877811904d8dd0ad532dd4c82 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 9 Apr 2024 11:56:22 -0400 Subject: [PATCH] Don't use Sentry in PushNotifications package --- .../Sources/PushNotifications/PushManager.swift | 6 +++--- .../Sources/PushNotifications/PushManagerImpl.swift | 7 +------ Tusker/AppDelegate.swift | 1 + 3 files changed, 5 insertions(+), 9 deletions(-) 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() }