Skip to content

Commit 1a81a40

Browse files
committed
update Sentry to 6.1.3 and AppCenter to 4.1.0
1 parent 4fd42a9 commit 1a81a40

2 files changed

Lines changed: 27 additions & 35 deletions

File tree

AppCenter/AppCenterSDK+SMFLogger.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AppCenterSDK: NSObject {
3030
// MARK: - Public properties
3131

3232
static var wasInitialized : Bool {
33-
return MSAppCenter.isConfigured()
33+
return AppCenter.isConfigured
3434
}
3535

3636
// MARK: - Methods
@@ -45,14 +45,14 @@ class AppCenterSDK: NSObject {
4545
return
4646
}
4747

48-
let services = (configuration.isDistributionEnabled == true) ? [MSDistribute.self] : []
48+
let services = (configuration.isDistributionEnabled == true) ? [Distribute.self] : []
4949

50-
MSAppCenter.start(configuration.appSecret, withServices: services)
50+
AppCenter.start(withAppSecret: configuration.appSecret, services: services)
5151
}
5252

5353
/// Returns True, if and only if the Service got started and is enabled.
5454
static var isDistributionEnabled: Bool {
55-
return MSDistribute.isEnabled()
55+
return Distribute.enabled
5656
}
5757

5858
/// Will enable or disable the Distribution Feature of AppCenter
@@ -66,7 +66,7 @@ class AppCenterSDK: NSObject {
6666
///
6767
/// - Parameter enabled: Enable or Disable Distribtion
6868
static func enableDistribution(enabled: Bool = true) {
69-
MSDistribute.setEnabled(enabled)
69+
Distribute.enabled = enabled
7070
}
7171
}
7272

Sentry/SentrySDK+SMFLogger.swift

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ fileprivate struct SentryConstants {
1414
static let smfLogUploadMaxSizeDefault = 5000
1515
}
1616

17-
class SentrySDK: NSObject {
17+
class SMFSentrySDK: NSObject {
1818

1919
// MARK: - Private static properties
2020

21-
fileprivate static var shared : SentrySDK?
21+
fileprivate static var shared : SMFSentrySDK?
2222

2323
fileprivate static let isDebugBuild : Bool = {
2424
#if DEBUG
@@ -36,15 +36,15 @@ class SentrySDK: NSObject {
3636
// MARK: - Public properties
3737

3838
static var wasInitialized : Bool {
39-
return (SentrySDK.shared?.isInitialized ?? false)
39+
return (SMFSentrySDK.shared?.isInitialized ?? false)
4040
}
4141

4242
// MARK: - Initialization
4343

4444
override init() {
4545
super.init()
4646

47-
SentrySDK.shared = self
47+
SMFSentrySDK.shared = self
4848
}
4949

5050
// MARK: - Methods
@@ -53,38 +53,30 @@ class SentrySDK: NSObject {
5353
///
5454
/// - Parameters:
5555
/// - configuration: Configuration object
56-
static func setup(configuration: SentrySDK.Configuration) {
56+
static func setup(configuration: SMFSentrySDK.Configuration) {
5757
guard (self.isDebugBuild == false || configuration.enableDebug == true) else {
5858
return
5959
}
6060

61-
let instance = (self.shared ?? SentrySDK())
62-
63-
do {
64-
Client.shared = try Client(dsn: configuration.sentryDSN)
65-
Client.shared?.beforeSerializeEvent = { (event: Event) in
66-
event.environment = SentrySDK.Configuration.environment
61+
let instance = (self.shared ?? SMFSentrySDK())
6762

63+
SentrySDK.start { (options: Options) in
64+
options.dsn = configuration.sentryDSN
65+
options.debug = configuration.enableDebug
66+
options.beforeBreadcrumb = { (event: Breadcrumb?) in
6867
if
69-
(event.level != .debug),
68+
(event?.level != .debug),
7069
(configuration.enableSMFLogUpload == true),
7170
let loggerContents = Logger.logFilesContent(maxSize: configuration.smfLogUploadMaxSize) {
72-
event.message = loggerContents
71+
event?.message = loggerContents
7372
}
74-
}
7573

76-
if (configuration.enableBreadcrumbs == true) {
77-
Client.shared?.enableAutomaticBreadcrumbTracking()
74+
return event
7875
}
79-
80-
try Client.shared?.startCrashHandler()
81-
82-
instance.configuration = configuration
83-
84-
instance.isInitialized = true
85-
} catch let error {
86-
Log.Channel.Manager.sentry.error("Error initialising sentry: \(error.localizedDescription)")
8776
}
77+
78+
instance.configuration = configuration
79+
instance.isInitialized = true
8880
}
8981

9082
/// This will create a `fatalError` to crash the app.
@@ -95,7 +87,7 @@ class SentrySDK: NSObject {
9587
return
9688
}
9789

98-
Client.shared?.reportUserException("TestCrash", reason: "Only testing crashes", language: "swift", lineOfCode: "23", stackTrace: [], logAllThreads: false, terminateProgram: true)
90+
SentrySDK.crash()
9991
fatalError("This is a test crash to trigger a crash report in Sentry Dashboard")
10092
}
10193

@@ -107,7 +99,7 @@ class SentrySDK: NSObject {
10799
/// - additionalData : dictionary of key/value pairs that will apear under Additional Data in Sentry
108100
/// - includeLoggerData : if the event should also include the last part of SMFLogger
109101
/// - smfLogUploadMaxSize : The max count of characters which should be uploaded
110-
static func sendEvent(title: String, message: String, additionalData: [String: Any]? = nil, includeLoggerData: Bool = true, smfLogUploadMaxSize: Int = (SentrySDK.shared?.configuration?.smfLogUploadMaxSize ?? SentryConstants.smfLogUploadMaxSizeDefault)) {
102+
static func sendEvent(title: String, message: String, additionalData: [String: Any]? = nil, includeLoggerData: Bool = true, smfLogUploadMaxSize: Int = (SMFSentrySDK.shared?.configuration?.smfLogUploadMaxSize ?? SentryConstants.smfLogUploadMaxSizeDefault)) {
111103
let event = Event(level: .debug)
112104

113105
if (additionalData != nil) {
@@ -123,13 +115,13 @@ class SentrySDK: NSObject {
123115
fullMessage.append(loggerContents)
124116
}
125117

126-
event.message = fullMessage
118+
event.message = SentryMessage(formatted: fullMessage)
127119

128-
Client.shared?.send(event: event, completion: nil)
120+
SentrySDK.capture(event: event)
129121
}
130122
}
131123

132-
extension SentrySDK {
124+
extension SMFSentrySDK {
133125

134126
struct Configuration {
135127

@@ -177,7 +169,7 @@ extension SentrySDK {
177169
self.smfLogUploadMaxSize = smfLogUploadMaxSize
178170
}
179171

180-
static var `default`: SentrySDK.Configuration {
172+
static var `default`: SMFSentrySDK.Configuration {
181173
return Configuration()
182174
}
183175
}

0 commit comments

Comments
 (0)