Skip to content

Commit 2028321

Browse files
committed
Fixes
1 parent af78978 commit 2028321

File tree

4 files changed

+7
-18
lines changed

4 files changed

+7
-18
lines changed

Sources/Swift/Core/MetricKit/SentryMXCallStackTree.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Foundation
77
struct SentryMXCallStackTree: Decodable {
88

99
let callStacks: [SentryMXCallStack]
10-
public let callStackPerThread: Bool
10+
let callStackPerThread: Bool
1111

1212
static func from(data: Data) throws -> SentryMXCallStackTree {
1313
return try JSONDecoder().decode(SentryMXCallStackTree.self, from: data)

Sources/Swift/Core/MetricKit/SentryMetricKitIntegration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private let hangDiagnosticMechanism = "mx_hang_diagnostic"
7373
@available(macOS 12.0, *)
7474
extension SentryMetricKitIntegration: SentryMXManagerDelegate {
7575
func didReceiveCrashDiagnostic(_ diagnostic: MXCrashDiagnostic, callStackTree: SentryMXCallStackTree, timeStampBegin: Date) {
76-
let exceptionValue = "MachException Type:\(diagnostic.exceptionType ?? 0) Code:\(diagnostic.exceptionCode ?? 0) Signal:\(diagnostic.signal ?? 0)"
76+
let exceptionValue = "MachException Type:\(String(describing: diagnostic.exceptionType)) Code:\(String(describing: diagnostic.exceptionCode)) Signal:\(String(describing: diagnostic.signal))"
7777
let event = Self.createEvent(handled: false, level: .error, exceptionValue: exceptionValue, exceptionType: "MXCrashDiagnostic", exceptionMechanism: crashMechanism, timeStampBegin: timeStampBegin)
7878
capture(event: event, handled: false, callStackTree: callStackTree, diagnosticJSON: diagnostic.jsonRepresentation())
7979
}
@@ -104,7 +104,7 @@ extension SentryMetricKitIntegration: SentryMXManagerDelegate {
104104

105105
extension Event {
106106
@objc
107-
public func isMetricKitEvent() -> Bool {
107+
@_spi(Private) public func isMetricKitEvent() -> Bool {
108108
guard let mechanism = exceptions?.first?.mechanism, exceptions?.count == 1 else {
109109
return false
110110
}

Tests/SentryTests/Integrations/MetricKit/SentryMetricKitEventTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@_spi(Private) import Sentry
12
import XCTest
23

34
#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst)
@@ -9,7 +10,7 @@ final class SentryMetricKitEventTests: XCTestCase {
910
}
1011

1112
func testMXDiskWriteException_IsMetricKitEvent() {
12-
XCTAssertTrue(createMetricKitEventWith(mechanismType: "mx_cpu_exception").isMetricKitEvent())
13+
XCTAssertTrue(createMetricKitEventWith(mechanismType: "mx_disk_write_exception").isMetricKitEvent())
1314
}
1415

1516
func testMXHangDiagnostic_IsMetricKitEvent() {

Tests/SentryTests/Integrations/MetricKit/SentryMetricKitIntegrationTests.swift

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ final class SentryMetricKitIntegrationTests: SentrySDKIntegrationTestsBase {
5555
let sut = SentryMetricKitIntegration(with: options, dependencies: ())
5656
sut?.uninstall()
5757

58-
XCTAssertNil((Dynamic(sut).metricKitManager as SentryMXManager?)?.delegate)
58+
XCTAssertNil((Dynamic(sut).mxManager as SentryMXManager?)?.delegate)
5959
}
6060

6161
func testMXCrashPayloadReceived() throws {
@@ -67,7 +67,7 @@ final class SentryMetricKitIntegrationTests: SentrySDKIntegrationTestsBase {
6767

6868
sut.didReceiveCrashDiagnostic(MXCrashDiagnostic(), callStackTree: callStackTreePerThread, timeStampBegin: timeStampBegin)
6969

70-
try assertPerThread(exceptionType: "MXCrashDiagnostic", exceptionValue: "MachException Type:(null) Code:(null) Signal:(null)", exceptionMechanism: "MXCrashDiagnostic", handled: false)
70+
try assertPerThread(exceptionType: "MXCrashDiagnostic", exceptionValue: "MachException Type:nil Code:nil Signal:nil", exceptionMechanism: "MXCrashDiagnostic", handled: false)
7171
}
7272

7373
func testAttachDiagnosticAsAttachment() throws {
@@ -124,18 +124,6 @@ final class SentryMetricKitIntegrationTests: SentrySDKIntegrationTestsBase {
124124
}
125125
}
126126

127-
func testCPUExceptionDiagnostic_PerThread() throws {
128-
givenSDKWithHubWithScope()
129-
130-
let options = Options()
131-
options.enableMetricKit = true
132-
let sut = try XCTUnwrap(SentryMetricKitIntegration(with: options, dependencies: ()))
133-
134-
sut.didReceiveCpuExceptionDiagnostic(TestMXCPUExceptionDiagnostic(), callStackTree: callStackTreePerThread, timeStampBegin: timeStampBegin)
135-
136-
assertNothingCaptured()
137-
}
138-
139127
func testCPUExceptionDiagnostic_NotPerThread() throws {
140128
givenSDKWithHubWithScope()
141129

0 commit comments

Comments
 (0)