diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bca98dd572..2e809f55540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Fixes - `storeEnvelope` ends session for unhandled errors (#4073) +- Deprecate `SentryUser.segment`(#4092). Please remove usages of this property. We will remove it in the next major. ## 8.29.1 diff --git a/Sources/Sentry/Public/SentryUser.h b/Sources/Sentry/Public/SentryUser.h index 525f8c444fe..3587e0e7a8d 100644 --- a/Sources/Sentry/Public/SentryUser.h +++ b/Sources/Sentry/Public/SentryUser.h @@ -30,8 +30,10 @@ NS_SWIFT_NAME(User) /** * The user segment, for apps that divide users in user segments. + * @deprecated This field will be removed in the next major version. */ -@property (atomic, copy) NSString *_Nullable segment; +@property (atomic, copy) NSString *_Nullable segment DEPRECATED_MSG_ATTRIBUTE( + "This field is deprecated and will be removed in the next major update."); /** * Optional: Human readable name diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index 68793363f7a..3517f7713b6 100644 --- a/Sources/Sentry/SentryClient.m +++ b/Sources/Sentry/SentryClient.m @@ -381,9 +381,12 @@ - (nullable SentryTraceContext *)getTraceStateWithEvent:(SentryEvent *)event } if (event.error || event.exceptions.count > 0) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [[SentryTraceContext alloc] initWithTraceId:scope.propagationContext.traceId options:self.options userSegment:scope.userObject.segment]; +#pragma clang diagnostic pop } return nil; diff --git a/Sources/Sentry/SentryNetworkTracker.m b/Sources/Sentry/SentryNetworkTracker.m index ef91506a6e6..15016d616fb 100644 --- a/Sources/Sentry/SentryNetworkTracker.m +++ b/Sources/Sentry/SentryNetworkTracker.m @@ -232,10 +232,13 @@ - (void)urlSessionTaskResume:(NSURLSessionTask *)sessionTask - (void)addTraceWithoutTransactionToTask:(NSURLSessionTask *)sessionTask { SentryPropagationContext *propagationContext = SentrySDK.currentHub.scope.propagationContext; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" SentryTraceContext *traceContext = [[SentryTraceContext alloc] initWithTraceId:propagationContext.traceId options:SentrySDK.currentHub.client.options userSegment:SentrySDK.currentHub.scope.userObject.segment]; +#pragma clang diagnostic pop [self addBaggageHeader:[traceContext toBaggage] traceHeader:[propagationContext traceHeader] diff --git a/Sources/Sentry/SentryTraceContext.m b/Sources/Sentry/SentryTraceContext.m index d249209c553..afe2a1b541f 100644 --- a/Sources/Sentry/SentryTraceContext.m +++ b/Sources/Sentry/SentryTraceContext.m @@ -59,9 +59,12 @@ - (nullable instancetype)initWithTracer:(SentryTracer *)tracer NSString *userSegment; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (scope.userObject.segment) { userSegment = scope.userObject.segment; } +#pragma clang diagnostic pop NSString *sampleRate = nil; if ([tracer isKindOfClass:[SentryTransactionContext class]]) { diff --git a/Sources/Sentry/SentryUser.m b/Sources/Sentry/SentryUser.m index 5a7ec63a50e..6952055e9b6 100644 --- a/Sources/Sentry/SentryUser.m +++ b/Sources/Sentry/SentryUser.m @@ -32,7 +32,10 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary } else if ([key isEqualToString:@"ip_address"] && isString) { self.ipAddress = value; } else if ([key isEqualToString:@"segment"] && isString) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" self.segment = value; +#pragma clang diagnostic pop } else if ([key isEqualToString:@"data"] && isDictionary) { self.data = value; } else { @@ -69,7 +72,10 @@ - (id)copyWithZone:(nullable NSZone *)zone copy.email = self.email; copy.username = self.username; copy.ipAddress = self.ipAddress; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" copy.segment = self.segment; +#pragma clang diagnostic pop copy.name = self.name; copy.geo = self.geo.copy; copy.data = self.data.copy; @@ -87,7 +93,10 @@ - (id)copyWithZone:(nullable NSZone *)zone [serializedData setValue:self.email forKey:@"email"]; [serializedData setValue:self.username forKey:@"username"]; [serializedData setValue:self.ipAddress forKey:@"ip_address"]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [serializedData setValue:self.segment forKey:@"segment"]; +#pragma clang diagnostic pop [serializedData setValue:self.name forKey:@"name"]; [serializedData setValue:[self.geo serialize] forKey:@"geo"]; [serializedData setValue:sentry_sanitize(self.data) forKey:@"data"]; @@ -142,10 +151,13 @@ - (BOOL)isEqualToUser:(SentryUser *)user return NO; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSString *otherSegment = user.segment; if (self.segment != otherSegment && ![self.segment isEqualToString:otherSegment]) { return NO; } +#pragma clang diagnostic pop NSString *otherName = user.name; if (self.name != otherName && ![self.name isEqualToString:otherName]) { @@ -178,7 +190,10 @@ - (NSUInteger)hash hash = hash * 23 + [self.email hash]; hash = hash * 23 + [self.username hash]; hash = hash * 23 + [self.ipAddress hash]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" hash = hash * 23 + [self.segment hash]; +#pragma clang diagnostic pop hash = hash * 23 + [self.name hash]; hash = hash * 23 + [self.geo hash]; hash = hash * 23 + [self.data hash];