@@ -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