@ohos-ports/datadog-mobile-react-native-session-replay 0.0.0-stage → 3.5.3-beta.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 (109) hide show
  1. package/DatadogSDKReactNativeSessionReplay.podspec +69 -0
  2. package/LICENSE +201 -0
  3. package/README.md +157 -2
  4. package/android/build.gradle +278 -0
  5. package/android/consumer-proguard-rules.pro +3 -0
  6. package/android/detekt.yml +721 -0
  7. package/android/gradle.properties +6 -0
  8. package/android/src/main/AndroidManifest.xml +11 -0
  9. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt +93 -0
  10. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeInternalCallback.kt +144 -0
  11. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupport.kt +54 -0
  12. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayPrivacySettings.kt +90 -0
  13. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplaySDKWrapper.kt +41 -0
  14. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayWrapper.kt +34 -0
  15. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/TextPropertiesResolver.kt +20 -0
  16. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/extensions/ReactDrawablesExt.kt +190 -0
  17. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/DefaultMapper.kt +65 -0
  18. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactEditTextMapper.kt +127 -0
  19. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactNativeImageViewMapper.kt +106 -0
  20. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactTextMapper.kt +47 -0
  21. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewGroupMapper.kt +18 -0
  22. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewModalMapper.kt +16 -0
  23. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/SvgViewMapper.kt +163 -0
  24. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/resources/ReactDrawableCopier.kt +34 -0
  25. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ColorUtils.kt +22 -0
  26. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/DrawableUtils.kt +22 -0
  27. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ReflectionUtils.kt +30 -0
  28. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/text/FabricTextViewUtils.kt +74 -0
  29. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/text/LegacyTextViewUtils.kt +133 -0
  30. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/text/TextViewUtils.kt +163 -0
  31. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/views/DdPrivacyView.kt +69 -0
  32. package/android/src/main/res/values/ids.xml +12 -0
  33. package/android/src/newarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +68 -0
  34. package/android/src/newarch/kotlin/com/datadog/reactnative/sessionreplay/views/DdPrivacyViewManager.kt +63 -0
  35. package/android/src/oldarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +77 -0
  36. package/android/src/oldarch/kotlin/com/datadog/reactnative/sessionreplay/views/DdPrivacyViewManager.kt +56 -0
  37. package/android/src/rn69/kotlin/com.datadog.reactnative.sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +86 -0
  38. package/android/src/rn75/kotlin/com/datadog/reactnative/sessionreplay/extensions/LengthPercentageExt.kt +12 -0
  39. package/android/src/rn75/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +98 -0
  40. package/android/src/rn76/kotlin/com/datadog/reactnative/sessionreplay/extensions/LengthPercentageExt.kt +13 -0
  41. package/android/src/rn76/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +98 -0
  42. package/android/src/rn79/kotlin/com/datadog/reactnative/sessionreplay/extensions/LengthPercentageExt.kt +13 -0
  43. package/android/src/rn79/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +111 -0
  44. package/android/src/rn80/kotlin/com/datadog/reactnative/sessionreplay/extensions/ComputedBorderRadiusExt.kt +27 -0
  45. package/android/src/rn80/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +157 -0
  46. package/android/src/rn83/kotlin/com/datadog/reactnative/sessionreplay/extensions/ComputedBorderRadiusExt.kt +27 -0
  47. package/android/src/rn83/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +103 -0
  48. package/android/src/rnlegacy/kotlin/com.datadog.reactnative.sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +106 -0
  49. package/android/src/rnpost74/kotlin/com/datadog/reactnative/sessionreplay/DdSDKReactNativeSessionReplayPackage.kt +54 -0
  50. package/android/src/rnpre74/kotlin/com/datadog/reactnative/sessionreplay/DdSDKReactNativeSessionReplayPackage.kt +31 -0
  51. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementationTest.kt +181 -0
  52. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupportTest.kt +99 -0
  53. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewGroupMapperTest.kt +132 -0
  54. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/mappers/SvgViewMapperTest.kt +189 -0
  55. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/ColorUtilsTest.kt +42 -0
  56. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/DrawableUtilsTest.kt +102 -0
  57. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/text/TextViewUtilsTest.kt +470 -0
  58. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/GenericAssert.kt +69 -0
  59. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/MapExt.kt +29 -0
  60. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/ReflectUtils.kt +266 -0
  61. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/BaseConfigurator.kt +24 -0
  62. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/ForgeConfigurator.kt +24 -0
  63. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/TextWireframeForgeryFactory.kt +64 -0
  64. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/Throwable.kt +31 -0
  65. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
  66. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/WireframeClipForgeryFactory.kt +25 -0
  67. package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
  68. package/assets/assets.bin +0 -0
  69. package/assets/assets.json +1 -0
  70. package/ios/DatadogSDKReactNativeSessionReplay.xcodeproj/project.pbxproj +272 -0
  71. package/ios/DatadogSDKReactNativeSessionReplay.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  72. package/ios/Sources/DatadogSDKReactNativeSessionReplay.h +8 -0
  73. package/ios/Sources/DdPrivacyOverrider.swift +71 -0
  74. package/ios/Sources/DdPrivacyViewFabric.h +28 -0
  75. package/ios/Sources/DdPrivacyViewFabric.mm +78 -0
  76. package/ios/Sources/DdPrivacyViewPaper.m +86 -0
  77. package/ios/Sources/DdSessionReplay.h +24 -0
  78. package/ios/Sources/DdSessionReplay.mm +100 -0
  79. package/ios/Sources/DdSessionReplayImplementation.swift +180 -0
  80. package/ios/Sources/RCTFabricWrapper.h +13 -0
  81. package/ios/Sources/RCTFabricWrapper.mm +113 -0
  82. package/ios/Sources/RCTTextExtractor.h +18 -0
  83. package/ios/Sources/RCTTextExtractor.mm +131 -0
  84. package/ios/Sources/RCTTextPropertiesWrapper.h +23 -0
  85. package/ios/Sources/RCTTextPropertiesWrapper.mm +28 -0
  86. package/ios/Sources/RCTTextViewRecorder.swift +135 -0
  87. package/ios/Sources/RCTVersion.h +8 -0
  88. package/ios/Sources/SvgViewRecorder.swift +236 -0
  89. package/ios/Sources/Utils/Bundle+SessionReplay.swift +21 -0
  90. package/metro.js +7 -0
  91. package/package.json +84 -5
  92. package/scripts/build-assets.js +31 -0
  93. package/scripts/set-ios-rn-version.js +47 -0
  94. package/src/SessionReplay.ts +225 -0
  95. package/src/components/SessionReplayView/HideView.tsx +25 -0
  96. package/src/components/SessionReplayView/MaskAllView.tsx +53 -0
  97. package/src/components/SessionReplayView/MaskNoneView.tsx +40 -0
  98. package/src/components/SessionReplayView/PrivacyView.tsx +78 -0
  99. package/src/components/SessionReplayView/index.ts +34 -0
  100. package/src/index.ts +27 -0
  101. package/src/metro/index.ts +89 -0
  102. package/src/metro/processing.ts +119 -0
  103. package/src/metro/utils.ts +17 -0
  104. package/src/nativeModulesTypes.ts +55 -0
  105. package/src/specs/DdPrivacyView.ts +17 -0
  106. package/src/specs/DdPrivacyViewNativeComponent.ts +28 -0
  107. package/src/specs/DdPrivacyViewPaper.ts +15 -0
  108. package/src/specs/NativeDdSessionReplay.ts +50 -0
  109. package/src/types/DdPrivacyView.ts +23 -0
@@ -0,0 +1,278 @@
1
+ import java.nio.file.Paths
2
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3
+
4
+ apply plugin: "io.gitlab.arturbosch.detekt"
5
+
6
+ buildscript {
7
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
8
+ def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['DatadogSDKReactNativeSessionReplay_kotlinVersion']
9
+
10
+ repositories {
11
+ mavenCentral()
12
+ google()
13
+ gradlePluginPortal()
14
+ }
15
+
16
+ dependencies {
17
+ classpath 'com.android.tools.build:gradle:7.3.1'
18
+ // noinspection DifferentKotlinGradleVersion
19
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
20
+ classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
21
+ classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.8"
22
+ classpath 'com.github.bjoernq:unmockplugin:0.7.9'
23
+ }
24
+ }
25
+
26
+
27
+ apply plugin: 'de.mobilej.unmock'
28
+
29
+ def isNewArchitectureEnabled() {
30
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
31
+ }
32
+
33
+ apply plugin: 'com.android.library'
34
+ if (isNewArchitectureEnabled()) {
35
+ apply plugin: 'com.facebook.react'
36
+ }
37
+ apply plugin: 'kotlin-android'
38
+ apply plugin: 'org.jlleitschuh.gradle.ktlint'
39
+
40
+ /**
41
+ * Finds the path of the installed npm package with the given name using Node's
42
+ * module resolution algorithm, which searches "node_modules" directories up to
43
+ * the file system root.
44
+ * This enables us to handle monorepos without requiring the node executable.
45
+ *
46
+ * The search begins at the given base directory (a File object). The returned
47
+ * path is a string.
48
+ */
49
+ static def findNodeModulePath(baseDir, packageName) {
50
+ def basePath = baseDir.toPath().normalize()
51
+ // Node's module resolution algorithm searches up to the root directory,
52
+ // after which the base path will be null
53
+ while (basePath) {
54
+ def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
55
+ if (candidatePath.toFile().exists()) {
56
+ return candidatePath.toString()
57
+ }
58
+ basePath = basePath.getParent()
59
+ }
60
+ return null
61
+ }
62
+
63
+ def resolveReactNativeDirectory() {
64
+ def reactNativeLocation = rootProject.hasProperty("reactNativeDir") ? rootProject.getProperty("reactNativeDir") : null
65
+
66
+ if (reactNativeLocation != null) {
67
+ return file(reactNativeLocation)
68
+ }
69
+
70
+ def reactNativePath = findNodeModulePath(projectDir, "react-native")
71
+
72
+ if (reactNativePath != null) {
73
+ return file(reactNativePath)
74
+ }
75
+
76
+ throw new Exception(
77
+ "${project.name}: Failed to resolve 'react-native' in the project. " +
78
+ "Altenatively, you can specify 'reactNativeDir' with the path to 'react-native' in your 'gradle.properties' file."
79
+ )
80
+ }
81
+
82
+ def reactNativeRootDir = resolveReactNativeDirectory()
83
+ def reactProperties = new Properties()
84
+ file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
85
+
86
+ def reactNativeVersion = reactProperties.getProperty("VERSION_NAME")
87
+ def (reactNativeMajorVersion, reactNativeMinorVersion) = reactNativeVersion.split("\\.").collect { it.isInteger() ? it.toInteger() : it }
88
+
89
+ def getExtOrDefault(name) {
90
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['DatadogSDKReactNativeSessionReplay_' + name]
91
+ }
92
+
93
+ def getExtOrIntegerDefault(name) {
94
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['DatadogSDKReactNativeSessionReplay_' + name]).toInteger()
95
+ }
96
+
97
+ android {
98
+ compileSdk getExtOrIntegerDefault('compileSdkVersion')
99
+ compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
100
+ buildToolsVersion getExtOrDefault('buildToolsVersion')
101
+
102
+ def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
103
+
104
+ if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
105
+ namespace = "com.datadog.reactnative.sessionreplay"
106
+ }
107
+
108
+ if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
109
+ buildFeatures {
110
+ buildConfig = true
111
+ }
112
+ }
113
+
114
+ if (agpVersion.tokenize('.')[0].toInteger() < 8) {
115
+ compileOptions {
116
+ sourceCompatibility JavaVersion.VERSION_11
117
+ targetCompatibility JavaVersion.VERSION_11
118
+ }
119
+ kotlinOptions {
120
+ jvmTarget = JavaVersion.VERSION_11.majorVersion
121
+ }
122
+ }
123
+
124
+ defaultConfig {
125
+ minSdkVersion getExtOrIntegerDefault('minSdkVersion')
126
+ targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
127
+ versionCode 1
128
+ versionName "1.0"
129
+ buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
130
+ }
131
+
132
+ sourceSets {
133
+ main {
134
+ if (isNewArchitectureEnabled()) {
135
+ java.srcDirs += ['src/newarch/kotlin']
136
+ } else {
137
+ java.srcDirs += ['src/oldarch/kotlin']
138
+ }
139
+
140
+ if (reactNativeMinorVersion >= 83) {
141
+ java.srcDirs += ['src/rn83/kotlin']
142
+ } else if (reactNativeMinorVersion >= 80) {
143
+ java.srcDirs += ['src/rn80/kotlin']
144
+ } else if (reactNativeMinorVersion >= 79) {
145
+ java.srcDirs += ['src/rn79/kotlin']
146
+ } else if (reactNativeMinorVersion >= 76) {
147
+ java.srcDirs += ['src/rn76/kotlin']
148
+ } else if (reactNativeMinorVersion >= 75) {
149
+ java.srcDirs += ['src/rn75/kotlin']
150
+ } else if (reactNativeMinorVersion >= 69) {
151
+ java.srcDirs += ['src/rn69/kotlin']
152
+ } else {
153
+ java.srcDirs += ['src/rnlegacy/kotlin']
154
+ }
155
+
156
+
157
+ if (reactNativeMinorVersion >= 74) {
158
+ java.srcDirs += ['src/rnpost74/kotlin']
159
+ } else {
160
+ java.srcDirs += ['src/rnpre74/kotlin']
161
+ }
162
+
163
+ assets.srcDirs += ['../assets']
164
+ }
165
+ test {
166
+ java.srcDir("src/test/kotlin")
167
+ }
168
+ }
169
+
170
+ testOptions {
171
+ unitTests {
172
+ returnDefaultValues = true
173
+ }
174
+ }
175
+
176
+ buildTypes {
177
+ release {
178
+ minifyEnabled false
179
+ consumerProguardFiles 'consumer-proguard-rules.pro'
180
+ }
181
+ }
182
+ lintOptions {
183
+ disable 'GradleCompatible'
184
+ }
185
+ }
186
+
187
+ repositories {
188
+ mavenCentral()
189
+ google()
190
+ maven { url "https://jitpack.io" }
191
+ mavenLocal()
192
+
193
+ if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
194
+ def androidSourcesDir = file("$reactNativeRootDir/android")
195
+ def androidSourcesName = "React Native sources"
196
+
197
+ if (androidSourcesDir.exists()) {
198
+ maven {
199
+ url androidSourcesDir.toString()
200
+ name androidSourcesName
201
+ }
202
+ }
203
+ }
204
+ }
205
+
206
+ def kotlin_version = getExtOrDefault('kotlinVersion')
207
+
208
+ dependencies {
209
+ if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
210
+ // noinspection GradleDynamicVersion
211
+ api 'com.facebook.react:react-native:+'
212
+ } else {
213
+ // We specify the $reactNativeVersion, like it's done on the react-native-gradle-plugin, as the plugin is not applied in tests.
214
+ // There is no impact for apps as we apply the same logic:
215
+ // https://github.com/facebook/react-native/blob/e1a1e6aa8030bf11d691c3dcf7abd13b25175027/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
216
+ api "com.facebook.react:react-android:$reactNativeVersion"
217
+ }
218
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
219
+ implementation "com.datadoghq:dd-sdk-android-session-replay:3.10.0"
220
+ implementation "com.datadoghq:dd-sdk-android-internal:3.10.0"
221
+ implementation project(path: ':datadog_mobile-react-native')
222
+
223
+ testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
224
+ testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
225
+ testImplementation "org.junit.jupiter:junit-jupiter-engine:5.6.2"
226
+ testImplementation "org.junit.jupiter:junit-jupiter-params:5.6.2"
227
+ testImplementation "org.mockito:mockito-junit-jupiter:3.4.6"
228
+ testImplementation "org.assertj:assertj-core:3.18.1"
229
+ testImplementation "com.github.xgouchet.Elmyr:core:1.3.1"
230
+ testImplementation "com.github.xgouchet.Elmyr:inject:1.3.1"
231
+ testImplementation "com.github.xgouchet.Elmyr:junit5:1.3.1"
232
+ testImplementation "com.github.xgouchet.Elmyr:jvm:1.3.1"
233
+ testImplementation "org.mockito.kotlin:mockito-kotlin:5.1.0"
234
+ testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
235
+
236
+ detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8"
237
+ detektPlugins "io.gitlab.arturbosch.detekt:detekt-rules-libraries:1.23.8"
238
+
239
+ unmock 'org.robolectric:android-all:4.4_r1-robolectric-r2'
240
+ }
241
+
242
+ tasks.withType(Test) {
243
+ useJUnitPlatform {
244
+ includeEngines("spek", "junit-jupiter", "junit-vintage")
245
+ }
246
+ reports {
247
+ junitXml.required.set(true)
248
+ html.required.set(true)
249
+ }
250
+ }
251
+
252
+ tasks.named("check") {
253
+ dependsOn("ktlintCheck")
254
+ dependsOn("detekt")
255
+ }
256
+
257
+ ktlint {
258
+ debug.set(false)
259
+ android.set(true)
260
+ outputToConsole.set(true)
261
+ ignoreFailures.set(false)
262
+ enableExperimentalRules.set(false)
263
+ filter {
264
+ exclude("**/generated/**")
265
+ include("**/kotlin/**")
266
+ }
267
+ }
268
+
269
+ detekt {
270
+ input = files("$projectDir/src/main/kotlin")
271
+ config = files("$projectDir/detekt.yml")
272
+ reports {
273
+ xml {
274
+ enabled = true
275
+ destination = file("build/reports/detekt.xml")
276
+ }
277
+ }
278
+ }
@@ -0,0 +1,3 @@
1
+ -keepclassmembers class com.facebook.drawee.drawable.RoundedBitmapDrawable {
2
+ private android.graphics.Bitmap mBitmap;
3
+ }