diff --git a/src/ios/SentryCordova.m b/src/ios/SentryCordova.m index 066ac2c..b1c6f48 100755 --- a/src/ios/SentryCordova.m +++ b/src/ios/SentryCordova.m @@ -180,19 +180,23 @@ - (void)setUser:(CDVInvokedUrlCommand *)command { NSDictionary *user = [command.arguments objectAtIndex:0]; NSDictionary *otherUserKeys = [command.arguments objectAtIndex:1]; + bool userIsNull = (nil == user || [user isEqual:[NSNull null]]); + bool otherUserKeysIsNull = + (nil == otherUserKeys || [otherUserKeys isEqual:[NSNull null]]); + [SentrySDK configureScope:^(SentryScope *_Nonnull scope) { - if (nil == user && nil == otherUserKeys) { + if (userIsNull && otherUserKeysIsNull) { [scope setUser:nil]; } else { SentryUser *userInstance = [[SentryUser alloc] init]; - if (nil != user) { + if (!userIsNull) { [userInstance setUserId:user[@"id"]]; [userInstance setEmail:user[@"email"]]; [userInstance setUsername:user[@"username"]]; } - if (nil != otherUserKeys) { + if (!otherUserKeysIsNull) { [userInstance setData:otherUserKeys]; }