@datadog/mobile-react-native-session-replay 2.0.4-alpha.0 → 2.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNativeSessionReplay.podspec +2 -1
- package/android/build.gradle +1 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt +10 -4
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolver.kt +7 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplaySDKWrapper.kt +3 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayWrapper.kt +2 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/TextViewUtils.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +8 -2
- package/android/src/oldarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +8 -2
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementationTest.kt +14 -6
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolverTest.kt +24 -1
- package/ios/Sources/DdSessionReplay.mm +4 -3
- package/ios/Sources/DdSessionReplayImplementation.swift +21 -8
- package/lib/commonjs/SessionReplay.js +9 -5
- package/lib/commonjs/SessionReplay.js.map +1 -1
- package/lib/commonjs/specs/NativeDdSessionReplay.js.map +1 -1
- package/lib/module/SessionReplay.js +9 -5
- package/lib/module/SessionReplay.js.map +1 -1
- package/lib/module/specs/NativeDdSessionReplay.js.map +1 -1
- package/lib/typescript/SessionReplay.d.ts +4 -0
- package/lib/typescript/nativeModulesTypes.d.ts +2 -1
- package/lib/typescript/specs/NativeDdSessionReplay.d.ts +2 -1
- package/package.json +1 -1
- package/src/SessionReplay.ts +21 -5
- package/src/__tests__/SessionReplay.test.ts +10 -5
- package/src/nativeModulesTypes.ts +3 -1
- package/src/specs/NativeDdSessionReplay.ts +3 -1
|
@@ -20,7 +20,8 @@ Pod::Spec.new do |s|
|
|
|
20
20
|
|
|
21
21
|
# /!\ Remember to keep the version in sync with DatadogSDKReactNative.podspec
|
|
22
22
|
s.dependency 'DatadogSessionReplay', '~> 2.6.0'
|
|
23
|
-
|
|
23
|
+
s.dependency 'DatadogSDKReactNative'
|
|
24
|
+
|
|
24
25
|
s.test_spec 'Tests' do |test_spec|
|
|
25
26
|
test_spec.dependency "React-RCTText"
|
|
26
27
|
test_spec.source_files = 'ios/Tests/*.swift'
|
package/android/build.gradle
CHANGED
|
@@ -189,6 +189,7 @@ dependencies {
|
|
|
189
189
|
}
|
|
190
190
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
191
191
|
implementation "com.datadoghq:dd-sdk-android-session-replay:2.5.0"
|
|
192
|
+
implementation project(path: ':datadog_mobile-react-native')
|
|
192
193
|
|
|
193
194
|
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
194
195
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
|
|
@@ -10,6 +10,7 @@ import com.datadog.android.Datadog
|
|
|
10
10
|
import com.datadog.android.api.feature.FeatureSdkCore
|
|
11
11
|
import com.datadog.android.sessionreplay.SessionReplayConfiguration
|
|
12
12
|
import com.datadog.android.sessionreplay.SessionReplayPrivacy
|
|
13
|
+
import com.datadog.reactnative.DatadogSDKWrapperStorage
|
|
13
14
|
import com.facebook.react.bridge.Promise
|
|
14
15
|
import com.facebook.react.bridge.ReactContext
|
|
15
16
|
import java.util.Locale
|
|
@@ -27,15 +28,20 @@ class DdSessionReplayImplementation(
|
|
|
27
28
|
* Enable session replay and start recording session.
|
|
28
29
|
* @param replaySampleRate The sample rate applied for session replay.
|
|
29
30
|
* @param defaultPrivacyLevel The privacy level used for replay.
|
|
31
|
+
* @param customEndpoint Custom server url for sending replay data.
|
|
30
32
|
*/
|
|
31
|
-
fun enable(replaySampleRate: Double, defaultPrivacyLevel: String, promise: Promise) {
|
|
32
|
-
val sdkCore =
|
|
33
|
+
fun enable(replaySampleRate: Double, defaultPrivacyLevel: String, customEndpoint: String, promise: Promise) {
|
|
34
|
+
val sdkCore = DatadogSDKWrapperStorage.getSdkCore() as FeatureSdkCore
|
|
33
35
|
val logger = sdkCore.internalLogger
|
|
34
36
|
val configuration = SessionReplayConfiguration.Builder(replaySampleRate.toFloat())
|
|
35
37
|
.setPrivacy(buildPrivacy(defaultPrivacyLevel))
|
|
36
38
|
.addExtensionSupport(ReactNativeSessionReplayExtensionSupport(reactContext, logger))
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
|
|
40
|
+
if (customEndpoint != "") {
|
|
41
|
+
configuration.useCustomEndpoint(customEndpoint)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
sessionReplayProvider().enable(configuration.build(), sdkCore)
|
|
39
45
|
promise.resolve(null)
|
|
40
46
|
}
|
|
41
47
|
|
package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolver.kt
CHANGED
|
@@ -144,6 +144,12 @@ internal class ReactTextPropertiesResolver(
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
private fun getTextColor(shadowNodeWrapper: ShadowNodeWrapper): String? {
|
|
147
|
+
val isColorSet = shadowNodeWrapper
|
|
148
|
+
.getDeclaredShadowNodeField(IS_COLOR_SET_FIELD_NAME) as Boolean?
|
|
149
|
+
if (isColorSet != true) {
|
|
150
|
+
// Improvement: get default text color if different from black
|
|
151
|
+
return "#000000FF"
|
|
152
|
+
}
|
|
147
153
|
val resolvedColor = shadowNodeWrapper
|
|
148
154
|
.getDeclaredShadowNodeField(COLOR_FIELD_NAME) as Int?
|
|
149
155
|
if (resolvedColor != null) {
|
|
@@ -187,6 +193,7 @@ internal class ReactTextPropertiesResolver(
|
|
|
187
193
|
internal const val TEXT_ATTRIBUTES_FIELD_NAME = "mTextAttributes"
|
|
188
194
|
internal const val FONT_FAMILY_FIELD_NAME = "mFontFamily"
|
|
189
195
|
internal const val COLOR_FIELD_NAME = "mColor"
|
|
196
|
+
internal const val IS_COLOR_SET_FIELD_NAME = "mIsColorSet"
|
|
190
197
|
|
|
191
198
|
private const val ROBOTO_TYPEFACE_NAME = "roboto"
|
|
192
199
|
private const val SERIF_FAMILY_NAME = "serif"
|
package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplaySDKWrapper.kt
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative.sessionreplay
|
|
8
8
|
|
|
9
|
+
import com.datadog.android.api.SdkCore
|
|
9
10
|
import com.datadog.android.sessionreplay.SessionReplay
|
|
10
11
|
import com.datadog.android.sessionreplay.SessionReplayConfiguration
|
|
11
12
|
|
|
@@ -16,9 +17,11 @@ internal class SessionReplaySDKWrapper : SessionReplayWrapper {
|
|
|
16
17
|
*/
|
|
17
18
|
override fun enable(
|
|
18
19
|
sessionReplayConfiguration: SessionReplayConfiguration,
|
|
20
|
+
sdkCore: SdkCore
|
|
19
21
|
) {
|
|
20
22
|
SessionReplay.enable(
|
|
21
23
|
sessionReplayConfiguration,
|
|
24
|
+
sdkCore,
|
|
22
25
|
)
|
|
23
26
|
}
|
|
24
27
|
}
|
package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayWrapper.kt
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative.sessionreplay
|
|
8
8
|
|
|
9
|
+
import com.datadog.android.api.SdkCore
|
|
9
10
|
import com.datadog.android.sessionreplay.SessionReplayConfiguration
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -18,5 +19,6 @@ interface SessionReplayWrapper {
|
|
|
18
19
|
*/
|
|
19
20
|
fun enable(
|
|
20
21
|
sessionReplayConfiguration: SessionReplayConfiguration,
|
|
22
|
+
sdkCore: SdkCore
|
|
21
23
|
)
|
|
22
24
|
}
|
package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/TextViewUtils.kt
CHANGED
|
@@ -23,7 +23,7 @@ internal class TextViewUtils {
|
|
|
23
23
|
val result = mutableListOf<MobileSegment.Wireframe>()
|
|
24
24
|
val pixelDensity = mappingContext.systemInformation.screenDensity
|
|
25
25
|
|
|
26
|
-
wireframes
|
|
26
|
+
for (originalWireframe in wireframes) {
|
|
27
27
|
if (originalWireframe !is MobileSegment.Wireframe.TextWireframe) {
|
|
28
28
|
result.add(originalWireframe)
|
|
29
29
|
} else {
|
|
@@ -25,9 +25,15 @@ class DdSessionReplay(
|
|
|
25
25
|
* Enable session replay and start recording session.
|
|
26
26
|
* @param replaySampleRate The sample rate applied for session replay.
|
|
27
27
|
* @param defaultPrivacyLevel The privacy level used for replay.
|
|
28
|
+
* @param customEndpoint Custom server url for sending replay data.
|
|
28
29
|
*/
|
|
29
30
|
@ReactMethod
|
|
30
|
-
override fun enable(
|
|
31
|
-
|
|
31
|
+
override fun enable(
|
|
32
|
+
replaySampleRate: Double,
|
|
33
|
+
defaultPrivacyLevel: String,
|
|
34
|
+
customEndpoint: String,
|
|
35
|
+
promise: Promise
|
|
36
|
+
) {
|
|
37
|
+
implementation.enable(replaySampleRate, defaultPrivacyLevel, customEndpoint, promise)
|
|
32
38
|
}
|
|
33
39
|
}
|
|
@@ -26,9 +26,15 @@ class DdSessionReplay(
|
|
|
26
26
|
* Enable session replay and start recording session.
|
|
27
27
|
* @param replaySampleRate The sample rate applied for session replay.
|
|
28
28
|
* @param defaultPrivacyLevel The privacy level used for replay.
|
|
29
|
+
* @param customEndpoint Custom server url for sending replay data.
|
|
29
30
|
*/
|
|
30
31
|
@ReactMethod
|
|
31
|
-
fun enable(
|
|
32
|
-
|
|
32
|
+
fun enable(
|
|
33
|
+
replaySampleRate: Double,
|
|
34
|
+
defaultPrivacyLevel: String,
|
|
35
|
+
customEndpoint: String,
|
|
36
|
+
promise: Promise
|
|
37
|
+
) {
|
|
38
|
+
implementation.enable(replaySampleRate, defaultPrivacyLevel, customEndpoint, promise)
|
|
33
39
|
}
|
|
34
40
|
}
|
|
@@ -69,23 +69,30 @@ internal class DdSessionReplayImplementationTest {
|
|
|
69
69
|
@Test
|
|
70
70
|
fun `M enable session replay W enable()`(
|
|
71
71
|
@DoubleForgery(min = 0.0, max = 100.0) replaySampleRate: Double,
|
|
72
|
-
@Forgery privacy: SessionReplayPrivacy
|
|
72
|
+
@Forgery privacy: SessionReplayPrivacy,
|
|
73
|
+
@StringForgery(regex = ".+") customEndpoint: String
|
|
73
74
|
) {
|
|
74
75
|
// Given
|
|
75
76
|
val sessionReplayConfigCaptor = argumentCaptor<SessionReplayConfiguration>()
|
|
76
77
|
|
|
77
78
|
// When
|
|
78
|
-
testedSessionReplay.enable(
|
|
79
|
+
testedSessionReplay.enable(
|
|
80
|
+
replaySampleRate,
|
|
81
|
+
privacy.toString(),
|
|
82
|
+
customEndpoint,
|
|
83
|
+
mockPromise
|
|
84
|
+
)
|
|
79
85
|
|
|
80
86
|
// Then
|
|
81
|
-
verify(mockSessionReplay).enable(sessionReplayConfigCaptor.capture())
|
|
87
|
+
verify(mockSessionReplay).enable(sessionReplayConfigCaptor.capture(), any())
|
|
82
88
|
assertThat(sessionReplayConfigCaptor.firstValue)
|
|
83
89
|
.hasFieldEqualTo("sampleRate", replaySampleRate.toFloat())
|
|
84
90
|
.hasFieldEqualTo("privacy", privacy)
|
|
91
|
+
.hasFieldEqualTo("customEndpointUrl", customEndpoint)
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
@Test
|
|
88
|
-
fun `M enable session replay
|
|
95
|
+
fun `M enable session replay without custom endpoint W empty string()`(
|
|
89
96
|
@DoubleForgery(min = 0.0, max = 100.0) replaySampleRate: Double,
|
|
90
97
|
// Not ALLOW nor MASK_USER_INPUT
|
|
91
98
|
@StringForgery(regex = "^/(?!ALLOW|MASK_USER_INPUT)([a-z0-9]+)$/i") privacy: String
|
|
@@ -94,12 +101,13 @@ internal class DdSessionReplayImplementationTest {
|
|
|
94
101
|
val sessionReplayConfigCaptor = argumentCaptor<SessionReplayConfiguration>()
|
|
95
102
|
|
|
96
103
|
// When
|
|
97
|
-
testedSessionReplay.enable(replaySampleRate, privacy, mockPromise)
|
|
104
|
+
testedSessionReplay.enable(replaySampleRate, privacy, "", mockPromise)
|
|
98
105
|
|
|
99
106
|
// Then
|
|
100
|
-
verify(mockSessionReplay).enable(sessionReplayConfigCaptor.capture())
|
|
107
|
+
verify(mockSessionReplay).enable(sessionReplayConfigCaptor.capture(), any())
|
|
101
108
|
assertThat(sessionReplayConfigCaptor.firstValue)
|
|
102
109
|
.hasFieldEqualTo("sampleRate", replaySampleRate.toFloat())
|
|
103
110
|
.hasFieldEqualTo("privacy", SessionReplayPrivacy.MASK)
|
|
111
|
+
.doesNotHaveField("customEndpointUrl")
|
|
104
112
|
}
|
|
105
113
|
}
|
|
@@ -10,6 +10,7 @@ import android.widget.TextView
|
|
|
10
10
|
import com.datadog.android.sessionreplay.model.MobileSegment
|
|
11
11
|
import com.datadog.reactnative.sessionreplay.ReactTextPropertiesResolver.Companion.COLOR_FIELD_NAME
|
|
12
12
|
import com.datadog.reactnative.sessionreplay.ReactTextPropertiesResolver.Companion.FONT_FAMILY_FIELD_NAME
|
|
13
|
+
import com.datadog.reactnative.sessionreplay.ReactTextPropertiesResolver.Companion.IS_COLOR_SET_FIELD_NAME
|
|
13
14
|
import com.datadog.reactnative.sessionreplay.ReactTextPropertiesResolver.Companion.MONOSPACE_FAMILY_NAME
|
|
14
15
|
import com.datadog.reactnative.sessionreplay.ReactTextPropertiesResolver.Companion.TEXT_ATTRIBUTES_FIELD_NAME
|
|
15
16
|
import com.datadog.reactnative.sessionreplay.ShadowNodeWrapper.Companion.UI_IMPLEMENTATION_FIELD_NAME
|
|
@@ -238,11 +239,13 @@ internal class ReactTextPropertiesResolverTest {
|
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
@Test
|
|
241
|
-
fun `M resolve font color W addReactNativeProperties()`(
|
|
242
|
+
fun `M resolve font color W addReactNativeProperties() { color is defined by developer }`(
|
|
242
243
|
@IntForgery fakeTextColor: Int
|
|
243
244
|
) {
|
|
244
245
|
// Given
|
|
245
246
|
whenever(mockTextView.background).thenReturn(null)
|
|
247
|
+
whenever(mockReflectionUtils.getDeclaredField(mockShadowNode, IS_COLOR_SET_FIELD_NAME))
|
|
248
|
+
.thenReturn(true)
|
|
246
249
|
whenever(mockReflectionUtils.getDeclaredField(mockShadowNode, COLOR_FIELD_NAME))
|
|
247
250
|
.thenReturn(fakeTextColor)
|
|
248
251
|
|
|
@@ -253,10 +256,30 @@ internal class ReactTextPropertiesResolverTest {
|
|
|
253
256
|
assertThat(result.textStyle.color).isEqualTo(formatAsRgba(fakeTextColor))
|
|
254
257
|
}
|
|
255
258
|
|
|
259
|
+
@Test
|
|
260
|
+
fun `M resolve font color W addReactNativeProperties() { color is not defined by developer }`(
|
|
261
|
+
@IntForgery fakeTextColor: Int
|
|
262
|
+
) {
|
|
263
|
+
// Given
|
|
264
|
+
whenever(mockTextView.background).thenReturn(null)
|
|
265
|
+
whenever(mockReflectionUtils.getDeclaredField(mockShadowNode, IS_COLOR_SET_FIELD_NAME))
|
|
266
|
+
.thenReturn(false)
|
|
267
|
+
whenever(mockReflectionUtils.getDeclaredField(mockShadowNode, COLOR_FIELD_NAME))
|
|
268
|
+
.thenReturn(fakeTextColor)
|
|
269
|
+
|
|
270
|
+
// When
|
|
271
|
+
val result = testedResolver.addReactNativeProperties(fakeWireframe, mockTextView, 0f)
|
|
272
|
+
|
|
273
|
+
// Then
|
|
274
|
+
assertThat(result.textStyle.color).isEqualTo("#000000FF")
|
|
275
|
+
}
|
|
276
|
+
|
|
256
277
|
@Test
|
|
257
278
|
fun `M fallback W addReactNativeProperties() { cannot resolve fontColor }`() {
|
|
258
279
|
// Given
|
|
259
280
|
whenever(mockTextView.background).thenReturn(null)
|
|
281
|
+
whenever(mockReflectionUtils.getDeclaredField(mockShadowNode, IS_COLOR_SET_FIELD_NAME))
|
|
282
|
+
.thenReturn(true)
|
|
260
283
|
whenever(mockShadowNodeWrapper.getDeclaredShadowNodeField(COLOR_FIELD_NAME))
|
|
261
284
|
.thenReturn(null)
|
|
262
285
|
|
|
@@ -19,10 +19,11 @@ RCT_EXPORT_MODULE()
|
|
|
19
19
|
|
|
20
20
|
RCT_REMAP_METHOD(enable, withEnableReplaySampleRate:(double)replaySampleRate
|
|
21
21
|
withDefaultPrivacyLevel:(NSString*)defaultPrivacyLevel
|
|
22
|
+
withCustomEndpoint:(NSString*)customEndpoint
|
|
22
23
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
23
24
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
24
25
|
{
|
|
25
|
-
[self enable:replaySampleRate defaultPrivacyLevel:defaultPrivacyLevel resolve:resolve reject:reject];
|
|
26
|
+
[self enable:replaySampleRate defaultPrivacyLevel:defaultPrivacyLevel customEndpoint:customEndpoint resolve:resolve reject:reject];
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
// Thanks to this guard, we won't compile this code when we build for the old architecture.
|
|
@@ -46,8 +47,8 @@ RCT_REMAP_METHOD(enable, withEnableReplaySampleRate:(double)replaySampleRate
|
|
|
46
47
|
return NO;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
- (void)enable:(double)replaySampleRate defaultPrivacyLevel:(NSString *)defaultPrivacyLevel resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
50
|
-
[self.ddSessionReplayImplementation enableWithReplaySampleRate:replaySampleRate defaultPrivacyLevel:defaultPrivacyLevel resolve:resolve reject:reject];
|
|
50
|
+
- (void)enable:(double)replaySampleRate defaultPrivacyLevel:(NSString *)defaultPrivacyLevel customEndpoint:(NSString*)customEndpoint resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
51
|
+
[self.ddSessionReplayImplementation enableWithReplaySampleRate:replaySampleRate defaultPrivacyLevel:defaultPrivacyLevel customEndpoint:customEndpoint resolve:resolve reject:reject];
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
@end
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import Foundation
|
|
8
8
|
@_spi(Internal) import DatadogSessionReplay
|
|
9
9
|
import DatadogInternal
|
|
10
|
+
import DatadogSDKReactNative
|
|
10
11
|
import React
|
|
11
12
|
|
|
12
13
|
@objc
|
|
@@ -29,17 +30,28 @@ public class DdSessionReplayImplementation: NSObject {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
@objc
|
|
32
|
-
public func enable(replaySampleRate: Double, defaultPrivacyLevel: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
33
|
+
public func enable(replaySampleRate: Double, defaultPrivacyLevel: String, customEndpoint: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
34
|
+
var customEndpointURL: URL? = nil
|
|
35
|
+
if (customEndpoint != "") {
|
|
36
|
+
customEndpointURL = URL(string: "\(customEndpoint)/api/v2/replay" as String)
|
|
37
|
+
}
|
|
33
38
|
var sessionReplayConfiguration = SessionReplay.Configuration(
|
|
34
39
|
replaySampleRate: Float(replaySampleRate),
|
|
35
|
-
defaultPrivacyLevel: buildPrivacyLevel(privacyLevel: defaultPrivacyLevel as NSString)
|
|
40
|
+
defaultPrivacyLevel: buildPrivacyLevel(privacyLevel: defaultPrivacyLevel as NSString),
|
|
41
|
+
customEndpoint: customEndpointURL
|
|
36
42
|
)
|
|
37
43
|
|
|
38
44
|
sessionReplayConfiguration.setAdditionalNodeRecorders([RCTTextViewRecorder(uiManager: self.uiManager)])
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
if let core = DatadogSDKWrapper.shared.getCoreInstance() {
|
|
47
|
+
sessionReplay.enable(
|
|
48
|
+
with: sessionReplayConfiguration,
|
|
49
|
+
in: core
|
|
50
|
+
)
|
|
51
|
+
} else {
|
|
52
|
+
consolePrint("Core instance was not found when initializing Session Replay.")
|
|
53
|
+
}
|
|
54
|
+
|
|
43
55
|
resolve(nil)
|
|
44
56
|
}
|
|
45
57
|
|
|
@@ -59,12 +71,13 @@ public class DdSessionReplayImplementation: NSObject {
|
|
|
59
71
|
|
|
60
72
|
internal protocol SessionReplayProtocol {
|
|
61
73
|
func enable(
|
|
62
|
-
with configuration: SessionReplay.Configuration
|
|
74
|
+
with configuration: SessionReplay.Configuration,
|
|
75
|
+
in core: DatadogCoreProtocol
|
|
63
76
|
)
|
|
64
77
|
}
|
|
65
78
|
|
|
66
79
|
internal class NativeSessionReplay: SessionReplayProtocol {
|
|
67
|
-
func enable(with configuration: DatadogSessionReplay.SessionReplay.Configuration) {
|
|
68
|
-
SessionReplay.enable(with: configuration)
|
|
80
|
+
func enable(with configuration: DatadogSessionReplay.SessionReplay.Configuration, in core: DatadogCoreProtocol) {
|
|
81
|
+
SessionReplay.enable(with: configuration, in: core)
|
|
69
82
|
}
|
|
70
83
|
}
|
|
@@ -27,7 +27,8 @@ exports.SessionReplayPrivacy = SessionReplayPrivacy;
|
|
|
27
27
|
|
|
28
28
|
const DEFAULTS = {
|
|
29
29
|
replaySampleRate: 0,
|
|
30
|
-
defaultPrivacyLevel: SessionReplayPrivacy.MASK
|
|
30
|
+
defaultPrivacyLevel: SessionReplayPrivacy.MASK,
|
|
31
|
+
customEndpoint: ''
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
class SessionReplayWrapper {
|
|
@@ -41,20 +42,23 @@ class SessionReplayWrapper {
|
|
|
41
42
|
|
|
42
43
|
const {
|
|
43
44
|
replaySampleRate,
|
|
44
|
-
defaultPrivacyLevel
|
|
45
|
+
defaultPrivacyLevel,
|
|
46
|
+
customEndpoint
|
|
45
47
|
} = configuration;
|
|
46
48
|
return {
|
|
47
49
|
replaySampleRate: replaySampleRate !== undefined ? replaySampleRate : DEFAULTS.replaySampleRate,
|
|
48
|
-
defaultPrivacyLevel: defaultPrivacyLevel !== undefined ? defaultPrivacyLevel : DEFAULTS.defaultPrivacyLevel
|
|
50
|
+
defaultPrivacyLevel: defaultPrivacyLevel !== undefined ? defaultPrivacyLevel : DEFAULTS.defaultPrivacyLevel,
|
|
51
|
+
customEndpoint: customEndpoint !== undefined ? customEndpoint : DEFAULTS.customEndpoint
|
|
49
52
|
};
|
|
50
53
|
});
|
|
51
54
|
|
|
52
55
|
_defineProperty(this, "enable", configuration => {
|
|
53
56
|
const {
|
|
54
57
|
replaySampleRate,
|
|
55
|
-
defaultPrivacyLevel
|
|
58
|
+
defaultPrivacyLevel,
|
|
59
|
+
customEndpoint
|
|
56
60
|
} = this.buildConfiguration(configuration);
|
|
57
|
-
return this.nativeSessionReplay.enable(replaySampleRate, defaultPrivacyLevel);
|
|
61
|
+
return this.nativeSessionReplay.enable(replaySampleRate, defaultPrivacyLevel, customEndpoint);
|
|
58
62
|
});
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["SessionReplay.ts"],"names":["SessionReplayPrivacy","DEFAULTS","replaySampleRate","defaultPrivacyLevel","MASK","SessionReplayWrapper","require","default","configuration","undefined","buildConfiguration","nativeSessionReplay","enable","SessionReplay"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;IAIYA,oB;AAMZ;AACA;AACA;;;;WARYA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;GAAAA,oB,oCAAAA,oB;;
|
|
1
|
+
{"version":3,"sources":["SessionReplay.ts"],"names":["SessionReplayPrivacy","DEFAULTS","replaySampleRate","defaultPrivacyLevel","MASK","customEndpoint","SessionReplayWrapper","require","default","configuration","undefined","buildConfiguration","nativeSessionReplay","enable","SessionReplay"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;IAIYA,oB;AAMZ;AACA;AACA;;;;WARYA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;GAAAA,oB,oCAAAA,oB;;AA8BZ,MAAMC,QAAQ,GAAG;AACbC,EAAAA,gBAAgB,EAAE,CADL;AAEbC,EAAAA,mBAAmB,EAAEH,oBAAoB,CAACI,IAF7B;AAGbC,EAAAA,cAAc,EAAE;AAHH,CAAjB;;AAMO,MAAMC,oBAAN,CAA2B;AAAA;AAAA,iDAEyBC,OAAO,CAAC,+BAAD,CAAP,CAClDC,OAHyB;;AAAA,gDAM1BC,aADyB,IAMxB;AACD,UAAI,CAACA,aAAL,EAAoB;AAChB,eAAOR,QAAP;AACH;;AACD,YAAM;AACFC,QAAAA,gBADE;AAEFC,QAAAA,mBAFE;AAGFE,QAAAA;AAHE,UAIFI,aAJJ;AAKA,aAAO;AACHP,QAAAA,gBAAgB,EACZA,gBAAgB,KAAKQ,SAArB,GACMR,gBADN,GAEMD,QAAQ,CAACC,gBAJhB;AAKHC,QAAAA,mBAAmB,EACfA,mBAAmB,KAAKO,SAAxB,GACMP,mBADN,GAEMF,QAAQ,CAACE,mBARhB;AASHE,QAAAA,cAAc,EACVA,cAAc,KAAKK,SAAnB,GACML,cADN,GAEMJ,QAAQ,CAACI;AAZhB,OAAP;AAcH,KAlC6B;;AAAA,oCAwCpBI,aAAD,IAA+D;AACpE,YAAM;AACFP,QAAAA,gBADE;AAEFC,QAAAA,mBAFE;AAGFE,QAAAA;AAHE,UAIF,KAAKM,kBAAL,CAAwBF,aAAxB,CAJJ;AAMA,aAAO,KAAKG,mBAAL,CAAyBC,MAAzB,CACHX,gBADG,EAEHC,mBAFG,EAGHE,cAHG,CAAP;AAKH,KApD6B;AAAA;;AAAA;;;AAuD3B,MAAMS,aAAa,GAAG,IAAIR,oBAAJ,EAAtB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { NativeSessionReplayType } from './nativeModulesTypes';\n\nexport enum SessionReplayPrivacy {\n MASK = 'MASK',\n ALLOW = 'ALLOW',\n MASK_USER_INPUT = 'MASK_USER_INPUT'\n}\n\n/**\n * The Session Replay configuration object.\n */\nexport interface SessionReplayConfiguration {\n /**\n * The sampling rate for Session Replay.\n * It is applied in addition to the RUM session sample rate.\n * Range `0`-`100`.\n *\n * Default value is `20`.\n */\n replaySampleRate?: number;\n /**\n * Defines the way sensitive content (e.g. text) should be masked.\n *\n * Default `SessionReplayPrivacy.MASK`.\n */\n defaultPrivacyLevel?: SessionReplayPrivacy;\n /**\n * Custom server url for sending replay data.\n */\n customEndpoint?: string;\n}\n\nconst DEFAULTS = {\n replaySampleRate: 0,\n defaultPrivacyLevel: SessionReplayPrivacy.MASK,\n customEndpoint: ''\n};\n\nexport class SessionReplayWrapper {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeSessionReplay: NativeSessionReplayType = require('./specs/NativeDdSessionReplay')\n .default;\n\n private buildConfiguration = (\n configuration?: SessionReplayConfiguration\n ): {\n replaySampleRate: number;\n defaultPrivacyLevel: SessionReplayPrivacy;\n customEndpoint: string;\n } => {\n if (!configuration) {\n return DEFAULTS;\n }\n const {\n replaySampleRate,\n defaultPrivacyLevel,\n customEndpoint\n } = configuration;\n return {\n replaySampleRate:\n replaySampleRate !== undefined\n ? replaySampleRate\n : DEFAULTS.replaySampleRate,\n defaultPrivacyLevel:\n defaultPrivacyLevel !== undefined\n ? defaultPrivacyLevel\n : DEFAULTS.defaultPrivacyLevel,\n customEndpoint:\n customEndpoint !== undefined\n ? customEndpoint\n : DEFAULTS.customEndpoint\n };\n };\n\n /**\n * Enable session replay and start recording session.\n * @param configuration: The session replay configuration.\n */\n enable = (configuration?: SessionReplayConfiguration): Promise<void> => {\n const {\n replaySampleRate,\n defaultPrivacyLevel,\n customEndpoint\n } = this.buildConfiguration(configuration);\n\n return this.nativeSessionReplay.enable(\n replaySampleRate,\n defaultPrivacyLevel,\n customEndpoint\n );\n };\n}\n\nexport const SessionReplay = new SessionReplayWrapper();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeDdSessionReplay.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;
|
|
1
|
+
{"version":3,"sources":["NativeDdSessionReplay.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;eAuBeA,iCAAoBC,GAApB,CAA8B,iBAA9B,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use NativeSessionReplayType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Enable session replay and start recording session.\n * @param replaySampleRate: The sample rate applied for session replay.\n * @param defaultPrivacyLevel: The privacy level used for replay.\n * @param customEndpoint: Custom server url for sending replay data.\n */\n enable(\n replaySampleRate: number,\n defaultPrivacyLevel: string,\n customEndpoint: string\n ): Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdSessionReplay');\n"]}
|
|
@@ -18,7 +18,8 @@ export let SessionReplayPrivacy;
|
|
|
18
18
|
|
|
19
19
|
const DEFAULTS = {
|
|
20
20
|
replaySampleRate: 0,
|
|
21
|
-
defaultPrivacyLevel: SessionReplayPrivacy.MASK
|
|
21
|
+
defaultPrivacyLevel: SessionReplayPrivacy.MASK,
|
|
22
|
+
customEndpoint: ''
|
|
22
23
|
};
|
|
23
24
|
export class SessionReplayWrapper {
|
|
24
25
|
constructor() {
|
|
@@ -31,20 +32,23 @@ export class SessionReplayWrapper {
|
|
|
31
32
|
|
|
32
33
|
const {
|
|
33
34
|
replaySampleRate,
|
|
34
|
-
defaultPrivacyLevel
|
|
35
|
+
defaultPrivacyLevel,
|
|
36
|
+
customEndpoint
|
|
35
37
|
} = configuration;
|
|
36
38
|
return {
|
|
37
39
|
replaySampleRate: replaySampleRate !== undefined ? replaySampleRate : DEFAULTS.replaySampleRate,
|
|
38
|
-
defaultPrivacyLevel: defaultPrivacyLevel !== undefined ? defaultPrivacyLevel : DEFAULTS.defaultPrivacyLevel
|
|
40
|
+
defaultPrivacyLevel: defaultPrivacyLevel !== undefined ? defaultPrivacyLevel : DEFAULTS.defaultPrivacyLevel,
|
|
41
|
+
customEndpoint: customEndpoint !== undefined ? customEndpoint : DEFAULTS.customEndpoint
|
|
39
42
|
};
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
_defineProperty(this, "enable", configuration => {
|
|
43
46
|
const {
|
|
44
47
|
replaySampleRate,
|
|
45
|
-
defaultPrivacyLevel
|
|
48
|
+
defaultPrivacyLevel,
|
|
49
|
+
customEndpoint
|
|
46
50
|
} = this.buildConfiguration(configuration);
|
|
47
|
-
return this.nativeSessionReplay.enable(replaySampleRate, defaultPrivacyLevel);
|
|
51
|
+
return this.nativeSessionReplay.enable(replaySampleRate, defaultPrivacyLevel, customEndpoint);
|
|
48
52
|
});
|
|
49
53
|
}
|
|
50
54
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["SessionReplay.ts"],"names":["SessionReplayPrivacy","DEFAULTS","replaySampleRate","defaultPrivacyLevel","MASK","SessionReplayWrapper","require","default","configuration","undefined","buildConfiguration","nativeSessionReplay","enable","SessionReplay"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,WAAYA,oBAAZ;AAMA;AACA;AACA;;WARYA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;GAAAA,oB,KAAAA,oB;;
|
|
1
|
+
{"version":3,"sources":["SessionReplay.ts"],"names":["SessionReplayPrivacy","DEFAULTS","replaySampleRate","defaultPrivacyLevel","MASK","customEndpoint","SessionReplayWrapper","require","default","configuration","undefined","buildConfiguration","nativeSessionReplay","enable","SessionReplay"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,WAAYA,oBAAZ;AAMA;AACA;AACA;;WARYA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;GAAAA,oB,KAAAA,oB;;AA8BZ,MAAMC,QAAQ,GAAG;AACbC,EAAAA,gBAAgB,EAAE,CADL;AAEbC,EAAAA,mBAAmB,EAAEH,oBAAoB,CAACI,IAF7B;AAGbC,EAAAA,cAAc,EAAE;AAHH,CAAjB;AAMA,OAAO,MAAMC,oBAAN,CAA2B;AAAA;AAAA,iDAEyBC,OAAO,CAAC,+BAAD,CAAP,CAClDC,OAHyB;;AAAA,gDAM1BC,aADyB,IAMxB;AACD,UAAI,CAACA,aAAL,EAAoB;AAChB,eAAOR,QAAP;AACH;;AACD,YAAM;AACFC,QAAAA,gBADE;AAEFC,QAAAA,mBAFE;AAGFE,QAAAA;AAHE,UAIFI,aAJJ;AAKA,aAAO;AACHP,QAAAA,gBAAgB,EACZA,gBAAgB,KAAKQ,SAArB,GACMR,gBADN,GAEMD,QAAQ,CAACC,gBAJhB;AAKHC,QAAAA,mBAAmB,EACfA,mBAAmB,KAAKO,SAAxB,GACMP,mBADN,GAEMF,QAAQ,CAACE,mBARhB;AASHE,QAAAA,cAAc,EACVA,cAAc,KAAKK,SAAnB,GACML,cADN,GAEMJ,QAAQ,CAACI;AAZhB,OAAP;AAcH,KAlC6B;;AAAA,oCAwCpBI,aAAD,IAA+D;AACpE,YAAM;AACFP,QAAAA,gBADE;AAEFC,QAAAA,mBAFE;AAGFE,QAAAA;AAHE,UAIF,KAAKM,kBAAL,CAAwBF,aAAxB,CAJJ;AAMA,aAAO,KAAKG,mBAAL,CAAyBC,MAAzB,CACHX,gBADG,EAEHC,mBAFG,EAGHE,cAHG,CAAP;AAKH,KApD6B;AAAA;;AAAA;AAuDlC,OAAO,MAAMS,aAAa,GAAG,IAAIR,oBAAJ,EAAtB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { NativeSessionReplayType } from './nativeModulesTypes';\n\nexport enum SessionReplayPrivacy {\n MASK = 'MASK',\n ALLOW = 'ALLOW',\n MASK_USER_INPUT = 'MASK_USER_INPUT'\n}\n\n/**\n * The Session Replay configuration object.\n */\nexport interface SessionReplayConfiguration {\n /**\n * The sampling rate for Session Replay.\n * It is applied in addition to the RUM session sample rate.\n * Range `0`-`100`.\n *\n * Default value is `20`.\n */\n replaySampleRate?: number;\n /**\n * Defines the way sensitive content (e.g. text) should be masked.\n *\n * Default `SessionReplayPrivacy.MASK`.\n */\n defaultPrivacyLevel?: SessionReplayPrivacy;\n /**\n * Custom server url for sending replay data.\n */\n customEndpoint?: string;\n}\n\nconst DEFAULTS = {\n replaySampleRate: 0,\n defaultPrivacyLevel: SessionReplayPrivacy.MASK,\n customEndpoint: ''\n};\n\nexport class SessionReplayWrapper {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeSessionReplay: NativeSessionReplayType = require('./specs/NativeDdSessionReplay')\n .default;\n\n private buildConfiguration = (\n configuration?: SessionReplayConfiguration\n ): {\n replaySampleRate: number;\n defaultPrivacyLevel: SessionReplayPrivacy;\n customEndpoint: string;\n } => {\n if (!configuration) {\n return DEFAULTS;\n }\n const {\n replaySampleRate,\n defaultPrivacyLevel,\n customEndpoint\n } = configuration;\n return {\n replaySampleRate:\n replaySampleRate !== undefined\n ? replaySampleRate\n : DEFAULTS.replaySampleRate,\n defaultPrivacyLevel:\n defaultPrivacyLevel !== undefined\n ? defaultPrivacyLevel\n : DEFAULTS.defaultPrivacyLevel,\n customEndpoint:\n customEndpoint !== undefined\n ? customEndpoint\n : DEFAULTS.customEndpoint\n };\n };\n\n /**\n * Enable session replay and start recording session.\n * @param configuration: The session replay configuration.\n */\n enable = (configuration?: SessionReplayConfiguration): Promise<void> => {\n const {\n replaySampleRate,\n defaultPrivacyLevel,\n customEndpoint\n } = this.buildConfiguration(configuration);\n\n return this.nativeSessionReplay.enable(\n replaySampleRate,\n defaultPrivacyLevel,\n customEndpoint\n );\n };\n}\n\nexport const SessionReplay = new SessionReplayWrapper();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeDdSessionReplay.ts"],"names":["TurboModuleRegistry","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AAEA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;;
|
|
1
|
+
{"version":3,"sources":["NativeDdSessionReplay.ts"],"names":["TurboModuleRegistry","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AAEA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;;AAiBA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,iBAA9B,CAAf","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use NativeSessionReplayType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Enable session replay and start recording session.\n * @param replaySampleRate: The sample rate applied for session replay.\n * @param defaultPrivacyLevel: The privacy level used for replay.\n * @param customEndpoint: Custom server url for sending replay data.\n */\n enable(\n replaySampleRate: number,\n defaultPrivacyLevel: string,\n customEndpoint: string\n ): Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdSessionReplay');\n"]}
|
|
@@ -21,6 +21,10 @@ export interface SessionReplayConfiguration {
|
|
|
21
21
|
* Default `SessionReplayPrivacy.MASK`.
|
|
22
22
|
*/
|
|
23
23
|
defaultPrivacyLevel?: SessionReplayPrivacy;
|
|
24
|
+
/**
|
|
25
|
+
* Custom server url for sending replay data.
|
|
26
|
+
*/
|
|
27
|
+
customEndpoint?: string;
|
|
24
28
|
}
|
|
25
29
|
export declare class SessionReplayWrapper {
|
|
26
30
|
private nativeSessionReplay;
|
|
@@ -12,7 +12,8 @@ export interface NativeSessionReplayType extends NativeDdSessionReplay {
|
|
|
12
12
|
* Enable session replay and start recording session.
|
|
13
13
|
* @param replaySampleRate: The sample rate applied for session replay.
|
|
14
14
|
* @param defaultPrivacyLevel: The privacy level used for replay.
|
|
15
|
+
* @param customEndpoint: Custom server url for sending replay data.
|
|
15
16
|
*/
|
|
16
|
-
enable(replaySampleRate: number, defaultPrivacyLevel: PrivacyLevel): Promise<void>;
|
|
17
|
+
enable(replaySampleRate: number, defaultPrivacyLevel: PrivacyLevel, customEndpoint: string): Promise<void>;
|
|
17
18
|
}
|
|
18
19
|
export {};
|
|
@@ -8,8 +8,9 @@ export interface Spec extends TurboModule {
|
|
|
8
8
|
* Enable session replay and start recording session.
|
|
9
9
|
* @param replaySampleRate: The sample rate applied for session replay.
|
|
10
10
|
* @param defaultPrivacyLevel: The privacy level used for replay.
|
|
11
|
+
* @param customEndpoint: Custom server url for sending replay data.
|
|
11
12
|
*/
|
|
12
|
-
enable(replaySampleRate: number, defaultPrivacyLevel: string): Promise<void>;
|
|
13
|
+
enable(replaySampleRate: number, defaultPrivacyLevel: string, customEndpoint: string): Promise<void>;
|
|
13
14
|
}
|
|
14
15
|
declare const _default: Spec | null;
|
|
15
16
|
export default _default;
|
package/package.json
CHANGED
package/src/SessionReplay.ts
CHANGED
|
@@ -30,11 +30,16 @@ export interface SessionReplayConfiguration {
|
|
|
30
30
|
* Default `SessionReplayPrivacy.MASK`.
|
|
31
31
|
*/
|
|
32
32
|
defaultPrivacyLevel?: SessionReplayPrivacy;
|
|
33
|
+
/**
|
|
34
|
+
* Custom server url for sending replay data.
|
|
35
|
+
*/
|
|
36
|
+
customEndpoint?: string;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
const DEFAULTS = {
|
|
36
40
|
replaySampleRate: 0,
|
|
37
|
-
defaultPrivacyLevel: SessionReplayPrivacy.MASK
|
|
41
|
+
defaultPrivacyLevel: SessionReplayPrivacy.MASK,
|
|
42
|
+
customEndpoint: ''
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
export class SessionReplayWrapper {
|
|
@@ -47,11 +52,16 @@ export class SessionReplayWrapper {
|
|
|
47
52
|
): {
|
|
48
53
|
replaySampleRate: number;
|
|
49
54
|
defaultPrivacyLevel: SessionReplayPrivacy;
|
|
55
|
+
customEndpoint: string;
|
|
50
56
|
} => {
|
|
51
57
|
if (!configuration) {
|
|
52
58
|
return DEFAULTS;
|
|
53
59
|
}
|
|
54
|
-
const {
|
|
60
|
+
const {
|
|
61
|
+
replaySampleRate,
|
|
62
|
+
defaultPrivacyLevel,
|
|
63
|
+
customEndpoint
|
|
64
|
+
} = configuration;
|
|
55
65
|
return {
|
|
56
66
|
replaySampleRate:
|
|
57
67
|
replaySampleRate !== undefined
|
|
@@ -60,7 +70,11 @@ export class SessionReplayWrapper {
|
|
|
60
70
|
defaultPrivacyLevel:
|
|
61
71
|
defaultPrivacyLevel !== undefined
|
|
62
72
|
? defaultPrivacyLevel
|
|
63
|
-
: DEFAULTS.defaultPrivacyLevel
|
|
73
|
+
: DEFAULTS.defaultPrivacyLevel,
|
|
74
|
+
customEndpoint:
|
|
75
|
+
customEndpoint !== undefined
|
|
76
|
+
? customEndpoint
|
|
77
|
+
: DEFAULTS.customEndpoint
|
|
64
78
|
};
|
|
65
79
|
};
|
|
66
80
|
|
|
@@ -71,12 +85,14 @@ export class SessionReplayWrapper {
|
|
|
71
85
|
enable = (configuration?: SessionReplayConfiguration): Promise<void> => {
|
|
72
86
|
const {
|
|
73
87
|
replaySampleRate,
|
|
74
|
-
defaultPrivacyLevel
|
|
88
|
+
defaultPrivacyLevel,
|
|
89
|
+
customEndpoint
|
|
75
90
|
} = this.buildConfiguration(configuration);
|
|
76
91
|
|
|
77
92
|
return this.nativeSessionReplay.enable(
|
|
78
93
|
replaySampleRate,
|
|
79
|
-
defaultPrivacyLevel
|
|
94
|
+
defaultPrivacyLevel,
|
|
95
|
+
customEndpoint
|
|
80
96
|
);
|
|
81
97
|
};
|
|
82
98
|
}
|
|
@@ -19,30 +19,35 @@ describe('SessionReplay', () => {
|
|
|
19
19
|
|
|
20
20
|
expect(NativeModules.DdSessionReplay.enable).toHaveBeenCalledWith(
|
|
21
21
|
0,
|
|
22
|
-
'MASK'
|
|
22
|
+
'MASK',
|
|
23
|
+
''
|
|
23
24
|
);
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
it('calls native session replay with provided configuration', () => {
|
|
27
28
|
SessionReplay.enable({
|
|
28
29
|
replaySampleRate: 100,
|
|
29
|
-
defaultPrivacyLevel: SessionReplayPrivacy.ALLOW
|
|
30
|
+
defaultPrivacyLevel: SessionReplayPrivacy.ALLOW,
|
|
31
|
+
customEndpoint: 'https://session-replay.example.com'
|
|
30
32
|
});
|
|
31
33
|
|
|
32
34
|
expect(NativeModules.DdSessionReplay.enable).toHaveBeenCalledWith(
|
|
33
35
|
100,
|
|
34
|
-
'ALLOW'
|
|
36
|
+
'ALLOW',
|
|
37
|
+
'https://session-replay.example.com'
|
|
35
38
|
);
|
|
36
39
|
});
|
|
37
40
|
|
|
38
41
|
it('calls native session replay with edge cases in configuration', () => {
|
|
39
42
|
SessionReplay.enable({
|
|
40
|
-
replaySampleRate: 0
|
|
43
|
+
replaySampleRate: 0,
|
|
44
|
+
customEndpoint: ''
|
|
41
45
|
});
|
|
42
46
|
|
|
43
47
|
expect(NativeModules.DdSessionReplay.enable).toHaveBeenCalledWith(
|
|
44
48
|
0,
|
|
45
|
-
'MASK'
|
|
49
|
+
'MASK',
|
|
50
|
+
''
|
|
46
51
|
);
|
|
47
52
|
});
|
|
48
53
|
});
|
|
@@ -21,9 +21,11 @@ export interface NativeSessionReplayType extends NativeDdSessionReplay {
|
|
|
21
21
|
* Enable session replay and start recording session.
|
|
22
22
|
* @param replaySampleRate: The sample rate applied for session replay.
|
|
23
23
|
* @param defaultPrivacyLevel: The privacy level used for replay.
|
|
24
|
+
* @param customEndpoint: Custom server url for sending replay data.
|
|
24
25
|
*/
|
|
25
26
|
enable(
|
|
26
27
|
replaySampleRate: number,
|
|
27
|
-
defaultPrivacyLevel: PrivacyLevel
|
|
28
|
+
defaultPrivacyLevel: PrivacyLevel,
|
|
29
|
+
customEndpoint: string
|
|
28
30
|
): Promise<void>;
|
|
29
31
|
}
|
|
@@ -18,10 +18,12 @@ export interface Spec extends TurboModule {
|
|
|
18
18
|
* Enable session replay and start recording session.
|
|
19
19
|
* @param replaySampleRate: The sample rate applied for session replay.
|
|
20
20
|
* @param defaultPrivacyLevel: The privacy level used for replay.
|
|
21
|
+
* @param customEndpoint: Custom server url for sending replay data.
|
|
21
22
|
*/
|
|
22
23
|
enable(
|
|
23
24
|
replaySampleRate: number,
|
|
24
|
-
defaultPrivacyLevel: string
|
|
25
|
+
defaultPrivacyLevel: string,
|
|
26
|
+
customEndpoint: string
|
|
25
27
|
): Promise<void>;
|
|
26
28
|
}
|
|
27
29
|
|