Skip to content

Commit

Permalink
feat: Marks App hang's event stacktrace snapshot as true (#2441)
Browse files Browse the repository at this point in the history
Marked App hang's event stacktrace snapshot as true
  • Loading branch information
brustolin authored Nov 24, 2022
1 parent ffa889e commit 040b8d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions Sources/Sentry/SentryANRTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]; }];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 040b8d9

Please sign in to comment.