88internal import CaptureLoggerBridge
99import Foundation
1010
11- @objc ( CAPIssueReporterType)
12- public enum IssueReporterTypeObjc : Int8 {
13- case builtIn
14- case customConfig
11+ /// A configuration representing the feature set enabled for Capture via Objective-C.
12+ @objc
13+ public final class CAPConfiguration : NSObject {
14+ public let sleepMode : SleepMode
15+ public let enableFatalIssueReporting : Bool
16+ public let enableURLSessionIntegration : Bool
17+
18+ /// Initializes a new instance of the Capture configuration.
19+ ///
20+ /// - parameter enableFatalIssueReporting: true if Capture should enable Fatal Issue Reporting
21+ /// - parameter enableURLSessionIntegration: true if Capture should enable Fatal Issue Reporting
22+ @objc
23+ public init ( enableFatalIssueReporting: Bool , enableURLSessionIntegration: Bool ) {
24+ self . sleepMode = . inactive
25+ self . enableFatalIssueReporting = enableFatalIssueReporting
26+ self . enableURLSessionIntegration = enableURLSessionIntegration
27+ }
28+
29+ /// Initializes a new instance of the Capture configuration.
30+ ///
31+ /// - parameter enableFatalIssueReporting: true if Capture should enable Fatal Issue Reporting
32+ /// - parameter enableURLSessionIntegration: true if Capture should enable Fatal Issue Reporting
33+ /// - parameter sleepMode: CAPSleepModeActive if Capture should initialize in minimal activity mode
34+ @objc
35+ public init ( enableFatalIssueReporting: Bool , enableURLSessionIntegration: Bool , sleepMode: SleepMode ) {
36+ self . sleepMode = sleepMode
37+ self . enableFatalIssueReporting = enableFatalIssueReporting
38+ self . enableURLSessionIntegration = enableURLSessionIntegration
39+ }
1540}
1641
1742// Make this class not available to Swift code. It should be used by Objective-c code only.
@@ -23,6 +48,84 @@ public final class LoggerObjc: NSObject {
2348 fatalError ( " init() is not available. Use static methods instead. " )
2449 }
2550
51+ /// Initializes the Capture SDK with the specified API key and session strategy.
52+ /// Calling other SDK methods has no effect unless the logger has been initialized.
53+ /// Subsequent calls to this function will have no effect.
54+ ///
55+ /// - parameter apiKey: The API key provided by bitdrift.
56+ /// - parameter sessionStrategy: A session strategy for the management of session IDs.
57+ @objc
58+ public static func start(
59+ withAPIKey apiKey: String ,
60+ sessionStrategy: SessionStrategyObjc
61+ ) {
62+ Capture . Logger
63+ . start (
64+ withAPIKey: apiKey,
65+ sessionStrategy: sessionStrategy. underlyingSessionStrategy,
66+ // swiftlint:disable:next force_unwrapping use_static_string_url_init
67+ apiURL: URL ( string: " https://api.bitdrift.io " ) !
68+ )
69+ }
70+
71+ /// Initializes the Capture SDK with the specified API key and session strategy.
72+ /// Calling other SDK methods has no effect unless the logger has been initialized.
73+ /// Subsequent calls to this function will have no effect.
74+ ///
75+ /// - parameter apiKey: The API key provided by bitdrift.
76+ /// - parameter sessionStrategy: A session strategy for the management of session IDs.
77+ /// - parameter configuration: Additional options for the Capture Logger
78+ @objc
79+ public static func start(
80+ withAPIKey apiKey: String ,
81+ sessionStrategy: SessionStrategyObjc ,
82+ configuration: CAPConfiguration
83+ ) {
84+ let config = Configuration ( sleepMode: configuration. sleepMode, enableFatalIssueReporting: configuration. enableFatalIssueReporting)
85+ let logger = Capture . Logger
86+ . start (
87+ withAPIKey: apiKey,
88+ sessionStrategy: sessionStrategy. underlyingSessionStrategy,
89+ configuration: config,
90+ // swiftlint:disable:next force_unwrapping use_static_string_url_init
91+ apiURL: URL ( string: " https://api.bitdrift.io " ) !
92+ )
93+
94+ if let logger, configuration. enableURLSessionIntegration {
95+ logger. enableIntegrations ( [ . urlSession( ) ] , disableSwizzling: false )
96+ }
97+ }
98+
99+ /// Initializes the Capture SDK with the specified API key and session strategy.
100+ /// Calling other SDK methods has no effect unless the logger has been initialized.
101+ /// Subsequent calls to this function will have no effect.
102+ ///
103+ /// - parameter apiKey: The API key provided by bitdrift.
104+ /// - parameter sessionStrategy: A session strategy for the management of session IDs.
105+ /// - parameter configuration: Additional options for the Capture Logger
106+ /// - parameter apiURL: The base URL of Capture API.
107+ @objc
108+ public static func start(
109+ withAPIKey apiKey: String ,
110+ sessionStrategy: SessionStrategyObjc ,
111+ configuration: CAPConfiguration ,
112+ // swiftlint:disable:next force_unwrapping use_static_string_url_init
113+ apiURL: URL = URL ( string: " https://api.bitdrift.io " ) !
114+ ) {
115+ let config = Configuration ( sleepMode: configuration. sleepMode, enableFatalIssueReporting: configuration. enableFatalIssueReporting)
116+ let logger = Capture . Logger
117+ . start (
118+ withAPIKey: apiKey,
119+ sessionStrategy: sessionStrategy. underlyingSessionStrategy,
120+ configuration: config,
121+ apiURL: apiURL
122+ )
123+
124+ if let logger, configuration. enableURLSessionIntegration {
125+ logger. enableIntegrations ( [ . urlSession( ) ] , disableSwizzling: false )
126+ }
127+ }
128+
26129 /// Initializes the Capture SDK with the specified API key and session strategy.
27130 /// Calling other SDK methods has no effect unless the logger has been initialized.
28131 /// Subsequent calls to this function will have no effect.
@@ -92,30 +195,6 @@ public final class LoggerObjc: NSObject {
92195 }
93196 }
94197
95- /// Initializes the issue reporting mechanism. Must be called prior to `Logger.start()`
96- /// This API is experimental and subject to change
97- /// WARNING: For now this API is not exposed to customers. If there is a request for this will open visibility again
98- @objc
99- static func initFatalIssueReporting( ) {
100- Capture . Logger. initFatalIssueReporting ( . builtIn)
101- }
102-
103- /// Initializes the issue reporting mechanism. Must be called prior to `Logger.start()`
104- /// This API is experimental and subject to change
105- ///
106- /// WARNING: For now this API is not exposed to customers. If there is a request for this will open visibility again
107- ///
108- /// - parameter type: mechanism for crash detection
109- @objc
110- static func initFatalIssueReporting( withType type: IssueReporterTypeObjc ) {
111- switch type {
112- case . builtIn:
113- Capture . Logger. initFatalIssueReporting ( . builtIn)
114- case . customConfig:
115- Capture . Logger. initFatalIssueReporting ( . customConfig)
116- }
117- }
118-
119198 /// Sets the operation mode of the logger, where activating sleep mode
120199 /// reduces activity to a minimal level
121200 ///
0 commit comments