Skip to content

Commit b909e59

Browse files
authored
Add sensible defaults for initFatalIssueReporting (#437)
1 parent 172f674 commit b909e59

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/Capture.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ object Capture {
102102
/**
103103
* Initializes fatal issue (ANR, JVM Crash, Native crash) reporting mechanism.
104104
*
105+
* @param fatalIssueMechanism the [FatalIssueMechanism] to use for crash detection
105106
* @param context an optional context reference. You should provide the context if called from a [android.content.ContentProvider]
106107
*
107108
* This should be called prior to Capture.Logger.start()
@@ -111,8 +112,8 @@ object Capture {
111112
@JvmStatic
112113
@JvmOverloads
113114
fun initFatalIssueReporting(
115+
fatalIssueMechanism: FatalIssueMechanism = FatalIssueMechanism.BuiltIn,
114116
context: Context? = null,
115-
fatalIssueMechanism: FatalIssueMechanism,
116117
) {
117118
if (context == null && !ContextHolder.isInitialized) {
118119
Log.w(LOG_TAG, "Attempted to initialize Fatal Issue Reporting with a null context. Skipping enabling crash tracking.")

platform/swift/source/Capture.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ extension Logger {
9797
/// This API is experimental and subject to change
9898
///
9999
/// - parameter type: mechanism for crash detection
100-
public static func initFatalIssueReporting(_ type: IssueReporterType = .customConfig) {
100+
public static func initFatalIssueReporting(_ type: IssueReporterType = .builtIn) {
101101
if issueReporterInitResult.0 != .notInitialized {
102102
log(level: .warning, message: "Fatal issue reporting already being initialized")
103103
return

test/platform/swift/unit_integration/core/FatalIssueReporterTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class FatalIssueReporterTests: XCTestCase {
4242
}
4343

4444
func testNoConfig() {
45-
Logger.initFatalIssueReporting()
45+
Logger.initFatalIssueReporting(.customConfig)
4646
let result = Logger.issueReporterInitResult
4747
XCTAssertEqual(IssueReporterInitState.initialized(.missingConfigFile), result.0)
4848

@@ -53,7 +53,7 @@ final class FatalIssueReporterTests: XCTestCase {
5353

5454
func testNoConfigDir() {
5555
try! FileManager.default.removeItem(at: reportDir)
56-
Logger.initFatalIssueReporting()
56+
Logger.initFatalIssueReporting(.customConfig)
5757
let result = Logger.issueReporterInitResult
5858
XCTAssertEqual(IssueReporterInitState.initialized(.missingConfigFile), result.0)
5959

@@ -64,7 +64,7 @@ final class FatalIssueReporterTests: XCTestCase {
6464

6565
func testBrokenConfig() {
6666
createConfig("some nonsense")
67-
Logger.initFatalIssueReporting()
67+
Logger.initFatalIssueReporting(.customConfig)
6868
let result = Logger.issueReporterInitResult
6969
XCTAssertEqual(IssueReporterInitState.initialized(.malformedConfigFile), result.0)
7070

@@ -79,7 +79,7 @@ final class FatalIssueReporterTests: XCTestCase {
7979
directory: "the-files/special",
8080
filename: "something.yam",
8181
contents: String(repeating: "<stuff>", count: 100))
82-
Logger.initFatalIssueReporting()
82+
Logger.initFatalIssueReporting(.customConfig)
8383
let result = Logger.issueReporterInitResult
8484
XCTAssertEqual(IssueReporterInitState.initialized(.withoutPriorCrash), result.0)
8585

@@ -97,7 +97,7 @@ final class FatalIssueReporterTests: XCTestCase {
9797
filename: "something.json",
9898
contents: initContents,
9999
attributes: [.modificationDate: modDate])
100-
Logger.initFatalIssueReporting()
100+
Logger.initFatalIssueReporting(.customConfig)
101101
let result = Logger.issueReporterInitResult
102102
XCTAssertEqual(IssueReporterInitState.initialized(.sent), result.0)
103103
XCTAssertLessThan(result.1, 50)
@@ -140,7 +140,7 @@ final class FatalIssueReporterTests: XCTestCase {
140140
filename: "old-and-ignore.json",
141141
contents: String(repeating: "<bad stuff>", count: 100),
142142
attributes: [.modificationDate: modDate - TimeInterval(200)])
143-
Logger.initFatalIssueReporting()
143+
Logger.initFatalIssueReporting(.customConfig)
144144
let result = Logger.issueReporterInitResult
145145
XCTAssertEqual(IssueReporterInitState.initialized(.sent), result.0)
146146
XCTAssertLessThan(result.1, 50)

0 commit comments

Comments
 (0)