@@ -99,6 +99,12 @@ BSGBreadcrumbType BreadcrumbTypeFromString(NSString *type) {
9999 return frames;
100100}
101101
102+ bool (^BSGReactNativeReportFilter)(NSDictionary *, BugsnagCrashReport *) = ^bool (NSDictionary *rawEventData,
103+ BugsnagCrashReport *_Nonnull report) {
104+ return !([report.errorClass hasPrefix: @" RCTFatalException" ]
105+ && [report.errorMessage hasPrefix: @" Unhandled JS Exception" ]);
106+ };
107+
102108@interface Bugsnag ()
103109+ (id )notifier ;
104110+ (BOOL )bugsnagStarted ;
@@ -121,10 +127,9 @@ + (void)start {
121127}
122128
123129+ (void )startWithAPIKey : (NSString *)APIKey {
124- if (APIKey.length == 0 )
125- APIKey = [[NSBundle mainBundle ] objectForInfoDictionaryKey: BSGInfoPlistKey];
126-
127- [Bugsnag startBugsnagWithApiKey: APIKey];
130+ BugsnagConfiguration *config = [BugsnagConfiguration new ];
131+ config.apiKey = APIKey;
132+ [self startWithConfiguration: config];
128133}
129134
130135+ (void )startWithConfiguration : (BugsnagConfiguration *)config {
@@ -136,6 +141,7 @@ + (void)startWithConfiguration:(BugsnagConfiguration *)config {
136141 // way to interact with the application should instead leverage startSession
137142 // manually.
138143 config.shouldAutoCaptureSessions = NO ;
144+ [config addBeforeSendBlock: BSGReactNativeReportFilter];
139145 [Bugsnag startBugsnagWithConfiguration: config];
140146}
141147
@@ -265,12 +271,6 @@ + (void)startWithConfiguration:(BugsnagConfiguration *)config {
265271 config.shouldAutoCaptureSessions = [RCTConvert BOOL: options[@" autoCaptureSessions" ]];
266272 config.automaticallyCollectBreadcrumbs = [RCTConvert BOOL: options[@" automaticallyCollectBreadcrumbs" ]];
267273
268- [config addBeforeSendBlock: ^bool (NSDictionary *_Nonnull rawEventData,
269- BugsnagCrashReport *_Nonnull report) {
270- return !([report.errorClass hasPrefix: @" RCTFatalException" ]
271- && [report.errorMessage hasPrefix: @" Unhandled JS Exception" ]);
272- }];
273-
274274 if (notifyURLPath.length > 0 ) {
275275 [config setEndpointsForNotify: notifyURLPath
276276 sessions: sessionURLPath];
@@ -284,9 +284,12 @@ + (void)startWithConfiguration:(BugsnagConfiguration *)config {
284284 withValue: codeBundleId
285285 toTabWithName: @" app" ];
286286 }
287- if ([Bugsnag bugsnagStarted ] && !config.autoNotify ) {
288- bsg_kscrash_setHandlingCrashTypes (BSG_KSCrashTypeUserReported);
289- } else if (![Bugsnag bugsnagStarted ]) {
287+ if ([Bugsnag bugsnagStarted ]) {
288+ if (!config.autoNotify ) {
289+ bsg_kscrash_setHandlingCrashTypes (BSG_KSCrashTypeUserReported);
290+ }
291+ } else {
292+ [config addBeforeSendBlock: BSGReactNativeReportFilter];
290293 [Bugsnag startBugsnagWithConfiguration: config];
291294 }
292295 [self setNotifierDetails: [RCTConvert NSString: options[@" version" ]]];
0 commit comments