Skip to content

fix(ios): report fatal crashes with the updated api #1290

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

Merged
merged 2 commits into from
Sep 30, 2024
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
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@

### Fixed

- Fix an issue with JavaScript fatal crashes on iOS causing them to be reported as native iOS crashes instead. ([#1290](https://github.com/Instabug/Instabug-React-Native/pull/1290)).
- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)).
- Drop non-error objects reported as crashes since they don't have a stack trace ([#1279](https://github.com/Instabug/Instabug-React-Native/pull/1279)).
- Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)).

### Fixed

- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)).

## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)

### Added
Expand Down
16 changes: 16 additions & 0 deletions examples/default/ios/InstabugTests/InstabugCrashReportingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ - (void)testSetEnabled {
XCTAssertFalse(IBGCrashReporting.enabled);
}

- (void)testSendJSCrash {
NSDictionary *stackTrace = @{};

XCTestExpectation *expectation = [self expectationWithDescription:@"Expected resolve to be called."];

RCTPromiseResolveBlock resolve = ^(id result) {
[expectation fulfill];
};
RCTPromiseRejectBlock reject = ^(NSString *code, NSString *message, NSError *error) {};

[self.bridge sendJSCrash:stackTrace resolver:resolve rejecter:reject];

[self waitForExpectations:@[expectation] timeout:1];
OCMVerify([self.mCrashReporting cp_reportFatalCrashWithStackTrace:stackTrace]);
}

- (void)testSendNonFatalErrorJsonCrash {
NSDictionary<NSString *,NSString * > *jsonCrash = @{};
NSString *fingerPrint = @"fingerprint";
Expand Down
9 changes: 2 additions & 7 deletions ios/RNInstabug/InstabugCrashReportingBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ + (BOOL)requiresMainQueueSetup
RCT_EXPORT_METHOD(sendJSCrash:(NSDictionary *)stackTrace
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
dispatch_async(queue, ^{
SEL reportCrashWithStackTraceSEL = NSSelectorFromString(@"reportCrashWithStackTrace:handled:");
if ([[Instabug class] respondsToSelector:reportCrashWithStackTraceSEL]) {
[[Instabug class] performSelector:reportCrashWithStackTraceSEL withObject:stackTrace withObject:@(NO)];
}
[IBGCrashReporting cp_reportFatalCrashWithStackTrace:stackTrace];
resolve([NSNull null]);
});
}
Expand All @@ -45,8 +42,6 @@ + (BOOL)requiresMainQueueSetup
rejecter:(RCTPromiseRejectBlock)reject) {
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{


[IBGCrashReporting cp_reportNonFatalCrashWithStackTrace:stackTrace level:nonFatalExceptionLevel groupingString:fingerprint userAttributes:userAttributes];

resolve([NSNull null]);
Expand Down