-
-
Notifications
You must be signed in to change notification settings - Fork 391
Expand file tree
/
Copy pathSentryBaggage.m
More file actions
125 lines (107 loc) · 4.31 KB
/
SentryBaggage.m
File metadata and controls
125 lines (107 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#import "SentryBaggage.h"
#import "SentryLogC.h"
#import "SentryScope+Private.h"
#import "SentrySwift.h"
#import "SentryTraceContext.h"
#import "SentryTracer.h"
#import "SentryUser.h"
@implementation SentryBaggage
- (instancetype)initWithTraceId:(SentryId *)traceId
publicKey:(NSString *)publicKey
releaseName:(nullable NSString *)releaseName
environment:(nullable NSString *)environment
transaction:(nullable NSString *)transaction
sampleRate:(nullable NSString *)sampleRate
sampled:(nullable NSString *)sampled
replayId:(nullable NSString *)replayId
{
return [self initWithTraceId:traceId
publicKey:publicKey
releaseName:releaseName
environment:environment
transaction:transaction
sampleRate:sampleRate
sampleRand:nil
sampled:sampled
replayId:replayId
orgId:nil];
}
- (instancetype)initWithTraceId:(SentryId *)traceId
publicKey:(NSString *)publicKey
releaseName:(nullable NSString *)releaseName
environment:(nullable NSString *)environment
transaction:(nullable NSString *)transaction
sampleRate:(nullable NSString *)sampleRate
sampleRand:(nullable NSString *)sampleRand
sampled:(nullable NSString *)sampled
replayId:(nullable NSString *)replayId
{
return [self initWithTraceId:traceId
publicKey:publicKey
releaseName:releaseName
environment:environment
transaction:transaction
sampleRate:sampleRate
sampleRand:sampleRand
sampled:sampled
replayId:replayId
orgId:nil];
}
- (instancetype)initWithTraceId:(SentryId *)traceId
publicKey:(NSString *)publicKey
releaseName:(nullable NSString *)releaseName
environment:(nullable NSString *)environment
transaction:(nullable NSString *)transaction
sampleRate:(nullable NSString *)sampleRate
sampleRand:(nullable NSString *)sampleRand
sampled:(nullable NSString *)sampled
replayId:(nullable NSString *)replayId
orgId:(nullable NSString *)orgId
{
if (self = [super init]) {
_traceId = traceId;
_publicKey = publicKey;
_releaseName = releaseName;
_environment = environment;
_transaction = transaction;
_sampleRate = sampleRate;
_sampleRand = sampleRand;
_sampled = sampled;
_replayId = replayId;
_orgId = orgId;
}
return self;
}
- (NSString *)toHTTPHeaderWithOriginalBaggage:(NSDictionary *_Nullable)originalBaggage
{
NSMutableDictionary<NSString *, NSString *> *information
= originalBaggage.mutableCopy ?: [[NSMutableDictionary alloc] init];
[information setValue:_traceId.sentryIdString forKey:@"sentry-trace_id"];
[information setValue:_publicKey forKey:@"sentry-public_key"];
if (_releaseName != nil) {
[information setValue:_releaseName forKey:@"sentry-release"];
}
if (_environment != nil) {
[information setValue:_environment forKey:@"sentry-environment"];
}
if (_transaction != nil) {
[information setValue:_transaction forKey:@"sentry-transaction"];
}
if (_sampleRand != nil) {
[information setValue:_sampleRand forKey:@"sentry-sample_rand"];
}
if (_sampleRate != nil) {
[information setValue:_sampleRate forKey:@"sentry-sample_rate"];
}
if (_sampled != nil) {
[information setValue:_sampled forKey:@"sentry-sampled"];
}
if (_replayId != nil) {
[information setValue:_replayId forKey:@"sentry-replay_id"];
}
if (_orgId != nil) {
[information setValue:_orgId forKey:@"sentry-org_id"];
}
return [SentryBaggageSerialization encodeDictionary:information];
}
@end