diff --git a/CHANGELOG.md b/CHANGELOG.md index 74aed2d63e..8d80f6c631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This version adds a dependency on Swift. - Properly demangle Swift class name (#2162) + ### Fixes - Errors shortly after SentrySDK.init now affect the session (#2430) @@ -32,6 +33,7 @@ This version adds a dependency on Swift. - Remove `SentryScope.apply(to:maxBreadcrumb:)` (#2416) - Remove `- [SentryOptions initWithDict:didFailWithError:]` (#2404) - Remove `- [SentryOptions sdkInfo]` (#2404) +- Marks App hang's event stacktrace snapshot as true (#2441) ## 7.31.2 diff --git a/Sources/Sentry/SentryANRTrackingIntegration.m b/Sources/Sentry/SentryANRTrackingIntegration.m index 9b947eb567..32ccc7fa3c 100644 --- a/Sources/Sentry/SentryANRTrackingIntegration.m +++ b/Sources/Sentry/SentryANRTrackingIntegration.m @@ -10,6 +10,7 @@ #import "SentryHub+Private.h" #import "SentryMechanism.h" #import "SentrySDK+Private.h" +#import "SentryStacktrace.h" #import "SentryThread.h" #import "SentryThreadInspector.h" #import "SentryThreadWrapper.h" @@ -65,8 +66,11 @@ - (void)anrDetected SentryEvent *event = [[SentryEvent alloc] initWithLevel:kSentryLevelError]; SentryException *sentryException = [[SentryException alloc] initWithValue:message type:@"App Hanging"]; + sentryException.mechanism = [[SentryMechanism alloc] initWithType:@"AppHang"]; sentryException.stacktrace = [threads[0] stacktrace]; + sentryException.stacktrace.snapshot = @(YES); + [threads enumerateObjectsUsingBlock:^(SentryThread *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { obj.current = [NSNumber numberWithBool:idx == 0]; }]; diff --git a/Tests/SentryTests/Integrations/ANR/SentryANRTrackingIntegrationTests.swift b/Tests/SentryTests/Integrations/ANR/SentryANRTrackingIntegrationTests.swift index 15d81d40ba..30cfca7696 100644 --- a/Tests/SentryTests/Integrations/ANR/SentryANRTrackingIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/ANR/SentryANRTrackingIntegrationTests.swift @@ -81,6 +81,7 @@ class SentryANRTrackingIntegrationTests: SentrySDKIntegrationTestsBase { XCTAssertEqual(ex.value, "App hanging for at least 4500 ms.") XCTAssertNotNil(ex.stacktrace) XCTAssertEqual(ex.stacktrace?.frames.first?.function, "main") + XCTAssertTrue(ex.stacktrace?.snapshot?.boolValue ?? false) XCTAssertTrue(event?.threads?[0].current?.boolValue ?? false) guard let threads = event?.threads else {