@datadog/mobile-react-native-session-replay 2.4.4-alpha.0 → 2.6.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.
Files changed (55) hide show
  1. package/DatadogSDKReactNativeSessionReplay.podspec +1 -1
  2. package/android/build.gradle +11 -1
  3. package/android/consumer-proguard-rules.pro +3 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt +32 -27
  5. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupport.kt +15 -4
  6. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolver.kt +8 -10
  7. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayPrivacySettings.kt +90 -0
  8. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplaySDKWrapper.kt +14 -0
  9. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayWrapper.kt +10 -0
  10. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/extensions/ReactDrawablesExt.kt +190 -0
  11. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactEditTextMapper.kt +84 -10
  12. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactNativeImageViewMapper.kt +106 -0
  13. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewGroupMapper.kt +4 -5
  14. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/resources/ReactDrawableCopier.kt +34 -0
  15. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/DrawableUtils.kt +10 -23
  16. package/android/src/newarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +28 -4
  17. package/android/src/oldarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +35 -3
  18. package/android/src/{main/kotlin/com/datadog/reactnative/sessionreplay/extensions/LongExt.kt → rn75/kotlin/com/datadog/reactnative/sessionreplay/extensions/LengthPercentageExt.kt} +6 -8
  19. package/android/src/rn75/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +101 -0
  20. package/android/src/rn76/kotlin/com/datadog/reactnative/sessionreplay/extensions/LengthPercentageExt.kt +13 -0
  21. package/android/src/rn76/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +101 -0
  22. package/android/src/rnlegacy/kotlin/com.datadog.reactnative.sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +88 -0
  23. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementationTest.kt +59 -50
  24. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupportTest.kt +7 -3
  25. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolverTest.kt +2 -7
  26. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewGroupMapperTest.kt +2 -7
  27. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/DrawableUtilsTest.kt +2 -1
  28. package/ios/Sources/DdSessionReplay.mm +46 -4
  29. package/ios/Sources/DdSessionReplayImplementation.swift +83 -11
  30. package/ios/Sources/RCTTextViewRecorder.swift +1 -1
  31. package/lib/commonjs/SessionReplay.js +78 -10
  32. package/lib/commonjs/SessionReplay.js.map +1 -1
  33. package/lib/commonjs/index.js +18 -0
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/specs/NativeDdSessionReplay.js.map +1 -1
  36. package/lib/module/SessionReplay.js +77 -9
  37. package/lib/module/SessionReplay.js.map +1 -1
  38. package/lib/module/index.js +2 -2
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/specs/NativeDdSessionReplay.js.map +1 -1
  41. package/lib/typescript/SessionReplay.d.ts +73 -4
  42. package/lib/typescript/SessionReplay.d.ts.map +1 -1
  43. package/lib/typescript/index.d.ts +2 -2
  44. package/lib/typescript/index.d.ts.map +1 -1
  45. package/lib/typescript/nativeModulesTypes.d.ts +18 -3
  46. package/lib/typescript/nativeModulesTypes.d.ts.map +1 -1
  47. package/lib/typescript/specs/NativeDdSessionReplay.d.ts +15 -2
  48. package/lib/typescript/specs/NativeDdSessionReplay.d.ts.map +1 -1
  49. package/package.json +85 -84
  50. package/src/SessionReplay.ts +170 -23
  51. package/src/__tests__/SessionReplay.test.ts +94 -8
  52. package/src/index.ts +14 -2
  53. package/src/nativeModulesTypes.ts +27 -4
  54. package/src/specs/NativeDdSessionReplay.ts +21 -3
  55. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +0 -66
@@ -17,14 +17,32 @@ export interface Spec extends TurboModule {
17
17
  /**
18
18
  * Enable session replay and start recording session.
19
19
  * @param replaySampleRate: The sample rate applied for session replay.
20
- * @param defaultPrivacyLevel: The privacy level used for replay.
21
20
  * @param customEndpoint: Custom server url for sending replay data.
21
+ * @param imagePrivacyLevel: Defines the way images should be masked.
22
+ * @param touchPrivacyLevel: Defines the way user touches should be masked.
23
+ * @param textAndInputPrivacyLevel: Defines the way text and input should be masked.
24
+ * @param startRecordingImmediately: Whether the recording should start automatically when the feature is enabled.
25
+ * When `true`, the recording starts automatically; when `false` it doesn't,
26
+ * and the recording will need to be started manually. Default: `true`.
22
27
  */
23
28
  enable(
24
29
  replaySampleRate: number,
25
- defaultPrivacyLevel: string,
26
- customEndpoint: string
30
+ customEndpoint: string,
31
+ imagePrivacyLevel: string,
32
+ touchPrivacyLevel: string,
33
+ textAndInputPrivacyLevel: string,
34
+ startRecordingImmediately: boolean
27
35
  ): Promise<void>;
36
+
37
+ /**
38
+ * Manually start the recording of the current session.
39
+ */
40
+ startRecording(): Promise<void>;
41
+
42
+ /**
43
+ * Manually stop the recording of the current session.
44
+ */
45
+ stopRecording(): Promise<void>;
28
46
  }
29
47
 
30
48
  // eslint-disable-next-line func-names
@@ -1,66 +0,0 @@
1
- /*
2
- * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
- * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
- * Copyright 2016-Present Datadog, Inc.
5
- */
6
-
7
- package com.datadog.reactnative.sessionreplay.utils
8
-
9
- import com.datadog.android.sessionreplay.model.MobileSegment
10
- import com.datadog.reactnative.sessionreplay.extensions.convertToDensityNormalized
11
- import com.facebook.react.uimanager.Spacing
12
- import com.facebook.react.views.view.ReactViewBackgroundDrawable
13
-
14
- internal class ReactViewBackgroundDrawableUtils(
15
- private val reflectionUtils: ReflectionUtils = ReflectionUtils()
16
- ) {
17
- internal fun resolveShapeAndBorder(
18
- drawable: ReactViewBackgroundDrawable,
19
- opacity: Float,
20
- pixelDensity: Float
21
- ): Pair<MobileSegment.ShapeStyle?, MobileSegment.ShapeBorder?> {
22
- val borderProps = resolveBorder(drawable, pixelDensity)
23
- val backgroundColor = getBackgroundColor(drawable)
24
- val colorHexString = if (backgroundColor != null) {
25
- formatAsRgba(backgroundColor)
26
- } else {
27
- return null to borderProps
28
- }
29
-
30
- val cornerRadius =
31
- drawable.fullBorderRadius.toLong().convertToDensityNormalized(pixelDensity)
32
-
33
- return MobileSegment.ShapeStyle(
34
- colorHexString,
35
- opacity,
36
- cornerRadius
37
- ) to borderProps
38
- }
39
-
40
- private fun getBackgroundColor(
41
- backgroundDrawable: ReactViewBackgroundDrawable,
42
- ): Int? {
43
- return reflectionUtils.getDeclaredField(
44
- backgroundDrawable,
45
- COLOR_FIELD_NAME
46
- ) as Int?
47
- }
48
-
49
- private fun resolveBorder(
50
- backgroundDrawable: ReactViewBackgroundDrawable,
51
- pixelDensity: Float
52
- ): MobileSegment.ShapeBorder {
53
- val borderWidth =
54
- backgroundDrawable.fullBorderWidth.toLong().convertToDensityNormalized(pixelDensity)
55
- val borderColor = formatAsRgba(backgroundDrawable.getBorderColor(Spacing.ALL))
56
-
57
- return MobileSegment.ShapeBorder(
58
- color = borderColor,
59
- width = borderWidth
60
- )
61
- }
62
-
63
- private companion object {
64
- private const val COLOR_FIELD_NAME = "mColor"
65
- }
66
- }