diff --git a/Projects/App/Project.swift b/Projects/App/Project.swift index fbf937ed..4aec0d69 100644 --- a/Projects/App/Project.swift +++ b/Projects/App/Project.swift @@ -28,7 +28,7 @@ let project = Project.makeModule( "UILaunchStoryboardName": "LaunchScreen", "BGTaskSchedulerPermittedIdentifiers": "com.oksusu.susu.app", "CFBundleShortVersionString": "1.0.5", - "CFBundleVersion": "2024092531", + "CFBundleVersion": "2024092632", "UIUserInterfaceStyle": "Light", "ITSAppUsesNonExemptEncryption": "No", "AppstoreAPPID": "6503701515", diff --git a/Projects/Feature/SSErrorHandler/Project.swift b/Projects/Feature/SSErrorHandler/Project.swift index 378a0580..5d911f98 100644 --- a/Projects/Feature/SSErrorHandler/Project.swift +++ b/Projects/Feature/SSErrorHandler/Project.swift @@ -6,9 +6,10 @@ let project = Project.makeModule( name: "SSErrorHandler", targets: .feature( .sSErrorHandler, + product: .framework, testingOptions: [], dependencies: [ - .core(.sSNotification), + .core(.coreLayers), ], testDependencies: [], infoPlist: ["DISCORD_WEB_HOOK_URL": "$(DISCORD_WEB_HOOK_URL"] diff --git a/Projects/Feature/SSErrorHandler/Sources/DiscordErrorHandler.swift b/Projects/Feature/SSErrorHandler/Sources/DiscordErrorHandler.swift index 3b8cc245..b3955865 100644 --- a/Projects/Feature/SSErrorHandler/Sources/DiscordErrorHandler.swift +++ b/Projects/Feature/SSErrorHandler/Sources/DiscordErrorHandler.swift @@ -41,7 +41,7 @@ public final class DiscordErrorHandler { os_log("Discord Web Hook URL이 잘못되었습니다. 확인해주세요") return } - let messages = message.splitByLength(1500) + let messages = message.splitByLength(1800) Task { do { diff --git a/Projects/Feature/SSErrorHandler/Sources/FireBaseErrorHandler.swift b/Projects/Feature/SSErrorHandler/Sources/FireBaseErrorHandler.swift new file mode 100644 index 00000000..6e289e74 --- /dev/null +++ b/Projects/Feature/SSErrorHandler/Sources/FireBaseErrorHandler.swift @@ -0,0 +1,55 @@ +// +// FireBaseErrorHandler.swift +// SSErrorHandler +// +// Created by MaraMincho on 9/26/24. +// Copyright © 2024 com.oksusu. All rights reserved. +// + +import Combine +import FirebaseAnalytics +import Foundation +import OSLog +import SSNotification + +// MARK: - FireBaseErrorHandler + +public final class FireBaseErrorHandler { + public static let shared = FireBaseErrorHandler() + var subscription: AnyCancellable? + private init() {} + + public func registerFirebaseLogSystem() { + subscription = NotificationCenter.default.publisher(for: SSNotificationName.logError) + .sink { @Sendable errorObjectOutput in + let errorObject = errorObjectOutput.object as? String + Self.sendErrorToFirebase(errorMessage: errorObject) + } + } + + public func removeDiscordLogSystem() { + subscription = nil + } + + @Sendable private static func sendErrorToFirebase(errorMessage message: String?) { + guard let message else { + return + } + Analytics.logEvent("iOS Error", parameters: ["description": message]) + } +} + +private extension String { + func splitByLength(_ length: Int) -> [String] { + var result: [String] = [] + var currentIndex = startIndex + + while currentIndex < endIndex { + let nextIndex = index(currentIndex, offsetBy: length, limitedBy: endIndex) ?? endIndex + result.append(String(self[currentIndex ..< nextIndex])) + currentIndex = nextIndex + } + + return result + } +} diff --git a/graph.png b/graph.png index 764e644a..9f47352f 100644 Binary files a/graph.png and b/graph.png differ