Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _None._

### New Features

_None._
- Exposed Sentry's `onCrashedLastRun` to `CrashLoggingDataProvider`.

### Bug Fixes

Expand Down
2 changes: 2 additions & 0 deletions Sources/Remote Logging/Crash Logging/CrashLogging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public class CrashLogging {
options.enableUserInteractionTracing = self.dataProvider.enableUserInteractionTracing
options.enableUIViewControllerTracing = self.dataProvider.enableUIViewControllerTracking
#endif

options.onCrashedLastRun = self.dataProvider.onCrashedLastRun
}

Internals.crashLogging = self
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import Sentry

#if SWIFT_PACKAGE
import AutomatticTracksModel
Expand All @@ -17,6 +18,9 @@ public protocol CrashLoggingDataProvider {
var enableAppHangTracking: Bool { get }
/// Whether HTTP client errors are captured.
var enableCaptureFailedRequests: Bool { get }

/// A closure that will run shortly after the crash logging is initialized in case a crash was detected during the previous run.
var onCrashedLastRun: ((Event) -> Void)? { get }
}

/// Default implementations of common protocol properties
Expand Down Expand Up @@ -94,4 +98,8 @@ public extension CrashLoggingDataProvider {
var errorEventsSamplingRate: Double {
return 1.0
}

var onCrashedLastRun: ((Event) -> Void)? {
return nil
}
}
6 changes: 6 additions & 0 deletions Tests/Tests/CrashLoggingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ class CrashLoggingTests: XCTestCase {
XCTAssertTrue(dataProvider.enableUserInteractionTracing)
#endif
}

func testOnCrashedLastRunDisabledByDefault() {
let dataProvider = MockCrashLoggingDataProvider()

XCTAssertNil(dataProvider.onCrashedLastRun)
}
}

/// Allow throwing Strings as error
Expand Down