diff --git a/AnalyticsKit.swift b/AnalyticsKit.swift index 4c90043..02a236d 100644 --- a/AnalyticsKit.swift +++ b/AnalyticsKit.swift @@ -14,7 +14,7 @@ import Foundation func logEvent(_ event: String, withProperties properties: [String: Any], timed: Bool) func endTimedEvent(_ event: String, withProperties properties: [String: Any]) func logError(_ name: String, message: String?, exception: NSException?) - func logError(_ name: String, message: String?, error: NSError?) + func logError(_ name: String, message: String?, error: Error?) } class AnalyticsKit: NSObject { @@ -104,7 +104,7 @@ class AnalyticsKit: NSObject { channel(DefaultChannel).logError(name, message: message, exception: exception) } - class func logError(_ name: String, message: String?, error: NSError?) { + class func logError(_ name: String, message: String?, error: Error?) { channel(DefaultChannel).logError(name, message: message, error: error) } @@ -214,8 +214,8 @@ class AnalyticsKitChannel: NSObject, AnalyticsKitProvider { } } - func logError(_ name: String, message: String?, error: NSError?) { - AKLog("\(channelName) \(name) message: \(message ?? "nil") error: \(error?.description ?? "nil")") + func logError(_ name: String, message: String?, error: Error?) { + AKLog("\(channelName) \(name) message: \(message ?? "nil") error: \(error?.localizedDescription ?? "nil")") for provider in providers { provider.logError(name, message: message, error: error) } @@ -224,7 +224,7 @@ class AnalyticsKitChannel: NSObject, AnalyticsKitProvider { private func AKLog(_ message: String, _ file: String = #file, _ function: String = #function, _ line: Int = #line) { #if DEBUG - print("\(NSURL(string: file)?.lastPathComponent ?? "") \(function)[\(line)]: \(message)") + print("\(URL(string: file)?.lastPathComponent ?? "") \(function)[\(line)]: \(message)") #else if message == "" { // Workaround for swift compiler optimizer crash diff --git a/AnalyticsKitDebugProvider.swift b/AnalyticsKitDebugProvider.swift index d4a50eb..4ebc9e4 100644 --- a/AnalyticsKitDebugProvider.swift +++ b/AnalyticsKitDebugProvider.swift @@ -26,8 +26,8 @@ class AnalyticsKitDebugProvider: NSObject, AnalyticsKitProvider { showAlert(message) } - func logError(_ name: String, message: String?, error: NSError?) { - let message = "\(name)\n\n\(message ?? "nil")\n\n\(error?.description ?? "nil")" + func logError(_ name: String, message: String?, error: Error?) { + let message = "\(name)\n\n\(message ?? "nil")\n\n\(error?.localizedDescription ?? "nil")" showAlert(message) } diff --git a/Providers/AdjustIO/AnalyticsKitAdjustIOProvider.swift b/Providers/AdjustIO/AnalyticsKitAdjustIOProvider.swift index 9b5949b..d6f7ac8 100644 --- a/Providers/AdjustIO/AnalyticsKitAdjustIOProvider.swift +++ b/Providers/AdjustIO/AnalyticsKitAdjustIOProvider.swift @@ -60,7 +60,7 @@ class AnalyticsKitAdjustIOProvider: NSObject, AnalyticsKitProvider { } - func logError(_ name: String, message: String?, error: NSError?) { + func logError(_ name: String, message: String?, error: Error?) { } diff --git a/Providers/Crashlytics/AnalyticsKitCrashlyticsProvider.swift b/Providers/Crashlytics/AnalyticsKitCrashlyticsProvider.swift index 88dace5..561e55b 100644 --- a/Providers/Crashlytics/AnalyticsKitCrashlyticsProvider.swift +++ b/Providers/Crashlytics/AnalyticsKitCrashlyticsProvider.swift @@ -49,8 +49,8 @@ class AnalyticsKitCrashlyticsProvider: NSObject, AnalyticsKitProvider { clsLog("error: \(name) message: \(message ?? "nil") exception: \(exception?.description ?? "nil")") } - func logError(_ name: String, message: String?, error: NSError?) { - clsLog("error: \(name) message: \(message ?? "nil") error: \(error?.description ?? "nil")") + func logError(_ name: String, message: String?, error: Error?) { + clsLog("error: \(name) message: \(message ?? "nil") error: \(error?.localizedDescription ?? "nil")") } fileprivate func clsLog(_ message: String) { diff --git a/Providers/Flurry/AnalyticsKitFlurryProvider.swift b/Providers/Flurry/AnalyticsKitFlurryProvider.swift index 3b675eb..938b881 100644 --- a/Providers/Flurry/AnalyticsKitFlurryProvider.swift +++ b/Providers/Flurry/AnalyticsKitFlurryProvider.swift @@ -72,7 +72,7 @@ class AnalyticsKitFlurryProvider: NSObject, AnalyticsKitProvider { } } - func logError(_ name: String, message: String?, error: NSError?) { + func logError(_ name: String, message: String?, error: Error?) { runOnMainThread { Flurry.logError(name, message: message, error: error) } diff --git a/Providers/Flurry/AnalyticsKitWatchExtensionFlurryProvider.swift b/Providers/Flurry/AnalyticsKitWatchExtensionFlurryProvider.swift index 9be0bc7..f62e800 100644 --- a/Providers/Flurry/AnalyticsKitWatchExtensionFlurryProvider.swift +++ b/Providers/Flurry/AnalyticsKitWatchExtensionFlurryProvider.swift @@ -45,7 +45,7 @@ class AnalyticsKitWatchExtensionFlurryProvider: NSObject, AnalyticsKitProvider { } - func logError(_ name: String, message: String?, error: NSError?) { + func logError(_ name: String, message: String?, error: Error?) { } diff --git a/Providers/Google Analytics/AnalyticsKitGoogleAnalyticsProvider.swift b/Providers/Google Analytics/AnalyticsKitGoogleAnalyticsProvider.swift index c17a272..078afac 100644 --- a/Providers/Google Analytics/AnalyticsKitGoogleAnalyticsProvider.swift +++ b/Providers/Google Analytics/AnalyticsKitGoogleAnalyticsProvider.swift @@ -73,13 +73,13 @@ class AnalyticsKitGoogleAnalyticsProvider: NSObject, AnalyticsKitProvider { } func logError(_ name: String, message: String?, exception: NSException?) { - // isFatal = NO, presume here, Exeption is not fatal. + // isFatal = NO, presume here, Exception is not fatal. let dict = GAIDictionaryBuilder.createException(withDescription: message ?? "nil", withFatal: 0).build() as [NSObject: AnyObject] tracker.send(dict) } - func logError(_ name: String, message: String?, error: NSError?) { - // isFatal = NO, presume here, Exeption is not fatal. + func logError(_ name: String, message: String?, error: Error?) { + // isFatal = NO, presume here, Exception is not fatal. let dict = GAIDictionaryBuilder.createException(withDescription: message ?? "nil", withFatal: 0).build() as [NSObject: AnyObject] tracker.send(dict) } diff --git a/Providers/mParticle/AnalyticsKitMParticleProvider.swift b/Providers/mParticle/AnalyticsKitMParticleProvider.swift index cf7bcc9..fd54713 100644 --- a/Providers/mParticle/AnalyticsKitMParticleProvider.swift +++ b/Providers/mParticle/AnalyticsKitMParticleProvider.swift @@ -85,13 +85,13 @@ class AnalyticsKitMParticleProvider: NSObject, AnalyticsKitProvider { } } - func logError(_ name: String, message: String?, error: NSError?) { + func logError(_ name: String, message: String?, error: Error?) { var eventInfo = [String: Any]() if let message = message { eventInfo["message"] = message } if let error = error { - eventInfo["error"] = error.description + eventInfo["error"] = error.localizedDescription } MParticle.sharedInstance().logError(name, eventInfo: eventInfo) }