@@ -23,24 +23,88 @@ class DDSessionReplayTests: XCTestCase {
23
23
// Then
24
24
XCTAssertEqual ( config. _swift. replaySampleRate, sampleRate)
25
25
XCTAssertEqual ( config. _swift. defaultPrivacyLevel, . mask)
26
+ XCTAssertEqual ( config. _swift. textAndInputPrivacyLevel, . maskAll)
27
+ XCTAssertEqual ( config. _swift. imagePrivacyLevel, . maskAll)
28
+ XCTAssertEqual ( config. _swift. touchPrivacyLevel, . hide)
29
+ XCTAssertNil ( config. _swift. customEndpoint)
30
+ }
31
+
32
+ func testConfigurationWithNewApi( ) {
33
+ // Given
34
+ let textAndInputPrivacy : DDTextAndInputPrivacyLevel = [ . maskAll, . maskAllInputs, . maskSensitiveInputs] . randomElement ( ) !
35
+ let touchPrivacy : DDTouchPrivacyLevel = [ . show, . hide] . randomElement ( ) !
36
+ let imagePrivacy : DDImagePrivacyLevel = [ . maskAll, . maskNonBundledOnly, . maskNone] . randomElement ( ) !
37
+ let sampleRate : Float = . mockRandom( min: 0 , max: 100 )
38
+
39
+ // When
40
+ let config = DDSessionReplayConfiguration (
41
+ replaySampleRate: sampleRate,
42
+ textAndInputPrivacyLevel: textAndInputPrivacy,
43
+ imagePrivacyLevel: imagePrivacy,
44
+ touchPrivacyLevel: touchPrivacy
45
+ )
46
+
47
+ // Then
48
+ XCTAssertEqual ( config. _swift. replaySampleRate, sampleRate)
49
+ XCTAssertEqual ( config. _swift. textAndInputPrivacyLevel, textAndInputPrivacy. _swift)
50
+ XCTAssertEqual ( config. _swift. imagePrivacyLevel, imagePrivacy. _swift)
51
+ XCTAssertEqual ( config. _swift. touchPrivacyLevel, touchPrivacy. _swift)
26
52
XCTAssertNil ( config. _swift. customEndpoint)
27
53
}
28
54
29
55
func testConfigurationOverrides( ) {
30
56
// Given
31
57
let sampleRate : Float = . mockRandom( min: 0 , max: 100 )
32
58
let privacy : DDSessionReplayConfigurationPrivacyLevel = [ . allow, . mask, . maskUserInput] . randomElement ( ) !
59
+ let textAndInputPrivacy : DDTextAndInputPrivacyLevel = [ . maskAll, . maskAllInputs, . maskSensitiveInputs] . randomElement ( ) !
60
+ let imagePrivacy : DDImagePrivacyLevel = [ . maskAll, . maskNonBundledOnly, . maskNone] . randomElement ( ) !
61
+ let touchPrivacy : DDTouchPrivacyLevel = [ . show, . hide] . randomElement ( ) !
33
62
let url : URL = . mockRandom( )
34
63
35
64
// When
36
65
let config = DDSessionReplayConfiguration ( replaySampleRate: 100 )
37
66
config. replaySampleRate = sampleRate
38
67
config. defaultPrivacyLevel = privacy
68
+ config. textAndInputPrivacyLevel = textAndInputPrivacy
69
+ config. imagePrivacyLevel = imagePrivacy
70
+ config. touchPrivacyLevel = touchPrivacy
39
71
config. customEndpoint = url
40
72
41
73
// Then
42
74
XCTAssertEqual ( config. _swift. replaySampleRate, sampleRate)
43
75
XCTAssertEqual ( config. _swift. defaultPrivacyLevel, privacy. _swift)
76
+ XCTAssertEqual ( config. _swift. textAndInputPrivacyLevel, textAndInputPrivacy. _swift)
77
+ XCTAssertEqual ( config. _swift. imagePrivacyLevel, imagePrivacy. _swift)
78
+ XCTAssertEqual ( config. _swift. touchPrivacyLevel, touchPrivacy. _swift)
79
+ XCTAssertEqual ( config. _swift. customEndpoint, url)
80
+ }
81
+
82
+ func testConfigurationOverridesWithNewApi( ) {
83
+ // Given
84
+ let sampleRate : Float = . mockRandom( min: 0 , max: 100 )
85
+ let textAndInputPrivacy : DDTextAndInputPrivacyLevel = [ . maskAll, . maskAllInputs, . maskSensitiveInputs] . randomElement ( ) !
86
+ let imagePrivacy : DDImagePrivacyLevel = [ . maskAll, . maskNonBundledOnly, . maskNone] . randomElement ( ) !
87
+ let touchPrivacy : DDTouchPrivacyLevel = [ . show, . hide] . randomElement ( ) !
88
+ let url : URL = . mockRandom( )
89
+
90
+ // When
91
+ let config = DDSessionReplayConfiguration (
92
+ replaySampleRate: 100 ,
93
+ textAndInputPrivacyLevel: . maskAll,
94
+ imagePrivacyLevel: . maskAll,
95
+ touchPrivacyLevel: . hide
96
+ )
97
+ config. replaySampleRate = sampleRate
98
+ config. textAndInputPrivacyLevel = textAndInputPrivacy
99
+ config. imagePrivacyLevel = imagePrivacy
100
+ config. touchPrivacyLevel = touchPrivacy
101
+ config. customEndpoint = url
102
+
103
+ // Then
104
+ XCTAssertEqual ( config. _swift. replaySampleRate, sampleRate)
105
+ XCTAssertEqual ( config. _swift. textAndInputPrivacyLevel, textAndInputPrivacy. _swift)
106
+ XCTAssertEqual ( config. _swift. imagePrivacyLevel, imagePrivacy. _swift)
107
+ XCTAssertEqual ( config. _swift. touchPrivacyLevel, touchPrivacy. _swift)
44
108
XCTAssertEqual ( config. _swift. customEndpoint, url)
45
109
}
46
110
@@ -54,6 +118,34 @@ class DDSessionReplayTests: XCTestCase {
54
118
XCTAssertEqual ( DDSessionReplayConfigurationPrivacyLevel ( . maskUserInput) , . maskUserInput)
55
119
}
56
120
121
+ func testTextAndInputPrivacyLevelsInterop( ) {
122
+ XCTAssertEqual ( DDTextAndInputPrivacyLevel . maskAll. _swift, . maskAll)
123
+ XCTAssertEqual ( DDTextAndInputPrivacyLevel . maskAllInputs. _swift, . maskAllInputs)
124
+ XCTAssertEqual ( DDTextAndInputPrivacyLevel . maskSensitiveInputs. _swift, . maskSensitiveInputs)
125
+
126
+ XCTAssertEqual ( DDTextAndInputPrivacyLevel ( . maskAll) , . maskAll)
127
+ XCTAssertEqual ( DDTextAndInputPrivacyLevel ( . maskAllInputs) , . maskAllInputs)
128
+ XCTAssertEqual ( DDTextAndInputPrivacyLevel ( . maskSensitiveInputs) , . maskSensitiveInputs)
129
+ }
130
+
131
+ func testImagePrivacyLevelsInterop( ) {
132
+ XCTAssertEqual ( DDImagePrivacyLevel . maskAll. _swift, . maskAll)
133
+ XCTAssertEqual ( DDImagePrivacyLevel . maskNonBundledOnly. _swift, . maskNonBundledOnly)
134
+ XCTAssertEqual ( DDImagePrivacyLevel . maskNone. _swift, . maskNone)
135
+
136
+ XCTAssertEqual ( DDImagePrivacyLevel ( . maskAll) , . maskAll)
137
+ XCTAssertEqual ( DDImagePrivacyLevel ( . maskNonBundledOnly) , . maskNonBundledOnly)
138
+ XCTAssertEqual ( DDImagePrivacyLevel ( . maskNone) , . maskNone)
139
+ }
140
+
141
+ func testTouchPrivacyLevelsInterop( ) {
142
+ XCTAssertEqual ( DDTouchPrivacyLevel . show. _swift, . show)
143
+ XCTAssertEqual ( DDTouchPrivacyLevel . hide. _swift, . hide)
144
+
145
+ XCTAssertEqual ( DDTouchPrivacyLevel ( . show) , . show)
146
+ XCTAssertEqual ( DDTouchPrivacyLevel ( . hide) , . hide)
147
+ }
148
+
57
149
func testWhenEnabled( ) throws {
58
150
// Given
59
151
let core = FeatureRegistrationCoreMock ( )
@@ -69,9 +161,39 @@ class DDSessionReplayTests: XCTestCase {
69
161
let sr = try XCTUnwrap ( core. get ( feature: SessionReplayFeature . self) )
70
162
let requestBuilder = try XCTUnwrap ( sr. requestBuilder as? DatadogSessionReplay . SegmentRequestBuilder )
71
163
XCTAssertEqual ( sr. recordingCoordinator. sampler. samplingRate, 42 )
72
- XCTAssertEqual ( sr. recordingCoordinator. privacy, . mask)
164
+ XCTAssertEqual ( sr. recordingCoordinator. textAndInputPrivacy, . maskAll)
165
+ XCTAssertEqual ( sr. recordingCoordinator. imagePrivacy, . maskAll)
166
+ XCTAssertEqual ( sr. recordingCoordinator. touchPrivacy, . hide)
73
167
XCTAssertNil ( requestBuilder. customUploadURL)
74
168
}
75
- }
76
169
170
+ func testWhenEnabledWithNewApi( ) throws {
171
+ // Given
172
+ let core = FeatureRegistrationCoreMock ( )
173
+ CoreRegistry . register ( default: core)
174
+ let textAndInputPrivacy : DDTextAndInputPrivacyLevel = [ . maskAll, . maskAllInputs, . maskSensitiveInputs] . randomElement ( ) !
175
+ let imagePrivacy : DDImagePrivacyLevel = [ . maskAll, . maskNonBundledOnly, . maskNone] . randomElement ( ) !
176
+ let touchPrivacy : DDTouchPrivacyLevel = [ . show, . hide] . randomElement ( ) !
177
+ defer { CoreRegistry . unregisterDefault ( ) }
178
+
179
+ let config = DDSessionReplayConfiguration (
180
+ replaySampleRate: 42 ,
181
+ textAndInputPrivacyLevel: textAndInputPrivacy,
182
+ imagePrivacyLevel: imagePrivacy,
183
+ touchPrivacyLevel: touchPrivacy
184
+ )
185
+
186
+ // When
187
+ DDSessionReplay . enable ( with: config)
188
+
189
+ // Then
190
+ let sr = try XCTUnwrap ( core. get ( feature: SessionReplayFeature . self) )
191
+ let requestBuilder = try XCTUnwrap ( sr. requestBuilder as? DatadogSessionReplay . SegmentRequestBuilder )
192
+ XCTAssertEqual ( sr. recordingCoordinator. sampler. samplingRate, 42 )
193
+ XCTAssertEqual ( sr. recordingCoordinator. textAndInputPrivacy, textAndInputPrivacy. _swift)
194
+ XCTAssertEqual ( sr. recordingCoordinator. imagePrivacy, imagePrivacy. _swift)
195
+ XCTAssertEqual ( sr. recordingCoordinator. touchPrivacy, touchPrivacy. _swift)
196
+ XCTAssertNil ( requestBuilder. customUploadURL)
197
+ }
198
+ }
77
199
#endif
0 commit comments