-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathInstabugCrashReportingBridge.m
68 lines (49 loc) · 1.86 KB
/
InstabugCrashReportingBridge.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#import "InstabugCrashReportingBridge.h"
#import "Util/IBGCrashReporting+CP.h"
@implementation InstabugCrashReportingBridge
- (dispatch_queue_t)methodQueue {
return dispatch_get_main_queue();
}
+ (BOOL)requiresMainQueueSetup
{
return NO;
}
- (NSArray<NSString *> *)supportedEvents {
return @[
@"IBGSendHandledJSCrash",
@"IBGSendUnhandledJSCrash",
];
}
RCT_EXPORT_MODULE(IBGCrashReporting)
RCT_EXPORT_METHOD(setEnabled: (BOOL) isEnabled) {
IBGCrashReporting.enabled = isEnabled;
}
RCT_EXPORT_METHOD(sendJSCrash:(NSDictionary *)stackTrace
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
dispatch_async(queue, ^{
[IBGCrashReporting cp_reportFatalCrashWithStackTrace:stackTrace];
resolve([NSNull null]);
});
}
RCT_EXPORT_METHOD(sendHandledJSCrash: (NSDictionary *)stackTrace
userAttributes:(nullable NSDictionary *)userAttributes fingerprint:(nullable NSString *)fingerprint nonFatalExceptionLevel:(IBGNonFatalLevel)nonFatalExceptionLevel
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
if([fingerprint isKindOfClass:NSNull.class]){
fingerprint = nil;
}
if([userAttributes isKindOfClass:NSNull.class]){
userAttributes = nil;
}
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]);
});
}
@synthesize description;
@synthesize hash;
@synthesize superclass;
@end