Skip to content
This repository was archived by the owner on Sep 14, 2020. It is now read-only.

Commit 741dcca

Browse files
Merge pull request #237 from bugsnag/api-key-plist-fix
fix: ignore empty api key from react native
2 parents a437a77 + 83cf568 commit 741dcca

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

cocoa/BugsnagReactNative.m

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ + (void)startWithConfiguration:(BugsnagConfiguration *)config {
137137
RCT_EXPORT_MODULE()
138138

139139
RCT_EXPORT_METHOD(notify:(NSDictionary *)options) {
140+
if (![Bugsnag bugsnagStarted]) {
141+
return;
142+
}
143+
140144
NSString *const EXCEPTION_TYPE = @"browserjs";
141145
NSException *exception = [NSException
142146
exceptionWithName:[RCTConvert NSString:options[@"errorClass"]]
@@ -181,21 +185,33 @@ + (void)startWithConfiguration:(BugsnagConfiguration *)config {
181185
}
182186

183187
RCT_EXPORT_METHOD(setUser:(NSDictionary *)userInfo) {
188+
if (![Bugsnag bugsnagStarted]) {
189+
return;
190+
}
184191
NSString *identifier = userInfo[@"id"] ? [RCTConvert NSString:userInfo[@"id"]] : nil;
185192
NSString *name = userInfo[@"name"] ? [RCTConvert NSString:userInfo[@"name"]] : nil;
186193
NSString *email = userInfo[@"email"] ? [RCTConvert NSString:userInfo[@"email"]] : nil;
187194
[[Bugsnag configuration] setUser:identifier withName:name andEmail:email];
188195
}
189196

190197
RCT_EXPORT_METHOD(startSession) {
198+
if (![Bugsnag bugsnagStarted]) {
199+
return;
200+
}
191201
[Bugsnag startSession];
192202
}
193203

194204
RCT_EXPORT_METHOD(clearUser) {
205+
if (![Bugsnag bugsnagStarted]) {
206+
return;
207+
}
195208
[[Bugsnag configuration] setUser:nil withName:nil andEmail:nil];
196209
}
197210

198211
RCT_EXPORT_METHOD(leaveBreadcrumb:(NSDictionary *)options) {
212+
if (![Bugsnag bugsnagStarted]) {
213+
return;
214+
}
199215
[Bugsnag leaveBreadcrumbWithBlock:^(BugsnagBreadcrumb *crumb) {
200216
crumb.name = [RCTConvert NSString:options[@"name"]];
201217
crumb.type = BreadcrumbTypeFromString([RCTConvert NSString:options[@"type"]]);
@@ -215,7 +231,11 @@ + (void)startWithConfiguration:(BugsnagConfiguration *)config {
215231
NSString *appVersion = [RCTConvert NSString:options[@"appVersion"]];
216232
NSString *codeBundleId = [RCTConvert NSString:options[@"codeBundleId"]];
217233
BugsnagConfiguration* config = [Bugsnag bugsnagStarted] ? [Bugsnag configuration] : [BugsnagConfiguration new];
218-
config.apiKey = apiKey;
234+
235+
if (apiKey.length > 0) {
236+
config.apiKey = apiKey;
237+
}
238+
219239
config.releaseStage = releaseStage;
220240
config.notifyReleaseStages = notifyReleaseStages;
221241
config.autoNotify = [RCTConvert BOOL:options[@"autoNotify"]];
@@ -254,6 +274,9 @@ + (void)startWithConfiguration:(BugsnagConfiguration *)config {
254274
}
255275

256276
- (void)setNotifierDetails:(NSString *)packageVersion {
277+
if (![Bugsnag bugsnagStarted]) {
278+
return;
279+
}
257280
id notifier = [Bugsnag notifier];
258281
NSDictionary *details = [notifier valueForKey:@"details"];
259282
NSString *version;

cocoa/vendor/bugsnag-cocoa/Source/BugsnagSessionTracker.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ - (void)startNewSession:(NSDate *)date
5858
- (void)trackSession {
5959
[self.sessionStore write:self.currentSession];
6060
self.trackedFirstSession = YES;
61-
61+
6262
if (self.callback) {
6363
self.callback(self.currentSession);
6464
}

0 commit comments

Comments
 (0)