Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,11 @@ - (void)testUserWithEmptyGeo

- (void)testUserWithInvalidGeo
{
SentryUser *expected = [[SentryUser alloc] init];
[expected setUserId:@"123"];

SentryUser *actual = [RNSentry userFrom:@{ @"id" : @"123", @"geo" : @"invalid_geo_data" }
otherUserKeys:nil];

XCTAssertTrue([actual isEqualToUser:expected]);
XCTAssertEqualObjects(actual.userId, @"123");
XCTAssertNil(actual.geo);
}

@end
28 changes: 1 addition & 27 deletions packages/core/ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#import <Sentry/SentryDebugMeta.h>
#import <Sentry/SentryEvent.h>
#import <Sentry/SentryException.h>
#import <Sentry/SentryGeo.h>
#import <Sentry/SentryUser.h>

@interface SentryUser ()
Expand Down Expand Up @@ -658,32 +657,7 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
{
// we can safely ignore userDataKeys since if original JS user was null userKeys will be null
if ([userKeys isKindOfClass:NSDictionary.class]) {
NSMutableDictionary *filteredKeys = [userKeys mutableCopy];
[filteredKeys removeObjectForKey:@"geo"];
SentryUser *userInstance = [[SentryUser alloc] initWithDictionary:filteredKeys];

id geo = [userKeys valueForKey:@"geo"];
if ([geo isKindOfClass:NSDictionary.class]) {
NSDictionary *geoDict = (NSDictionary *)geo;
SentryGeo *sentryGeo = [SentryGeo alloc];

id city = [geoDict valueForKey:@"city"];
if ([city isKindOfClass:NSString.class]) {
[sentryGeo setCity:city];
}

id countryCode = [geoDict valueForKey:@"country_code"];
if ([countryCode isKindOfClass:NSString.class]) {
[sentryGeo setCountryCode:countryCode];
}

id region = [geoDict valueForKey:@"region"];
if ([region isKindOfClass:NSString.class]) {
[sentryGeo setRegion:region];
}

[userInstance setGeo:sentryGeo];
}
SentryUser *userInstance = [[SentryUser alloc] initWithDictionary:userKeys];

if ([userDataKeys isKindOfClass:NSDictionary.class]) {
[userInstance setData:userDataKeys];
Expand Down
Loading