Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose onCrashedLastRun #291

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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,8 @@ public protocol CrashLoggingDataProvider {
var enableAppHangTracking: Bool { get }
/// Whether HTTP client errors are captured.
var enableCaptureFailedRequests: Bool { get }

var onCrashedLastRun: ((Event) -> Void)? { get }
1Conan marked this conversation as resolved.
Show resolved Hide resolved
}

/// Default implementations of common protocol properties
Expand Down Expand Up @@ -94,4 +97,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