From 5da71818806ac4ac35b4beab40371f5fdb81bba5 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 21 Feb 2023 14:11:46 +0100 Subject: [PATCH 01/21] add name to user --- Sources/Sentry/Public/SentryUser.h | 5 +++++ Sources/Sentry/SentryUser.m | 8 ++++++++ Tests/SentryTests/Protocol/SentryUserTests.swift | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/Sources/Sentry/Public/SentryUser.h b/Sources/Sentry/Public/SentryUser.h index 497d6337feb..86e8e3540a9 100644 --- a/Sources/Sentry/Public/SentryUser.h +++ b/Sources/Sentry/Public/SentryUser.h @@ -31,6 +31,11 @@ NS_SWIFT_NAME(User) */ @property (atomic, copy) NSString *_Nullable segment; +/** + * Optional: Human readable name + */ +@property (atomic, copy) NSString *_Nullable name; + /** * Optional: Additional data */ diff --git a/Sources/Sentry/SentryUser.m b/Sources/Sentry/SentryUser.m index 4b80d9653e3..3e3ee7eb6f8 100644 --- a/Sources/Sentry/SentryUser.m +++ b/Sources/Sentry/SentryUser.m @@ -30,6 +30,7 @@ - (id)copyWithZone:(nullable NSZone *)zone copy.username = self.username; copy.ipAddress = self.ipAddress; copy.segment = self.segment; + copy.name = self.name; copy.data = self.data.copy; } } @@ -47,6 +48,7 @@ - (id)copyWithZone:(nullable NSZone *)zone [serializedData setValue:self.username forKey:@"username"]; [serializedData setValue:self.ipAddress forKey:@"ip_address"]; [serializedData setValue:self.segment forKey:@"segment"]; + [serializedData setValue:self.name forKey:@"name"]; [serializedData setValue:[self.data sentry_sanitize] forKey:@"data"]; } @@ -104,6 +106,11 @@ - (BOOL)isEqualToUser:(SentryUser *)user if (self.segment != otherSegment && ![self.segment isEqualToString:otherSegment]) { return NO; } + + NSString *otherName = user.name; + if (self.name != otherName && ![self.name isEqualToString:otherName]) { + return NO; + } NSDictionary *otherUserData = user.data; if (self.data != otherUserData && ![self.data isEqualToDictionary:otherUserData]) { @@ -124,6 +131,7 @@ - (NSUInteger)hash hash = hash * 23 + [self.username hash]; hash = hash * 23 + [self.ipAddress hash]; hash = hash * 23 + [self.segment hash]; + hash = hash * 23 + [self.name hash]; hash = hash * 23 + [self.data hash]; return hash; diff --git a/Tests/SentryTests/Protocol/SentryUserTests.swift b/Tests/SentryTests/Protocol/SentryUserTests.swift index ccc1afd857e..4ec5ab14a59 100644 --- a/Tests/SentryTests/Protocol/SentryUserTests.swift +++ b/Tests/SentryTests/Protocol/SentryUserTests.swift @@ -12,6 +12,7 @@ class SentryUserTests: XCTestCase { user.username = "" user.ipAddress = "" user.segment = "" + user.name = "" user.data?.removeAll() XCTAssertEqual(TestData.user.userId, actual["id"] as? String) @@ -19,6 +20,7 @@ class SentryUserTests: XCTestCase { XCTAssertEqual(TestData.user.username, actual["username"] as? String) XCTAssertEqual(TestData.user.ipAddress, actual["ip_address"] as? String) XCTAssertEqual(TestData.user.segment, actual["segment"] as? String) + XCTAssertEqual(TestData.user.name, actual["name"] as? String) XCTAssertEqual(["some": ["data": "data", "date": TestData.timestampAs8601String]], actual["data"] as? Dictionary) } @@ -64,6 +66,7 @@ class SentryUserTests: XCTestCase { testIsNotEqual { user in user.username = "" } testIsNotEqual { user in user.ipAddress = "" } testIsNotEqual { user in user.segment = "" } + testIsNotEqual { user in user.name = "" } testIsNotEqual { user in user.data?.removeAll() } } @@ -83,6 +86,7 @@ class SentryUserTests: XCTestCase { user.username = "" user.ipAddress = "" user.segment = "" + user.name = "" user.data = [:] XCTAssertEqual(TestData.user, copiedUser) @@ -119,6 +123,7 @@ class SentryUserTests: XCTestCase { user.username = "\(i)" user.ipAddress = "\(i)" user.segment = "\(i)" + user.name = "\(i)" user.data?["\(i)"] = "\(i)" From 59ed2aead8230eca16804fd1da9dd5b3b9e928a3 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 21 Feb 2023 14:40:56 +0100 Subject: [PATCH 02/21] add geo --- Sources/Sentry/Public/SentryGeo.h | 35 ++++++ Sources/Sentry/SentryGeo.m | 103 ++++++++++++++++++ .../SentryTests/Protocol/SentryGeoTests.swift | 62 +++++++++++ Tests/SentryTests/Protocol/TestData.swift | 8 ++ 4 files changed, 208 insertions(+) create mode 100644 Sources/Sentry/Public/SentryGeo.h create mode 100644 Sources/Sentry/SentryGeo.m create mode 100644 Tests/SentryTests/Protocol/SentryGeoTests.swift diff --git a/Sources/Sentry/Public/SentryGeo.h b/Sources/Sentry/Public/SentryGeo.h new file mode 100644 index 00000000000..9ea656ce371 --- /dev/null +++ b/Sources/Sentry/Public/SentryGeo.h @@ -0,0 +1,35 @@ +#import "SentryDefines.h" +#import "SentrySerializable.h" +#import + +NS_ASSUME_NONNULL_BEGIN + +NS_SWIFT_NAME(Geo) +@interface SentryGeo : NSObject + +/** + * Optional: Human readable city name. + */ +@property (atomic, copy) NSString *_Nullable city; + +/** + * Optional: Two-letter country code (ISO 3166-1 alpha-2). + */ +@property (atomic, copy) NSString *_Nullable countryCode; + +/** + * Optional: Human readable region name or code. + */ +@property (atomic, copy) NSString *_Nullable region; + +- (instancetype)init; + +- (BOOL)isEqual:(id _Nullable)other; + +- (BOOL)isEqualToGeo:(SentryGeo *)geo; + +- (NSUInteger)hash; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/SentryGeo.m b/Sources/Sentry/SentryGeo.m new file mode 100644 index 00000000000..8135c76cc60 --- /dev/null +++ b/Sources/Sentry/SentryGeo.m @@ -0,0 +1,103 @@ +#import "SentryGeo.h" + +#import + +NS_ASSUME_NONNULL_BEGIN + +@implementation SentryGeo + +- (instancetype)init +{ + return [super init]; +} + +- (id)copyWithZone:(nullable NSZone *)zone +{ + SentryGeo *copy = [[SentryGeo allocWithZone:zone] init]; + + @synchronized(self) { + if (copy != nil) { + copy.city = self.city; + copy.countryCode = self.countryCode; + copy.region = self.region; + } + } + + return copy; +} + +- (NSDictionary *)serialize +{ + NSMutableDictionary *serializedData = [[NSMutableDictionary alloc] init]; + + @synchronized(self) { + [serializedData setValue:self.city forKey:@"city"]; + [serializedData setValue:self.countryCode forKey:@"country_code"]; + [serializedData setValue:self.region forKey:@"region"]; + } + + return serializedData; +} + +- (BOOL)isEqual:(id _Nullable)other +{ + @synchronized(self) { + if (other == self) { + return YES; + } + if (!other || ![[other class] isEqual:[self class]]) { + return NO; + } + + return [self isEqualToGeo:other]; + } +} + +- (BOOL)isEqualToGeo:(SentryGeo *)geo +{ + @synchronized(self) { + // We need to get some local copies of the properties, because they could be modified during + // the if statements + + if (self == geo) { + return YES; + } + if (geo == nil) { + return NO; + } + + NSString *otherCity = geo.city; + if (self.city != otherCity && ![self.city isEqualToString:otherCity]) { + return NO; + } + + NSString *otherCountryCode = geo.countryCode; + if (self.countryCode != otherCountryCode && ![self.countryCode isEqualToString:otherCountryCode]) { + return NO; + } + + NSString *otherRegion = geo.region; + if (self.region != otherRegion && ![self.region isEqualToString:otherRegion]) { + return NO; + } + + return YES; + } +} + +- (NSUInteger)hash +{ + @synchronized(self) { + NSUInteger hash = 17; + + hash = hash * 23 + [self.city hash]; + hash = hash * 23 + [self.countryCode hash]; + hash = hash * 23 + [self.region hash]; + + return hash; + } +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/Tests/SentryTests/Protocol/SentryGeoTests.swift b/Tests/SentryTests/Protocol/SentryGeoTests.swift new file mode 100644 index 00000000000..70fa6cab5ff --- /dev/null +++ b/Tests/SentryTests/Protocol/SentryGeoTests.swift @@ -0,0 +1,62 @@ +import XCTest + +class SentryGeoTests: XCTestCase { + func testSerializationWithAllProperties() { + let geo = TestData.geo.copy() as! Geo + let actual = geo.serialize() + + // Changing the original doesn't modify the serialized + geo.city = "" + geo.countryCode = "" + geo.region = "" + + XCTAssertEqual(TestData.geo.city, actual["city"] as? String) + XCTAssertEqual(TestData.geo.countryCode, actual["country_code"] as? String) + XCTAssertEqual(TestData.geo.region, actual["region"] as? String) + } + + func testHash() { + XCTAssertEqual(TestData.geo.hash(), TestData.geo.hash()) + + let geo2 = TestData.geo + geo2.city = "Berlin" + XCTAssertNotEqual(TestData.geo.hash(), geo2.hash()) + } + + func testIsEqualToSelf() { + XCTAssertEqual(TestData.geo, TestData.geo) + XCTAssertTrue(TestData.geo.isEqual(to: TestData.geo)) + } + + func testIsNotEqualToOtherClass() { + XCTAssertFalse(TestData.geo.isEqual(1)) + } + + func testIsEqualToCopy() { + XCTAssertEqual(TestData.geo, TestData.geo.copy() as! Geo) + } + + func testNotIsEqual() { + testIsNotEqual { geo in geo.city = "" } + testIsNotEqual { geo in geo.countryCode = "" } + testIsNotEqual { geo in geo.region = "" } + } + + func testIsNotEqual(block: (Geo) -> Void ) { + let geo = TestData.geo.copy() as! Geo + block(geo) + XCTAssertNotEqual(TestData.geo, geo) + } + + func testCopyWithZone_CopiesDeepCopy() { + let geo = TestData.geo + let copiedGeo = geo.copy() as! Geo + + // Modifying the original does not change the copy + geo.city = "" + geo.countryCode = "" + geo.region = "" + + XCTAssertEqual(TestData.geo, copiedGeo) + } +} diff --git a/Tests/SentryTests/Protocol/TestData.swift b/Tests/SentryTests/Protocol/TestData.swift index 0f522bd4b14..9af9450de4e 100644 --- a/Tests/SentryTests/Protocol/TestData.swift +++ b/Tests/SentryTests/Protocol/TestData.swift @@ -66,6 +66,14 @@ class TestData { return user } + static var geo: Geo { + let geo = Geo() + geo.city = "Vienna" + geo.countryCode = "at" + geo.region = "Vienna" + return geo + } + static var debugMeta: DebugMeta { let debugMeta = DebugMeta() debugMeta.imageAddress = "0x0000000105705000" From 7dcc3ce9e9cea3884c9e5d369de9c9bc6f587996 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 21 Feb 2023 14:59:35 +0100 Subject: [PATCH 03/21] add geo to user --- Sources/Sentry/Public/Sentry.h | 1 + Sources/Sentry/Public/SentryUser.h | 6 ++++++ Sources/Sentry/SentryUser.m | 8 ++++++++ Tests/SentryTests/Protocol/SentryUserTests.swift | 8 ++++++++ Tests/SentryTests/Protocol/TestData.swift | 2 ++ 5 files changed, 25 insertions(+) diff --git a/Sources/Sentry/Public/Sentry.h b/Sources/Sentry/Public/Sentry.h index df484339c6d..afaa72b0986 100644 --- a/Sources/Sentry/Public/Sentry.h +++ b/Sources/Sentry/Public/Sentry.h @@ -19,6 +19,7 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[]; #import "SentryEvent.h" #import "SentryException.h" #import "SentryFrame.h" +#import "SentryGeo.h" #import "SentryHttpStatusCodeRange.h" #import "SentryHub.h" #import "SentryId.h" diff --git a/Sources/Sentry/Public/SentryUser.h b/Sources/Sentry/Public/SentryUser.h index 86e8e3540a9..b746cc0d21e 100644 --- a/Sources/Sentry/Public/SentryUser.h +++ b/Sources/Sentry/Public/SentryUser.h @@ -1,5 +1,6 @@ #import "SentryDefines.h" #import "SentrySerializable.h" +#import "SentryGeo.h" NS_ASSUME_NONNULL_BEGIN @@ -36,6 +37,11 @@ NS_SWIFT_NAME(User) */ @property (atomic, copy) NSString *_Nullable name; +/** + * Optional: Geo location of user + */ +@property (nonatomic, strong) SentryGeo *_Nullable geo; + /** * Optional: Additional data */ diff --git a/Sources/Sentry/SentryUser.m b/Sources/Sentry/SentryUser.m index 3e3ee7eb6f8..e84d8fefdff 100644 --- a/Sources/Sentry/SentryUser.m +++ b/Sources/Sentry/SentryUser.m @@ -31,6 +31,7 @@ - (id)copyWithZone:(nullable NSZone *)zone copy.ipAddress = self.ipAddress; copy.segment = self.segment; copy.name = self.name; + copy.geo = self.geo; copy.data = self.data.copy; } } @@ -49,6 +50,7 @@ - (id)copyWithZone:(nullable NSZone *)zone [serializedData setValue:self.ipAddress forKey:@"ip_address"]; [serializedData setValue:self.segment forKey:@"segment"]; [serializedData setValue:self.name forKey:@"name"]; + [serializedData setValue:[self.geo serialize] forKey:@"geo"]; [serializedData setValue:[self.data sentry_sanitize] forKey:@"data"]; } @@ -111,6 +113,11 @@ - (BOOL)isEqualToUser:(SentryUser *)user if (self.name != otherName && ![self.name isEqualToString:otherName]) { return NO; } + + SentryGeo *otherGeo = user.geo; + if (self.geo != otherGeo && ![self.geo isEqualToGeo:otherGeo]) { + return NO; + } NSDictionary *otherUserData = user.data; if (self.data != otherUserData && ![self.data isEqualToDictionary:otherUserData]) { @@ -132,6 +139,7 @@ - (NSUInteger)hash hash = hash * 23 + [self.ipAddress hash]; hash = hash * 23 + [self.segment hash]; hash = hash * 23 + [self.name hash]; + hash = hash * 23 + [self.geo hash]; hash = hash * 23 + [self.data hash]; return hash; diff --git a/Tests/SentryTests/Protocol/SentryUserTests.swift b/Tests/SentryTests/Protocol/SentryUserTests.swift index 4ec5ab14a59..37e824136ac 100644 --- a/Tests/SentryTests/Protocol/SentryUserTests.swift +++ b/Tests/SentryTests/Protocol/SentryUserTests.swift @@ -13,6 +13,7 @@ class SentryUserTests: XCTestCase { user.ipAddress = "" user.segment = "" user.name = "" + user.geo = Geo() user.data?.removeAll() XCTAssertEqual(TestData.user.userId, actual["id"] as? String) @@ -21,6 +22,7 @@ class SentryUserTests: XCTestCase { XCTAssertEqual(TestData.user.ipAddress, actual["ip_address"] as? String) XCTAssertEqual(TestData.user.segment, actual["segment"] as? String) XCTAssertEqual(TestData.user.name, actual["name"] as? String) + XCTAssertEqual(TestData.user.geo, actual["geo"] as? String) XCTAssertEqual(["some": ["data": "data", "date": TestData.timestampAs8601String]], actual["data"] as? Dictionary) } @@ -67,6 +69,7 @@ class SentryUserTests: XCTestCase { testIsNotEqual { user in user.ipAddress = "" } testIsNotEqual { user in user.segment = "" } testIsNotEqual { user in user.name = "" } + testIsNotEqual { user in user.geo = Geo() } testIsNotEqual { user in user.data?.removeAll() } } @@ -87,6 +90,7 @@ class SentryUserTests: XCTestCase { user.ipAddress = "" user.segment = "" user.name = "" + user.geo = Geo() user.data = [:] XCTAssertEqual(TestData.user, copiedUser) @@ -125,6 +129,10 @@ class SentryUserTests: XCTestCase { user.segment = "\(i)" user.name = "\(i)" + let geo = Geo() + geo.city = "\(i)" + user.geo = geo + user.data?["\(i)"] = "\(i)" // Trigger hash diff --git a/Tests/SentryTests/Protocol/TestData.swift b/Tests/SentryTests/Protocol/TestData.swift index 9af9450de4e..77c221aefd1 100644 --- a/Tests/SentryTests/Protocol/TestData.swift +++ b/Tests/SentryTests/Protocol/TestData.swift @@ -61,6 +61,8 @@ class TestData { user.username = "user123" user.ipAddress = "127.0.0.1" user.segment = "segmentA" + user.name = "User" + user.geo = geo user.data = ["some": ["data": "data", "date": timestamp]] return user From 9f36ea3e700202544fc12678adbe8b4e12dd8bbc Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 21 Feb 2023 15:09:31 +0100 Subject: [PATCH 04/21] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7379434cfec..8f4f0b9bb83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Combine UIKit and SwiftUI transactions (#2681) - Add isMain thread to SentryThread (#2692) - Add `in_foreground` to App Context (#2692) +- Add `name` and `geo` to User (#2710) ### Fixes From c7de7cd0c56db725b59daab77991b9880c9971f3 Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Tue, 21 Feb 2023 14:09:51 +0000 Subject: [PATCH 05/21] Format code --- Sources/Sentry/Public/SentryUser.h | 2 +- Sources/Sentry/SentryGeo.m | 7 ++++--- Sources/Sentry/SentryUser.m | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Sources/Sentry/Public/SentryUser.h b/Sources/Sentry/Public/SentryUser.h index b746cc0d21e..886915714ee 100644 --- a/Sources/Sentry/Public/SentryUser.h +++ b/Sources/Sentry/Public/SentryUser.h @@ -1,6 +1,6 @@ #import "SentryDefines.h" -#import "SentrySerializable.h" #import "SentryGeo.h" +#import "SentrySerializable.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/SentryGeo.m b/Sources/Sentry/SentryGeo.m index 8135c76cc60..c39e7efc8f3 100644 --- a/Sources/Sentry/SentryGeo.m +++ b/Sources/Sentry/SentryGeo.m @@ -70,12 +70,13 @@ - (BOOL)isEqualToGeo:(SentryGeo *)geo if (self.city != otherCity && ![self.city isEqualToString:otherCity]) { return NO; } - + NSString *otherCountryCode = geo.countryCode; - if (self.countryCode != otherCountryCode && ![self.countryCode isEqualToString:otherCountryCode]) { + if (self.countryCode != otherCountryCode + && ![self.countryCode isEqualToString:otherCountryCode]) { return NO; } - + NSString *otherRegion = geo.region; if (self.region != otherRegion && ![self.region isEqualToString:otherRegion]) { return NO; diff --git a/Sources/Sentry/SentryUser.m b/Sources/Sentry/SentryUser.m index e84d8fefdff..5cf952f9ecd 100644 --- a/Sources/Sentry/SentryUser.m +++ b/Sources/Sentry/SentryUser.m @@ -108,12 +108,12 @@ - (BOOL)isEqualToUser:(SentryUser *)user if (self.segment != otherSegment && ![self.segment isEqualToString:otherSegment]) { return NO; } - + NSString *otherName = user.name; if (self.name != otherName && ![self.name isEqualToString:otherName]) { return NO; } - + SentryGeo *otherGeo = user.geo; if (self.geo != otherGeo && ![self.geo isEqualToGeo:otherGeo]) { return NO; From 83abdfdd1427bf729ad433b991c8831bb9e44479 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 21 Feb 2023 15:41:30 +0100 Subject: [PATCH 06/21] add files to project and fix tests --- Sentry.xcodeproj/project.pbxproj | 12 ++++++++++++ Sources/Sentry/Public/SentryUser.h | 4 +++- Tests/SentryTests/Protocol/SentryUserTests.swift | 12 ++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 83bed259a1e..e816a8fbb2e 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -684,6 +684,9 @@ 8ED2D28026A6581C00CA8329 /* NSURLProtocolSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ED2D27F26A6581C00CA8329 /* NSURLProtocolSwizzle.m */; }; 8ED3D306264DFE700049393B /* SwiftDescriptorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED3D305264DFE700049393B /* SwiftDescriptorTests.swift */; }; 8EE017A126704CD500470616 /* SentryUIViewControllerPerformanceTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EA1ED0E2669152F00E62B98 /* SentryUIViewControllerPerformanceTrackerTests.swift */; }; + 9286059529A5096600F96038 /* SentryGeo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9286059429A5096600F96038 /* SentryGeo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9286059729A5098900F96038 /* SentryGeo.m in Sources */ = {isa = PBXBuildFile; fileRef = 9286059629A5098900F96038 /* SentryGeo.m */; }; + 9286059929A50BAB00F96038 /* SentryGeoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9286059829A50BAA00F96038 /* SentryGeoTests.swift */; }; A2475E1325FB63A3007D9080 /* fishhook.h in Headers */ = {isa = PBXBuildFile; fileRef = A2475E1225FB63A3007D9080 /* fishhook.h */; }; A2475E1725FB63AF007D9080 /* SentryHook.h in Headers */ = {isa = PBXBuildFile; fileRef = A2475E1625FB63AF007D9080 /* SentryHook.h */; }; A2475E1B25FB63D7007D9080 /* SentryHook.c in Sources */ = {isa = PBXBuildFile; fileRef = A2475E1A25FB63D7007D9080 /* SentryHook.c */; }; @@ -1550,6 +1553,9 @@ 8ED2D27E26A6581C00CA8329 /* NSURLProtocolSwizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSURLProtocolSwizzle.h; sourceTree = ""; }; 8ED2D27F26A6581C00CA8329 /* NSURLProtocolSwizzle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSURLProtocolSwizzle.m; sourceTree = ""; }; 8ED3D305264DFE700049393B /* SwiftDescriptorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptorTests.swift; sourceTree = ""; }; + 9286059429A5096600F96038 /* SentryGeo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryGeo.h; path = Public/SentryGeo.h; sourceTree = ""; }; + 9286059629A5098900F96038 /* SentryGeo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryGeo.m; sourceTree = ""; }; + 9286059829A50BAA00F96038 /* SentryGeoTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SentryGeoTests.swift; sourceTree = ""; }; A2475E1225FB63A3007D9080 /* fishhook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fishhook.h; sourceTree = ""; }; A2475E1625FB63AF007D9080 /* SentryHook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentryHook.h; sourceTree = ""; }; A2475E1A25FB63D7007D9080 /* SentryHook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SentryHook.c; sourceTree = ""; }; @@ -1787,6 +1793,8 @@ 639FCF9B1EBC7F9500778193 /* SentryThread.m */, 639FCFAA1EBC811400778193 /* SentryUser.h */, 639FCFAB1EBC811400778193 /* SentryUser.m */, + 9286059429A5096600F96038 /* SentryGeo.h */, + 9286059629A5098900F96038 /* SentryGeo.m */, 63B818F71EC34639002FDF4C /* SentryDebugMeta.h */, 63B818F81EC34639002FDF4C /* SentryDebugMeta.m */, 6360850B1ED2AFE100E8599E /* SentryBreadcrumb.h */, @@ -2460,6 +2468,7 @@ 7B6D98E824C6D336005502FA /* SentrySdkInfo+Equality.m */, 7B82D54824E2A2D400EE670F /* SentryIdTests.swift */, 7B04A9AA24EA5F8D00E710B1 /* SentryUserTests.swift */, + 9286059829A50BAA00F96038 /* SentryGeoTests.swift */, 7BB42EEF24F3B7B700D7B39A /* SentrySession+Equality.h */, 7BB42EF024F3B7B700D7B39A /* SentrySession+Equality.m */, 7B0A5451252311CE00A71716 /* SentryBreadcrumbTests.swift */, @@ -3445,6 +3454,7 @@ 63FE714F20DA4C1100CDBAE8 /* NSError+SentrySimpleConstructor.h in Headers */, 7BC5B6FA290BCDE500D99477 /* SentryHttpStatusCodeRange+Private.h in Headers */, 7B04A9AF24EAC02C00E710B1 /* SentryRetryAfterHeaderParser.h in Headers */, + 9286059529A5096600F96038 /* SentryGeo.h in Headers */, 7DC83100239826280043DD9A /* SentryIntegrationProtocol.h in Headers */, 7B98D7BC25FB607300C5A389 /* SentryWatchdogTerminationTracker.h in Headers */, 7BA61CB9247BC57B00C130A8 /* SentryCrashDefaultBinaryImageProvider.h in Headers */, @@ -3837,6 +3847,7 @@ 7B98D7CF25FB650F00C5A389 /* SentryWatchdogTerminationTrackingIntegration.m in Sources */, 8E5D38DD261D4A3E000D363D /* SentryPerformanceTrackingIntegration.m in Sources */, 7B4E23C2251A2C2B00060D68 /* SentrySessionCrashedHandler.m in Sources */, + 9286059729A5098900F96038 /* SentryGeo.m in Sources */, 7B42C48227E08F4B009B58C2 /* SentryDependencyContainer.m in Sources */, 7BA61E9225F21AF80008CAA2 /* SentryLogOutput.m in Sources */, 639FCFAD1EBC811400778193 /* SentryUser.m in Sources */, @@ -3944,6 +3955,7 @@ 0A5370A128A3EC2400B2DCDE /* SentryViewHierarchyTests.swift in Sources */, D8FFE50C2703DBB400607131 /* SwizzlingCallTests.swift in Sources */, 7BFAA6E7297AA16A00E7E02E /* SentryCrashMonitor_CppException_Tests.mm in Sources */, + 9286059929A50BAB00F96038 /* SentryGeoTests.swift in Sources */, D8B76B0828081461000A58C4 /* TestSentryScreenShot.swift in Sources */, A8AFFCD22907DA7600967CD7 /* SentryHttpStatusCodeRangeTests.swift in Sources */, 7BE2C7F8257000A4003B66C7 /* SentryTestIntegration.m in Sources */, diff --git a/Sources/Sentry/Public/SentryUser.h b/Sources/Sentry/Public/SentryUser.h index b746cc0d21e..5a428fed610 100644 --- a/Sources/Sentry/Public/SentryUser.h +++ b/Sources/Sentry/Public/SentryUser.h @@ -4,6 +4,8 @@ NS_ASSUME_NONNULL_BEGIN +@class SentryGeo; + NS_SWIFT_NAME(User) @interface SentryUser : NSObject @@ -40,7 +42,7 @@ NS_SWIFT_NAME(User) /** * Optional: Geo location of user */ -@property (nonatomic, strong) SentryGeo *_Nullable geo; +@property (nonatomic, copy) SentryGeo *_Nullable geo; /** * Optional: Additional data diff --git a/Tests/SentryTests/Protocol/SentryUserTests.swift b/Tests/SentryTests/Protocol/SentryUserTests.swift index 37e824136ac..b3df2c1abfe 100644 --- a/Tests/SentryTests/Protocol/SentryUserTests.swift +++ b/Tests/SentryTests/Protocol/SentryUserTests.swift @@ -22,8 +22,12 @@ class SentryUserTests: XCTestCase { XCTAssertEqual(TestData.user.ipAddress, actual["ip_address"] as? String) XCTAssertEqual(TestData.user.segment, actual["segment"] as? String) XCTAssertEqual(TestData.user.name, actual["name"] as? String) - XCTAssertEqual(TestData.user.geo, actual["geo"] as? String) XCTAssertEqual(["some": ["data": "data", "date": TestData.timestampAs8601String]], actual["data"] as? Dictionary) + + let actualGeo = actual["geo"] as? [String: Any] + XCTAssertEqual(TestData.user.geo?.city, actualGeo?["city"] as? String) + XCTAssertEqual(TestData.user.geo?.countryCode, actualGeo?["country_code"] as? String) + XCTAssertEqual(TestData.user.geo?.region, actualGeo?["region"] as? String) } func testSerializationWithOnlyId() { @@ -129,9 +133,9 @@ class SentryUserTests: XCTestCase { user.segment = "\(i)" user.name = "\(i)" - let geo = Geo() - geo.city = "\(i)" - user.geo = geo + user.geo?.city = "\(i)" + user.geo?.countryCode = "\(i)" + user.geo?.region = "\(i)" user.data?["\(i)"] = "\(i)" From afd5dafe11c1c1abf1f745afb4cffa5b9a25ffb6 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 21 Feb 2023 15:54:11 +0100 Subject: [PATCH 07/21] change prop to strong --- Sources/Sentry/Public/SentryUser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Sentry/Public/SentryUser.h b/Sources/Sentry/Public/SentryUser.h index 05d59295f44..bf67d50fbed 100644 --- a/Sources/Sentry/Public/SentryUser.h +++ b/Sources/Sentry/Public/SentryUser.h @@ -42,7 +42,7 @@ NS_SWIFT_NAME(User) /** * Optional: Geo location of user */ -@property (nonatomic, copy) SentryGeo *_Nullable geo; +@property (nonatomic, strong) SentryGeo *_Nullable geo; /** * Optional: Additional data From 2f6437ed7d6447e7bea556ae1ef775c21b8a7474 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 27 Feb 2023 11:03:43 +0100 Subject: [PATCH 08/21] use correct nullable syntax --- Sources/Sentry/Public/SentryGeo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Sentry/Public/SentryGeo.h b/Sources/Sentry/Public/SentryGeo.h index 9ea656ce371..92546cde493 100644 --- a/Sources/Sentry/Public/SentryGeo.h +++ b/Sources/Sentry/Public/SentryGeo.h @@ -10,17 +10,17 @@ NS_SWIFT_NAME(Geo) /** * Optional: Human readable city name. */ -@property (atomic, copy) NSString *_Nullable city; +@property (nullable, atomic, copy) NSString *city; /** * Optional: Two-letter country code (ISO 3166-1 alpha-2). */ -@property (atomic, copy) NSString *_Nullable countryCode; +@property (nullable, atomic, copy) NSString *countryCode; /** * Optional: Human readable region name or code. */ -@property (atomic, copy) NSString *_Nullable region; +@property (nullable, atomic, copy) NSString *region; - (instancetype)init; From d8e4d8ee6beec2d24e6f8a780b4ee23ca01dabe1 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 27 Feb 2023 11:06:58 +0100 Subject: [PATCH 09/21] copy geo --- Sources/Sentry/SentryUser.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Sentry/SentryUser.m b/Sources/Sentry/SentryUser.m index 5cf952f9ecd..2a902279532 100644 --- a/Sources/Sentry/SentryUser.m +++ b/Sources/Sentry/SentryUser.m @@ -31,7 +31,7 @@ - (id)copyWithZone:(nullable NSZone *)zone copy.ipAddress = self.ipAddress; copy.segment = self.segment; copy.name = self.name; - copy.geo = self.geo; + copy.geo = self.geo.copy; copy.data = self.data.copy; } } From ba0f3f53acc07800714fbd91faecc386932771e7 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 27 Feb 2023 11:07:52 +0100 Subject: [PATCH 10/21] use assignment syntax --- Sources/Sentry/SentryGeo.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Sentry/SentryGeo.m b/Sources/Sentry/SentryGeo.m index c39e7efc8f3..c824336be9f 100644 --- a/Sources/Sentry/SentryGeo.m +++ b/Sources/Sentry/SentryGeo.m @@ -31,9 +31,9 @@ - (id)copyWithZone:(nullable NSZone *)zone NSMutableDictionary *serializedData = [[NSMutableDictionary alloc] init]; @synchronized(self) { - [serializedData setValue:self.city forKey:@"city"]; - [serializedData setValue:self.countryCode forKey:@"country_code"]; - [serializedData setValue:self.region forKey:@"region"]; + serializedData[@"city"] = self.city; + serializedData[@"country_code"] = self.countryCode; + serializedData[@"region"] = self.region; } return serializedData; From f5dd5935a76a665c23964372698f4adc1d339e98 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 27 Feb 2023 11:08:32 +0100 Subject: [PATCH 11/21] use shorter init syntax --- Sources/Sentry/SentryGeo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Sentry/SentryGeo.m b/Sources/Sentry/SentryGeo.m index c824336be9f..7fa0a5a279e 100644 --- a/Sources/Sentry/SentryGeo.m +++ b/Sources/Sentry/SentryGeo.m @@ -28,7 +28,7 @@ - (id)copyWithZone:(nullable NSZone *)zone - (NSDictionary *)serialize { - NSMutableDictionary *serializedData = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *serializedData = [NSMutableDictionary dictionary]; @synchronized(self) { serializedData[@"city"] = self.city; From c4d82c65c0599e469ece9b3a3d59e1172de8558a Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 27 Feb 2023 11:40:59 +0100 Subject: [PATCH 12/21] move entry to unreleased section --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf6c93c9a1c..6e59ec4fcbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Features + +- Add `name` and `geo` to User (#2710) + ## 8.2.0 ### Features @@ -7,7 +13,6 @@ - Add enableTracing option (#2693) - Add isMain thread to SentryThread (#2692) - Add `in_foreground` to App Context (#2692) -- Add `name` and `geo` to User (#2710) - Combine UIKit and SwiftUI transactions (#2681) ### Fixes From 7d6693c7aa8dffbd6827cdb032546cbe09d764a8 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 7 Mar 2023 13:38:38 +0100 Subject: [PATCH 13/21] use diefferent nullability syntax --- Sources/Sentry/Public/SentryDebugMeta.h | 2 +- Sources/Sentry/Public/SentryUser.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Sentry/Public/SentryDebugMeta.h b/Sources/Sentry/Public/SentryDebugMeta.h index b846850cbd4..09c187d67ac 100644 --- a/Sources/Sentry/Public/SentryDebugMeta.h +++ b/Sources/Sentry/Public/SentryDebugMeta.h @@ -37,7 +37,7 @@ NS_SWIFT_NAME(DebugMeta) /** * Name of the image. Use ``codeFile`` when using ``type`` "macho". */ -@property (nonatomic, copy) NSString *_Nullable name; +@property (nullable, nonatomic, copy) NSString *name; /** * The size of the image in virtual memory. If missing, Sentry will assume that the image spans up diff --git a/Sources/Sentry/Public/SentryUser.h b/Sources/Sentry/Public/SentryUser.h index bf67d50fbed..28651f1925c 100644 --- a/Sources/Sentry/Public/SentryUser.h +++ b/Sources/Sentry/Public/SentryUser.h @@ -42,7 +42,7 @@ NS_SWIFT_NAME(User) /** * Optional: Geo location of user */ -@property (nonatomic, strong) SentryGeo *_Nullable geo; +@property (nullable, nonatomic, strong) SentryGeo *geo; /** * Optional: Additional data From f497206016d30f0704d5fb7935509b263e33931d Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 7 Mar 2023 13:54:19 +0100 Subject: [PATCH 14/21] add newline --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d268fae0146..96f7ddd6a8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features - Add `name` and `geo` to User (#2710) + ## 8.3.0 ### Fixes From 2bf929407122fce02f56d02a2d07c095d4a7383f Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 13 Mar 2023 13:11:43 +0100 Subject: [PATCH 15/21] remove redundant init override --- Sources/Sentry/Public/SentryGeo.h | 2 -- Sources/Sentry/SentryGeo.m | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Sources/Sentry/Public/SentryGeo.h b/Sources/Sentry/Public/SentryGeo.h index 92546cde493..3e6c75d6d5b 100644 --- a/Sources/Sentry/Public/SentryGeo.h +++ b/Sources/Sentry/Public/SentryGeo.h @@ -22,8 +22,6 @@ NS_SWIFT_NAME(Geo) */ @property (nullable, atomic, copy) NSString *region; -- (instancetype)init; - - (BOOL)isEqual:(id _Nullable)other; - (BOOL)isEqualToGeo:(SentryGeo *)geo; diff --git a/Sources/Sentry/SentryGeo.m b/Sources/Sentry/SentryGeo.m index 7fa0a5a279e..a651fd062af 100644 --- a/Sources/Sentry/SentryGeo.m +++ b/Sources/Sentry/SentryGeo.m @@ -6,14 +6,9 @@ @implementation SentryGeo -- (instancetype)init -{ - return [super init]; -} - - (id)copyWithZone:(nullable NSZone *)zone { - SentryGeo *copy = [[SentryGeo allocWithZone:zone] init]; + SentryGeo *copy = [[[self class] allocWithZone:zone] init]; @synchronized(self) { if (copy != nil) { From 990c8ea30f99643ac24bbdd566a97a872325b684 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 20 Mar 2023 14:52:48 +0100 Subject: [PATCH 16/21] remove synchronized blocks in geo, handle name in user --- CHANGELOG.md | 1 + Sources/Sentry/SentryGeo.m | 95 ++++++++++++++++--------------------- Sources/Sentry/SentryUser.m | 8 ++++ 3 files changed, 50 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da8f41717a0..3e3b11870fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features - Add `name` and `geo` to User (#2710) + ### Fixes - Updating AppHang state on main thread (#2793) diff --git a/Sources/Sentry/SentryGeo.m b/Sources/Sentry/SentryGeo.m index a651fd062af..e4334d36666 100644 --- a/Sources/Sentry/SentryGeo.m +++ b/Sources/Sentry/SentryGeo.m @@ -10,12 +10,10 @@ - (id)copyWithZone:(nullable NSZone *)zone { SentryGeo *copy = [[[self class] allocWithZone:zone] init]; - @synchronized(self) { - if (copy != nil) { - copy.city = self.city; - copy.countryCode = self.countryCode; - copy.region = self.region; - } + if (copy != nil) { + copy.city = self.city; + copy.countryCode = self.countryCode; + copy.region = self.region; } return copy; @@ -25,73 +23,62 @@ - (id)copyWithZone:(nullable NSZone *)zone { NSMutableDictionary *serializedData = [NSMutableDictionary dictionary]; - @synchronized(self) { - serializedData[@"city"] = self.city; - serializedData[@"country_code"] = self.countryCode; - serializedData[@"region"] = self.region; - } + serializedData[@"city"] = self.city; + serializedData[@"country_code"] = self.countryCode; + serializedData[@"region"] = self.region; return serializedData; } - (BOOL)isEqual:(id _Nullable)other { - @synchronized(self) { - if (other == self) { - return YES; - } - if (!other || ![[other class] isEqual:[self class]]) { - return NO; - } - - return [self isEqualToGeo:other]; + if (other == self) { + return YES; } + if (!other || ![[other class] isEqual:[self class]]) { + return NO; + } + + return [self isEqualToGeo:other]; } - (BOOL)isEqualToGeo:(SentryGeo *)geo { - @synchronized(self) { - // We need to get some local copies of the properties, because they could be modified during - // the if statements - - if (self == geo) { - return YES; - } - if (geo == nil) { - return NO; - } - - NSString *otherCity = geo.city; - if (self.city != otherCity && ![self.city isEqualToString:otherCity]) { - return NO; - } - - NSString *otherCountryCode = geo.countryCode; - if (self.countryCode != otherCountryCode - && ![self.countryCode isEqualToString:otherCountryCode]) { - return NO; - } - - NSString *otherRegion = geo.region; - if (self.region != otherRegion && ![self.region isEqualToString:otherRegion]) { - return NO; - } - + if (self == geo) { return YES; } + if (geo == nil) { + return NO; + } + + NSString *otherCity = geo.city; + if (self.city != otherCity && ![self.city isEqualToString:otherCity]) { + return NO; + } + + NSString *otherCountryCode = geo.countryCode; + if (self.countryCode != otherCountryCode + && ![self.countryCode isEqualToString:otherCountryCode]) { + return NO; + } + + NSString *otherRegion = geo.region; + if (self.region != otherRegion && ![self.region isEqualToString:otherRegion]) { + return NO; + } + + return YES; } - (NSUInteger)hash { - @synchronized(self) { - NSUInteger hash = 17; + NSUInteger hash = 17; - hash = hash * 23 + [self.city hash]; - hash = hash * 23 + [self.countryCode hash]; - hash = hash * 23 + [self.region hash]; + hash = hash * 23 + [self.city hash]; + hash = hash * 23 + [self.countryCode hash]; + hash = hash * 23 + [self.region hash]; - return hash; - } + return hash; } @end diff --git a/Sources/Sentry/SentryUser.m b/Sources/Sentry/SentryUser.m index 940de6a61d9..b4f6ce3e673 100644 --- a/Sources/Sentry/SentryUser.m +++ b/Sources/Sentry/SentryUser.m @@ -29,6 +29,7 @@ - (id)copyWithZone:(nullable NSZone *)zone copy.username = self.username; copy.ipAddress = self.ipAddress; copy.segment = self.segment; + copy.name = self.name; copy.geo = self.geo.copy; copy.data = self.data.copy; } @@ -45,6 +46,7 @@ - (id)copyWithZone:(nullable NSZone *)zone [serializedData setValue:self.username forKey:@"username"]; [serializedData setValue:self.ipAddress forKey:@"ip_address"]; [serializedData setValue:self.segment forKey:@"segment"]; + [serializedData setValue:self.name forKey:@"name"]; [serializedData setValue:[self.geo serialize] forKey:@"geo"]; [serializedData setValue:[self.data sentry_sanitize] forKey:@"data"]; @@ -97,6 +99,11 @@ - (BOOL)isEqualToUser:(SentryUser *)user if (self.segment != otherSegment && ![self.segment isEqualToString:otherSegment]) { return NO; } + + NSString *otherName = user.name; + if (self.name != otherName && ![self.name isEqualToString:otherName]) { + return NO; + } SentryGeo *otherGeo = user.geo; if (self.geo != otherGeo && ![self.geo isEqualToGeo:otherGeo]) { @@ -120,6 +127,7 @@ - (NSUInteger)hash hash = hash * 23 + [self.username hash]; hash = hash * 23 + [self.ipAddress hash]; hash = hash * 23 + [self.segment hash]; + hash = hash * 23 + [self.name hash]; hash = hash * 23 + [self.geo hash]; hash = hash * 23 + [self.data hash]; From 3c261e01754aeb4b09b9f779cee866f90d47b3b1 Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Mon, 20 Mar 2023 13:54:25 +0000 Subject: [PATCH 17/21] Format code --- Sources/Sentry/SentryUser.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Sentry/SentryUser.m b/Sources/Sentry/SentryUser.m index b4f6ce3e673..5db730f14b6 100644 --- a/Sources/Sentry/SentryUser.m +++ b/Sources/Sentry/SentryUser.m @@ -99,7 +99,7 @@ - (BOOL)isEqualToUser:(SentryUser *)user if (self.segment != otherSegment && ![self.segment isEqualToString:otherSegment]) { return NO; } - + NSString *otherName = user.name; if (self.name != otherName && ![self.name isEqualToString:otherName]) { return NO; From ba655db372e2a354336fa94aacedf090f6cf2041 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 27 Mar 2023 14:53:39 +0200 Subject: [PATCH 18/21] refactor code --- Sources/Sentry/SentryGeo.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Sources/Sentry/SentryGeo.m b/Sources/Sentry/SentryGeo.m index e4334d36666..a10e61106dc 100644 --- a/Sources/Sentry/SentryGeo.m +++ b/Sources/Sentry/SentryGeo.m @@ -21,13 +21,11 @@ - (id)copyWithZone:(nullable NSZone *)zone - (NSDictionary *)serialize { - NSMutableDictionary *serializedData = [NSMutableDictionary dictionary]; - - serializedData[@"city"] = self.city; - serializedData[@"country_code"] = self.countryCode; - serializedData[@"region"] = self.region; - - return serializedData; + return @{ + @"city" : self.city, + @"country_code" : self.countryCode, + @"region" : self.region + }; } - (BOOL)isEqual:(id _Nullable)other From 7d043820f2c3faefc1d696f5caa723dc13923c97 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 27 Mar 2023 14:56:32 +0200 Subject: [PATCH 19/21] add sample data in comment --- Sources/Sentry/Public/SentryGeo.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/Sentry/Public/SentryGeo.h b/Sources/Sentry/Public/SentryGeo.h index 3e6c75d6d5b..ef63b737d49 100644 --- a/Sources/Sentry/Public/SentryGeo.h +++ b/Sources/Sentry/Public/SentryGeo.h @@ -4,6 +4,16 @@ NS_ASSUME_NONNULL_BEGIN +/// Approximate geographical location of the end user or device. +/// +/// Example of serialized data: +/// { +/// "geo": { +/// "country_code": "US", +/// "city": "Ashburn", +/// "region": "San Francisco" +/// } +/// } NS_SWIFT_NAME(Geo) @interface SentryGeo : NSObject From 70cc238511fcae2a0d03dc487db94009330bdcaf Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Mon, 27 Mar 2023 16:08:10 +0000 Subject: [PATCH 20/21] Format code --- Sources/Sentry/SentryGeo.m | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sources/Sentry/SentryGeo.m b/Sources/Sentry/SentryGeo.m index a10e61106dc..91d73818a8c 100644 --- a/Sources/Sentry/SentryGeo.m +++ b/Sources/Sentry/SentryGeo.m @@ -21,11 +21,7 @@ - (id)copyWithZone:(nullable NSZone *)zone - (NSDictionary *)serialize { - return @{ - @"city" : self.city, - @"country_code" : self.countryCode, - @"region" : self.region - }; + return @{ @"city" : self.city, @"country_code" : self.countryCode, @"region" : self.region }; } - (BOOL)isEqual:(id _Nullable)other From d929410d00ef86b3d48b22bda49b6bef6d698ac8 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 27 Mar 2023 18:14:58 +0200 Subject: [PATCH 21/21] update changelog entry --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a3f8a2e28..f4558765b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ # Changelog -## 8.3.3 +## Unreleased ### Features - Add `name` and `geo` to User (#2710) +## 8.3.3 + ### Fixes - View hierarchy not sent for crashes (#2781)