Skip to content

Commit 79ea69a

Browse files
committed
Fixes #166 - Fix userId nil
1 parent 6955757 commit 79ea69a

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

ios/RNSentry.m

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ - (NSInteger)indexOfReactNativeCallFrame:(NSArray<SentryFrame *> *)frames native
119119
SentryFrame *sentryFrame = [[SentryFrame alloc] init];
120120
sentryFrame.fileName = [NSString stringWithFormat:@"app:///%@", simpleFilename];
121121
sentryFrame.function = frame[@"methodName"];
122-
sentryFrame.lineNumber = frame[@"lineNumber"];
123-
sentryFrame.columnNumber = frame[@"column"];
122+
if (nil != frame[@"lineNumber"]) {
123+
sentryFrame.lineNumber = frame[@"lineNumber"];
124+
}
125+
if (nil != frame[@"column"]) {
126+
sentryFrame.columnNumber = frame[@"column"];
127+
}
124128
sentryFrame.platform = @"javascript";
125129
[frames addObject:sentryFrame];
126130
}
@@ -330,15 +334,13 @@ - (void)swizzleCallNativeModule:(Class)class {
330334
{
331335
SentrySeverity level = [self sentrySeverityFromLevel:event[@"level"]];
332336

333-
SentryUser *user = [self createUser:event[@"user"]];
334-
335337
SentryEvent *sentryEvent = [[SentryEvent alloc] initWithLevel:level];
336338
sentryEvent.eventId = event[@"event_id"];
337339
sentryEvent.message = event[@"message"];
338340
sentryEvent.logger = event[@"logger"];
339341
sentryEvent.tags = [self sanitizeDictionary:event[@"tags"]];
340342
sentryEvent.extra = event[@"extra"];
341-
sentryEvent.user = user;
343+
sentryEvent.user = [self createUser:event[@"user"]];
342344
if (event[@"exception"]) {
343345
NSDictionary *exception = event[@"exception"][@"values"][0];
344346
NSMutableArray *frames = [NSMutableArray array];
@@ -370,10 +372,12 @@ - (SentryUser *_Nullable)createUser:(NSDictionary *_Nonnull)user {
370372
userId = [NSString stringWithFormat:@"%@", user[@"id"]];
371373
}
372374
SentryUser *sentryUser = nil;
373-
sentryUser = [[SentryUser alloc] initWithUserId:userId];
374-
sentryUser.email = [NSString stringWithFormat:@"%@", user[@"email"]];
375-
sentryUser.username = [NSString stringWithFormat:@"%@", user[@"username"]];
376-
sentryUser.extra = [RCTConvert NSDictionary:user[@"extra"]];
375+
if (nil != userId) {
376+
sentryUser = [[SentryUser alloc] initWithUserId:userId];
377+
sentryUser.email = [NSString stringWithFormat:@"%@", user[@"email"]];
378+
sentryUser.username = [NSString stringWithFormat:@"%@", user[@"username"]];
379+
sentryUser.extra = [RCTConvert NSDictionary:user[@"extra"]];
380+
}
377381
return sentryUser;
378382
}
379383

0 commit comments

Comments
 (0)