11#import " SentryTraceContext.h"
22#import " SentryBaggage.h"
3+ #import " SentryDefines.h"
34#import " SentryDsn.h"
45#import " SentryId.h"
56#import " SentryLog.h"
67#import " SentryOptions+Private.h"
8+ #import " SentrySampleDecision.h"
79#import " SentryScope+Private.h"
810#import " SentrySerialization.h"
911#import " SentryTracer.h"
@@ -21,6 +23,7 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
2123 transaction : (nullable NSString *)transaction
2224 userSegment : (nullable NSString *)userSegment
2325 sampleRate : (nullable NSString *)sampleRate
26+ sampled : (nullable NSString *)sampled
2427{
2528 if (self = [super init ]) {
2629 _traceId = traceId;
@@ -30,6 +33,7 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
3033 _transaction = transaction;
3134 _userSegment = userSegment;
3235 _sampleRate = sampleRate;
36+ _sampled = sampled;
3337 }
3438 return self;
3539}
@@ -63,13 +67,20 @@ - (nullable instancetype)initWithTracer:(SentryTracer *)tracer
6367 [NSString stringWithFormat: @" %@ " , [(SentryTransactionContext *)tracer sampleRate ]];
6468 }
6569
70+ NSString *sampled = nil ;
71+ if (tracer.sampled != kSentrySampleDecisionUndecided ) {
72+ sampled
73+ = tracer.sampled == kSentrySampleDecisionYes ? kSentryTrueString : kSentryFalseString ;
74+ }
75+
6676 return [self initWithTraceId: tracer.traceId
6777 publicKey: options.parsedDsn.url.user
6878 releaseName: options.releaseName
6979 environment: options.environment
7080 transaction: tracer.transactionContext.name
7181 userSegment: userSegment
72- sampleRate: sampleRate];
82+ sampleRate: sampleRate
83+ sampled: sampled];
7384}
7485
7586- (nullable instancetype )initWithDict : (NSDictionary <NSString *, id> *)dictionary
@@ -94,7 +105,8 @@ - (nullable instancetype)initWithDict:(NSDictionary<NSString *, id> *)dictionary
94105 environment: dictionary[@" environment" ]
95106 transaction: dictionary[@" transaction" ]
96107 userSegment: userSegment
97- sampleRate: dictionary[@" sample_rate" ]];
108+ sampleRate: dictionary[@" sample_rate" ]
109+ sampled: dictionary[@" sampled" ]];
98110}
99111
100112- (SentryBaggage *)toBaggage
@@ -105,7 +117,8 @@ - (SentryBaggage *)toBaggage
105117 environment: _environment
106118 transaction: _transaction
107119 userSegment: _userSegment
108- sampleRate: _sampleRate];
120+ sampleRate: _sampleRate
121+ sampled: _sampled];
109122 return result;
110123}
111124
@@ -134,6 +147,10 @@ - (SentryBaggage *)toBaggage
134147 [result setValue: _sampleRate forKey: @" sample_rate" ];
135148 }
136149
150+ if (_sampled != nil ) {
151+ [result setValue: _sampleRate forKey: @" sampled" ];
152+ }
153+
137154 return result;
138155}
139156
0 commit comments