Skip to content

Commit 9a17767

Browse files
noahsmartincursoragentarmcknight
authored
feat(v9): Remove segment property (#5638)
* feat(v9): Remove segment property * Remove userSegment from SentryTraceContext for SDK_V9 (#5640) * Add SDK_V9 support for SentryTraceContext without userSegment Co-authored-by: noah.martin <noah.martin@sentry.io> * Remove userSegment parameter for SDK_V9, conditionally compile related code Co-authored-by: noah.martin <noah.martin@sentry.io> * Checkpoint before follow-up message * Remove userSegment parameter for SDK_V9 builds Co-authored-by: noah.martin <noah.martin@sentry.io> * Changes from background composer bc-531a0790-0efc-4531-b43a-6e3289ec47f4 --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> * Fixes * Update Sources/Sentry/Public/SentryTraceContext.h Co-authored-by: Andrew McKnight <andrew.mcknight@sentry.io> * PR feedback --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Andrew McKnight <andrew.mcknight@sentry.io>
1 parent a7655b5 commit 9a17767

File tree

11 files changed

+138
-362
lines changed

11 files changed

+138
-362
lines changed

CHANGELOG-v9.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# 9.0
22

3-
## Breaking Changes
4-
5-
### Fixes
6-
7-
Fixes warnings about minimum OS version being lower than Xcode supported version (#5591)
8-
9-
### Improvements
3+
### Breaking Changes
104

115
Removes deprecated user feedback API, this is replaced with the new feedback API (#5591)
126
Removes unused SentryLogLevel (#5591)
137
Removes deprecated getStoreEndpoint (#5591)
148
Removes deprecated useSpan function (#5591)
159
Removes deprecated SentryDebugImageProvider class (#5598)
1610
Makes app hang tracking V2 the default and removes the option to enable/disable it (#5615)
11+
Removes segment property on SentryUser, SentryBaggage, and SentryTraceContext (#5638)
12+
13+
### Fixes
14+
15+
Fixes warnings about minimum OS version being lower than Xcode supported version (#5591)
16+
17+
### Improvements

Sources/Sentry/Public/SentryBaggage.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ NS_SWIFT_NAME(Baggage)
4343
/**
4444
* The value of a segment attribute in the user's data bag, if it exists.
4545
*/
46+
#if !SDK_V9
4647
@property (nullable, nonatomic, readonly) NSString *userSegment;
48+
#endif
4749

4850
/**
4951
* The random value used to determine if the trace is sampled.
@@ -69,7 +71,9 @@ NS_SWIFT_NAME(Baggage)
6971
releaseName:(nullable NSString *)releaseName
7072
environment:(nullable NSString *)environment
7173
transaction:(nullable NSString *)transaction
74+
#if !SDK_V9
7275
userSegment:(nullable NSString *)userSegment
76+
#endif
7377
sampleRate:(nullable NSString *)sampleRate
7478
sampled:(nullable NSString *)sampled
7579
replayId:(nullable NSString *)replayId;
@@ -79,7 +83,9 @@ NS_SWIFT_NAME(Baggage)
7983
releaseName:(nullable NSString *)releaseName
8084
environment:(nullable NSString *)environment
8185
transaction:(nullable NSString *)transaction
86+
#if !SDK_V9
8287
userSegment:(nullable NSString *)userSegment
88+
#endif
8389
sampleRate:(nullable NSString *)sampleRate
8490
sampleRand:(nullable NSString *)sampleRand
8591
sampled:(nullable NSString *)sampled

Sources/Sentry/Public/SentryTraceContext.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ NS_SWIFT_NAME(TraceContext)
4545
/**
4646
* A subset of the scope's user context.
4747
*/
48+
#if !SDK_V9
4849
@property (nullable, nonatomic, readonly) NSString *userSegment;
50+
#endif
4951

5052
/**
5153
* Serialized sample rate used for this trace.
@@ -75,7 +77,9 @@ NS_SWIFT_NAME(TraceContext)
7577
releaseName:(nullable NSString *)releaseName
7678
environment:(nullable NSString *)environment
7779
transaction:(nullable NSString *)transaction
80+
#if !SDK_V9
7881
userSegment:(nullable NSString *)userSegment
82+
#endif
7983
sampleRate:(nullable NSString *)sampleRate
8084
sampled:(nullable NSString *)sampled
8185
replayId:(nullable NSString *)replayId;
@@ -88,7 +92,9 @@ NS_SWIFT_NAME(TraceContext)
8892
releaseName:(nullable NSString *)releaseName
8993
environment:(nullable NSString *)environment
9094
transaction:(nullable NSString *)transaction
95+
#if !SDK_V9
9196
userSegment:(nullable NSString *)userSegment
97+
#endif
9298
sampleRate:(nullable NSString *)sampleRate
9399
sampleRand:(nullable NSString *)sampleRand
94100
sampled:(nullable NSString *)sampled
@@ -111,16 +117,29 @@ NS_SWIFT_NAME(TraceContext)
111117
scope:(nullable SentryScope *)scope
112118
options:(SentryOptions *)options;
113119

120+
#if SDK_V9
114121
/**
115-
* Initializes a SentryTraceContext with data from a traceID, options and userSegment.
122+
* Initializes a SentryTraceContext with data from a traceId, options and replayId.
123+
*
124+
* @param traceId The current tracer.
125+
* @param options The current active options.
126+
* @param replayId The current session replay.
127+
*/
128+
#else
129+
/**
130+
* Initializes a SentryTraceContext with data from a traceId, options, userSegment and replayId.
116131
*
117132
* @param traceId The current tracer.
118133
* @param options The current active options.
119134
* @param userSegment You can retrieve this usually from the `scope.userObject.segment`.
135+
* @param replayId The current session replay.
120136
*/
137+
#endif
121138
- (instancetype)initWithTraceId:(SentryId *)traceId
122139
options:(SentryOptions *)options
140+
#if !SDK_V9
123141
userSegment:(nullable NSString *)userSegment
142+
#endif
124143
replayId:(nullable NSString *)replayId;
125144

126145
/**

Sources/Sentry/Public/SentryUser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ NS_SWIFT_NAME(User)
3434
*/
3535
@property (atomic, copy) NSString *_Nullable ipAddress;
3636

37+
#if !SDK_V9
3738
/**
3839
* The user segment, for apps that divide users in user segments.
3940
* @deprecated This field will be removed in the next major version.
4041
*/
4142
@property (atomic, copy) NSString *_Nullable segment DEPRECATED_MSG_ATTRIBUTE(
4243
"This field is deprecated and will be removed in the next major update.");
44+
#endif // !SDK_V9
4345

4446
/**
4547
* Optional: Human readable name

Sources/Sentry/SentryBaggage.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
1515
releaseName:(nullable NSString *)releaseName
1616
environment:(nullable NSString *)environment
1717
transaction:(nullable NSString *)transaction
18+
#if !SDK_V9
1819
userSegment:(nullable NSString *)userSegment
20+
#endif
1921
sampleRate:(nullable NSString *)sampleRate
2022
sampled:(nullable NSString *)sampled
2123
replayId:(nullable NSString *)replayId
@@ -25,7 +27,9 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
2527
releaseName:releaseName
2628
environment:environment
2729
transaction:transaction
30+
#if !SDK_V9
2831
userSegment:userSegment
32+
#endif
2933
sampleRate:sampleRate
3034
sampleRand:nil
3135
sampled:sampled
@@ -37,7 +41,9 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
3741
releaseName:(nullable NSString *)releaseName
3842
environment:(nullable NSString *)environment
3943
transaction:(nullable NSString *)transaction
44+
#if !SDK_V9
4045
userSegment:(nullable NSString *)userSegment
46+
#endif
4147
sampleRate:(nullable NSString *)sampleRate
4248
sampleRand:(nullable NSString *)sampleRand
4349
sampled:(nullable NSString *)sampled
@@ -50,7 +56,9 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
5056
_releaseName = releaseName;
5157
_environment = environment;
5258
_transaction = transaction;
59+
#if !SDK_V9
5360
_userSegment = userSegment;
61+
#endif
5462
_sampleRate = sampleRate;
5563
_sampleRand = sampleRand;
5664
_sampled = sampled;
@@ -80,9 +88,11 @@ - (NSString *)toHTTPHeaderWithOriginalBaggage:(NSDictionary *_Nullable)originalB
8088
[information setValue:_transaction forKey:@"sentry-transaction"];
8189
}
8290

91+
#if !SDK_V9
8392
if (_userSegment != nil) {
8493
[information setValue:_userSegment forKey:@"sentry-user_segment"];
8594
}
95+
#endif
8696

8797
if (_sampleRand != nil) {
8898
[information setValue:_sampleRand forKey:@"sentry-sample_rand"];

Sources/Sentry/SentryClient.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,19 @@ - (nullable SentryTraceContext *)getTraceStateWithEvent:(SentryEvent *)event
426426
}
427427

428428
if (event.error || event.exceptions.count > 0) {
429-
#pragma clang diagnostic push
430-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
429+
#if !SDK_V9
430+
NSString *segment = nil;
431+
# pragma clang diagnostic push
432+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
433+
segment = scope.userObject.segment;
434+
# pragma clang diagnostic pop
435+
#endif
431436
return [[SentryTraceContext alloc] initWithTraceId:scope.propagationContext.traceId
432437
options:self.options
433-
userSegment:scope.userObject.segment
438+
#if !SDK_V9
439+
userSegment:segment
440+
#endif
434441
replayId:scope.replayId];
435-
#pragma clang diagnostic pop
436442
}
437443

438444
return nil;

Sources/Sentry/SentryNetworkTracker.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,22 @@ - (void)urlSessionTaskResume:(NSURLSessionTask *)sessionTask
230230
- (void)addTraceWithoutTransactionToTask:(NSURLSessionTask *)sessionTask
231231
{
232232
SentryPropagationContext *propagationContext = SentrySDK.currentHub.scope.propagationContext;
233-
#pragma clang diagnostic push
234-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
233+
234+
#if !SDK_V9
235+
NSString *segment = nil;
236+
# pragma clang diagnostic push
237+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
238+
segment = SentrySDK.currentHub.scope.userObject.segment;
239+
# pragma clang diagnostic pop
240+
#endif
241+
235242
SentryTraceContext *traceContext =
236243
[[SentryTraceContext alloc] initWithTraceId:propagationContext.traceId
237244
options:SentrySDK.currentHub.client.options
238-
userSegment:SentrySDK.currentHub.scope.userObject.segment
245+
#if !SDK_V9
246+
userSegment:segment
247+
#endif
239248
replayId:SentrySDK.currentHub.scope.replayId];
240-
#pragma clang diagnostic pop
241249

242250
[self addBaggageHeader:[traceContext toBaggage]
243251
traceHeader:[propagationContext traceHeader]

Sources/Sentry/SentryTraceContext.m

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
2121
releaseName:(nullable NSString *)releaseName
2222
environment:(nullable NSString *)environment
2323
transaction:(nullable NSString *)transaction
24+
#if !SDK_V9
2425
userSegment:(nullable NSString *)userSegment
26+
#endif
2527
sampleRate:(nullable NSString *)sampleRate
2628
sampled:(nullable NSString *)sampled
2729
replayId:(nullable NSString *)replayId
@@ -31,7 +33,9 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
3133
releaseName:releaseName
3234
environment:environment
3335
transaction:transaction
36+
#if !SDK_V9
3437
userSegment:userSegment
38+
#endif
3539
sampleRate:sampleRate
3640
sampleRand:nil
3741
sampled:sampled
@@ -43,7 +47,9 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
4347
releaseName:(nullable NSString *)releaseName
4448
environment:(nullable NSString *)environment
4549
transaction:(nullable NSString *)transaction
50+
#if !SDK_V9
4651
userSegment:(nullable NSString *)userSegment
52+
#endif
4753
sampleRate:(nullable NSString *)sampleRate
4854
sampleRand:(nullable NSString *)sampleRand
4955
sampled:(nullable NSString *)sampled
@@ -55,7 +61,9 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
5561
_environment = environment;
5662
_releaseName = releaseName;
5763
_transaction = transaction;
64+
#if !SDK_V9
5865
_userSegment = userSegment;
66+
#endif
5967
_sampleRand = sampleRand;
6068
_sampleRate = sampleRate;
6169
_sampled = sampled;
@@ -81,14 +89,15 @@ - (nullable instancetype)initWithTracer:(SentryTracer *)tracer
8189
if (tracer.traceId == nil || options.parsedDsn == nil)
8290
return nil;
8391

84-
NSString *userSegment;
85-
86-
#pragma clang diagnostic push
87-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
92+
#if !SDK_V9
93+
NSString *userSegment = nil;
94+
# pragma clang diagnostic push
95+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
8896
if (scope.userObject.segment) {
8997
userSegment = scope.userObject.segment;
9098
}
91-
#pragma clang diagnostic pop
99+
# pragma clang diagnostic pop
100+
#endif // !SDK_V9
92101

93102
NSString *serializedSampleRand = nil;
94103
NSNumber *sampleRand = [tracer.transactionContext sampleRand];
@@ -112,7 +121,9 @@ - (nullable instancetype)initWithTracer:(SentryTracer *)tracer
112121
releaseName:options.releaseName
113122
environment:options.environment
114123
transaction:tracer.transactionContext.name
124+
#if !SDK_V9
115125
userSegment:userSegment
126+
#endif
116127
sampleRate:serializedSampleRate
117128
sampleRand:serializedSampleRand
118129
sampled:sampled
@@ -121,15 +132,19 @@ - (nullable instancetype)initWithTracer:(SentryTracer *)tracer
121132

122133
- (instancetype)initWithTraceId:(SentryId *)traceId
123134
options:(SentryOptions *)options
135+
#if !SDK_V9
124136
userSegment:(nullable NSString *)userSegment
137+
#endif
125138
replayId:(nullable NSString *)replayId;
126139
{
127140
return [[SentryTraceContext alloc] initWithTraceId:traceId
128141
publicKey:options.parsedDsn.url.user
129142
releaseName:options.releaseName
130143
environment:options.environment
131144
transaction:nil
145+
#if !SDK_V9
132146
userSegment:userSegment
147+
#endif
133148
sampleRate:nil
134149
sampleRand:nil
135150
sampled:nil
@@ -143,6 +158,7 @@ - (nullable instancetype)initWithDict:(NSDictionary<NSString *, id> *)dictionary
143158
if (traceId == nil || publicKey == nil)
144159
return nil;
145160

161+
#if !SDK_V9
146162
NSString *userSegment;
147163
if (dictionary[@"user"] != nil) {
148164
NSDictionary *userInfo = dictionary[@"user"];
@@ -151,13 +167,16 @@ - (nullable instancetype)initWithDict:(NSDictionary<NSString *, id> *)dictionary
151167
} else {
152168
userSegment = dictionary[@"user_segment"];
153169
}
170+
#endif
154171

155172
return [self initWithTraceId:traceId
156173
publicKey:publicKey
157174
releaseName:dictionary[@"release"]
158175
environment:dictionary[@"environment"]
159176
transaction:dictionary[@"transaction"]
177+
#if !SDK_V9
160178
userSegment:userSegment
179+
#endif
161180
sampleRate:dictionary[@"sample_rate"]
162181
sampleRand:dictionary[@"sample_rand"]
163182
sampled:dictionary[@"sampled"]
@@ -171,7 +190,9 @@ - (SentryBaggage *)toBaggage
171190
releaseName:_releaseName
172191
environment:_environment
173192
transaction:_transaction
193+
#if !SDK_V9
174194
userSegment:_userSegment
195+
#endif
175196
sampleRate:_sampleRate
176197
sampleRand:_sampleRand
177198
sampled:_sampled
@@ -196,9 +217,11 @@ - (SentryBaggage *)toBaggage
196217
[result setValue:_transaction forKey:@"transaction"];
197218
}
198219

220+
#if !SDK_V9
199221
if (_userSegment != nil) {
200222
[result setValue:_userSegment forKey:@"user_segment"];
201223
}
224+
#endif
202225

203226
if (_sampleRand != nil) {
204227
[result setValue:_sampleRand forKey:@"sample_rand"];

0 commit comments

Comments
 (0)