Skip to content

Commit bd79efe

Browse files
authored
fix(usercontext): Add null check for user properties
This adds additional checks for user parameters Fixes #211
1 parent c7dc841 commit bd79efe

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ios/RNSentry.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,15 @@ - (SentryUser *_Nullable)createUser:(NSDictionary *_Nonnull)user {
391391
userId = [NSString stringWithFormat:@"%@", user[@"id"]];
392392
}
393393
SentryUser *sentryUser = [[SentryUser alloc] init];
394-
sentryUser.userId = userId;
395-
sentryUser.email = [NSString stringWithFormat:@"%@", user[@"email"]];
396-
sentryUser.username = [NSString stringWithFormat:@"%@", user[@"username"]];
394+
if (nil != userId) {
395+
sentryUser.userId = userId;
396+
}
397+
if (nil != user[@"email"]) {
398+
sentryUser.email = [NSString stringWithFormat:@"%@", user[@"email"]];
399+
}
400+
if (nil != user[@"username"]) {
401+
sentryUser.username = [NSString stringWithFormat:@"%@", user[@"username"]];
402+
}
397403
sentryUser.extra = [RCTConvert NSDictionary:user[@"extra"]];
398404
return sentryUser;
399405
}

0 commit comments

Comments
 (0)