@datadog/mobile-react-native-session-replay 2.0.2-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.
Files changed (77) hide show
  1. package/DatadogSDKReactNativeSessionReplay.podspec +41 -0
  2. package/README.md +3 -0
  3. package/android/build.gradle +239 -0
  4. package/android/detekt.yml +572 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +11 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DatadogSDKReactNativeSessionReplayPackage.kt +46 -0
  8. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt +57 -0
  9. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/NoopTextPropertiesResolver.kt +22 -0
  10. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupport.kt +77 -0
  11. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolver.kt +196 -0
  12. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplaySDKWrapper.kt +24 -0
  13. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayWrapper.kt +22 -0
  14. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ShadowNodeWrapper.kt +70 -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/LongExt.kt +15 -0
  17. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactMaskInputTextMapper.kt +54 -0
  18. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactMaskTextMapper.kt +55 -0
  19. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactTextMapper.kt +54 -0
  20. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewGroupMapper.kt +58 -0
  21. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ColorUtils.kt +22 -0
  22. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/DrawableUtils.kt +35 -0
  23. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +66 -0
  24. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ReflectionUtils.kt +30 -0
  25. package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/TextViewUtils.kt +40 -0
  26. package/android/src/newarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +33 -0
  27. package/android/src/oldarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +34 -0
  28. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementationTest.kt +105 -0
  29. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupportTest.kt +127 -0
  30. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolverTest.kt +271 -0
  31. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewGroupMapperTest.kt +131 -0
  32. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/ColorUtilsTest.kt +42 -0
  33. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/DrawableUtilsTest.kt +101 -0
  34. package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/TextViewUtilsTest.kt +109 -0
  35. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/GenericAssert.kt +69 -0
  36. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/MapExt.kt +29 -0
  37. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/ReflectUtils.kt +266 -0
  38. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/BaseConfigurator.kt +24 -0
  39. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/ForgeConfigurator.kt +24 -0
  40. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/TextWireframeForgeryFactory.kt +64 -0
  41. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/Throwable.kt +31 -0
  42. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
  43. package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/WireframeClipForgeryFactory.kt +25 -0
  44. package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
  45. package/ios/DatadogSDKReactNativeSessionReplay.xcodeproj/project.pbxproj +272 -0
  46. package/ios/DatadogSDKReactNativeSessionReplay.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  47. package/ios/Sources/DatadogSDKReactNativeSessionReplay.h +8 -0
  48. package/ios/Sources/DdSessionReplay.h +24 -0
  49. package/ios/Sources/DdSessionReplay.mm +53 -0
  50. package/ios/Sources/DdSessionReplayImplementation.swift +70 -0
  51. package/ios/Sources/RCTTextViewRecorder.swift +157 -0
  52. package/lib/commonjs/SessionReplay.js +66 -0
  53. package/lib/commonjs/SessionReplay.js.map +1 -0
  54. package/lib/commonjs/index.js +26 -0
  55. package/lib/commonjs/index.js.map +1 -0
  56. package/lib/commonjs/nativeModulesTypes.js +2 -0
  57. package/lib/commonjs/nativeModulesTypes.js.map +1 -0
  58. package/lib/commonjs/specs/NativeDdSessionReplay.js +20 -0
  59. package/lib/commonjs/specs/NativeDdSessionReplay.js.map +1 -0
  60. package/lib/module/SessionReplay.js +53 -0
  61. package/lib/module/SessionReplay.js.map +1 -0
  62. package/lib/module/index.js +8 -0
  63. package/lib/module/index.js.map +1 -0
  64. package/lib/module/nativeModulesTypes.js +2 -0
  65. package/lib/module/nativeModulesTypes.js.map +1 -0
  66. package/lib/module/specs/NativeDdSessionReplay.js +14 -0
  67. package/lib/module/specs/NativeDdSessionReplay.js.map +1 -0
  68. package/lib/typescript/SessionReplay.d.ts +34 -0
  69. package/lib/typescript/index.d.ts +2 -0
  70. package/lib/typescript/nativeModulesTypes.d.ts +18 -0
  71. package/lib/typescript/specs/NativeDdSessionReplay.d.ts +15 -0
  72. package/package.json +90 -0
  73. package/src/SessionReplay.ts +84 -0
  74. package/src/__tests__/SessionReplay.test.ts +49 -0
  75. package/src/index.ts +13 -0
  76. package/src/nativeModulesTypes.ts +29 -0
  77. package/src/specs/NativeDdSessionReplay.ts +28 -0
@@ -0,0 +1,41 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "DatadogSDKReactNativeSessionReplay"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "11.0", :tvos => "11.0" }
14
+ s.source = { :git => "https://github.com/DataDog/dd-sdk-reactnative.git", :tag => "#{s.version}" }
15
+
16
+
17
+ s.source_files = "ios/Sources/*.{h,m,mm,swift}"
18
+
19
+ s.dependency "React-Core"
20
+
21
+ # /!\ Remember to keep the version in sync with DatadogSDKReactNative.podspec
22
+ s.dependency 'DatadogSessionReplay', '~> 2.6.0'
23
+
24
+ s.test_spec 'Tests' do |test_spec|
25
+ test_spec.dependency "React-RCTText"
26
+ test_spec.source_files = 'ios/Tests/*.swift'
27
+ end
28
+
29
+
30
+ # This guard prevents installing the dependencies when we run `pod install` in the old architecture.
31
+ # The `install_modules_dependencies` function is only available from RN 0.71, the new architecture is not
32
+ # supported on earlier RN versions.
33
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
34
+ s.pod_target_xcconfig = {
35
+ "DEFINES_MODULE" => "YES",
36
+ "OTHER_CPLUSPLUSFLAGS" => "-DRCT_NEW_ARCH_ENABLED=1"
37
+ }
38
+
39
+ install_modules_dependencies(s)
40
+ end
41
+ end
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Session Replay for React Native
2
+
3
+ Session Replay for React Native is not available yet.
@@ -0,0 +1,239 @@
1
+ import java.nio.file.Paths
2
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3
+
4
+ buildscript {
5
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
6
+ def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['DatadogSDKReactNativeSessionReplay_kotlinVersion']
7
+
8
+ repositories {
9
+ mavenCentral()
10
+ google()
11
+ gradlePluginPortal()
12
+ }
13
+
14
+ dependencies {
15
+ classpath 'com.android.tools.build:gradle:7.2.2'
16
+ // noinspection DifferentKotlinGradleVersion
17
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
18
+ classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
19
+ classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0"
20
+ classpath 'com.github.bjoernq:unmockplugin:0.7.9'
21
+ }
22
+ }
23
+
24
+
25
+ apply plugin: 'de.mobilej.unmock'
26
+
27
+ def isNewArchitectureEnabled() {
28
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
29
+ }
30
+
31
+ apply plugin: 'com.android.library'
32
+ if (isNewArchitectureEnabled()) {
33
+ apply plugin: 'com.facebook.react'
34
+ }
35
+ apply plugin: 'kotlin-android'
36
+ apply plugin: 'org.jlleitschuh.gradle.ktlint'
37
+ apply plugin: "io.gitlab.arturbosch.detekt"
38
+
39
+ /**
40
+ * Finds the path of the installed npm package with the given name using Node's
41
+ * module resolution algorithm, which searches "node_modules" directories up to
42
+ * the file system root.
43
+ * This enables us to handle monorepos without requiring the node executable.
44
+ *
45
+ * The search begins at the given base directory (a File object). The returned
46
+ * path is a string.
47
+ */
48
+ static def findNodeModulePath(baseDir, packageName) {
49
+ def basePath = baseDir.toPath().normalize()
50
+ // Node's module resolution algorithm searches up to the root directory,
51
+ // after which the base path will be null
52
+ while (basePath) {
53
+ def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
54
+ if (candidatePath.toFile().exists()) {
55
+ return candidatePath.toString()
56
+ }
57
+ basePath = basePath.getParent()
58
+ }
59
+ return null
60
+ }
61
+
62
+ def resolveReactNativeDirectory() {
63
+ def reactNativeLocation = rootProject.hasProperty("reactNativeDir") ? rootProject.getProperty("reactNativeDir") : null
64
+
65
+ if (reactNativeLocation != null) {
66
+ return file(reactNativeLocation)
67
+ }
68
+
69
+ def reactNativePath = findNodeModulePath(projectDir, "react-native")
70
+
71
+ if (reactNativePath != null) {
72
+ return file(reactNativePath)
73
+ }
74
+
75
+ throw new Exception(
76
+ "${project.name}: Failed to resolve 'react-native' in the project. " +
77
+ "Altenatively, you can specify 'reactNativeDir' with the path to 'react-native' in your 'gradle.properties' file."
78
+ )
79
+ }
80
+
81
+ def reactNativeRootDir = resolveReactNativeDirectory()
82
+ def reactProperties = new Properties()
83
+ file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
84
+
85
+ def reactNativeVersion = reactProperties.getProperty("VERSION_NAME")
86
+ def (reactNativeMajorVersion, reactNativeMinorVersion) = reactNativeVersion.split("\\.").collect { it.isInteger() ? it.toInteger() : it }
87
+
88
+ def getExtOrDefault(name) {
89
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['DatadogSDKReactNativeSessionReplay_' + name]
90
+ }
91
+
92
+ def getExtOrIntegerDefault(name) {
93
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['DatadogSDKReactNativeSessionReplay_' + name]).toInteger()
94
+ }
95
+
96
+ android {
97
+ compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
98
+ buildToolsVersion getExtOrDefault('buildToolsVersion')
99
+ def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
100
+ if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
101
+ namespace = "com.datadog.reactnative.sessionreplay"
102
+ }
103
+ if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
104
+ buildFeatures {
105
+ buildConfig = true
106
+ }
107
+ }
108
+
109
+ defaultConfig {
110
+ minSdkVersion 21
111
+ targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
112
+ versionCode 1
113
+ versionName "1.0"
114
+ buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
115
+ }
116
+
117
+ sourceSets {
118
+ main {
119
+ if (isNewArchitectureEnabled()) {
120
+ java.srcDirs += ['src/newarch/kotlin']
121
+ } else {
122
+ java.srcDirs += ['src/oldarch/kotlin']
123
+ }
124
+ }
125
+ test {
126
+ java.srcDir("src/test/kotlin")
127
+ }
128
+ }
129
+
130
+ testOptions {
131
+ unitTests {
132
+ returnDefaultValues = true
133
+ }
134
+ }
135
+
136
+ buildTypes {
137
+ release {
138
+ minifyEnabled false
139
+ }
140
+ }
141
+ lintOptions {
142
+ disable 'GradleCompatible'
143
+ }
144
+ compileOptions {
145
+ sourceCompatibility JavaVersion.VERSION_11
146
+ targetCompatibility JavaVersion.VERSION_11
147
+ }
148
+ }
149
+
150
+ repositories {
151
+ mavenCentral()
152
+ google()
153
+ maven { url "https://jitpack.io" }
154
+ mavenLocal()
155
+
156
+ if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
157
+ def androidSourcesDir = file("$reactNativeRootDir/android")
158
+ def androidSourcesName = "React Native sources"
159
+
160
+ if (androidSourcesDir.exists()) {
161
+ maven {
162
+ url androidSourcesDir.toString()
163
+ name androidSourcesName
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+ def kotlin_version = getExtOrDefault('kotlinVersion')
170
+
171
+ dependencies {
172
+ if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
173
+ // noinspection GradleDynamicVersion
174
+ api 'com.facebook.react:react-native:+'
175
+ } else {
176
+ // We specify the $reactNativeVersion, like it's done on the react-native-gradle-plugin, as the plugin is not applied in tests.
177
+ // There is no impact for apps as we apply the same logic:
178
+ // https://github.com/facebook/react-native/blob/e1a1e6aa8030bf11d691c3dcf7abd13b25175027/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
179
+ api "com.facebook.react:react-android:$reactNativeVersion"
180
+ }
181
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
182
+ implementation "com.datadoghq:dd-sdk-android-session-replay:2.5.0"
183
+
184
+ testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
185
+ testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
186
+ testImplementation "org.junit.jupiter:junit-jupiter-engine:5.6.2"
187
+ testImplementation "org.junit.jupiter:junit-jupiter-params:5.6.2"
188
+ testImplementation "org.mockito:mockito-junit-jupiter:3.4.6"
189
+ testImplementation "org.assertj:assertj-core:3.18.1"
190
+ testImplementation "com.github.xgouchet.Elmyr:core:1.3.1"
191
+ testImplementation "com.github.xgouchet.Elmyr:inject:1.3.1"
192
+ testImplementation "com.github.xgouchet.Elmyr:junit5:1.3.1"
193
+ testImplementation "com.github.xgouchet.Elmyr:jvm:1.3.1"
194
+ testImplementation "org.mockito.kotlin:mockito-kotlin:5.1.0"
195
+ testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
196
+ unmock 'org.robolectric:android-all:4.4_r1-robolectric-r2'
197
+ }
198
+
199
+ tasks.withType(Test) {
200
+ tasks.withType(KotlinCompile) {
201
+ kotlinOptions.jvmTarget = JavaVersion.VERSION_11
202
+ }
203
+
204
+ useJUnitPlatform {
205
+ includeEngines("spek", "junit-jupiter", "junit-vintage")
206
+ }
207
+ reports {
208
+ junitXml.required.set(true)
209
+ html.required.set(true)
210
+ }
211
+ }
212
+
213
+ tasks.named("check") {
214
+ dependsOn("ktlintCheck")
215
+ dependsOn("detekt")
216
+ }
217
+
218
+ ktlint {
219
+ debug.set(false)
220
+ android.set(true)
221
+ outputToConsole.set(true)
222
+ ignoreFailures.set(false)
223
+ enableExperimentalRules.set(false)
224
+ filter {
225
+ exclude("**/generated/**")
226
+ include("**/kotlin/**")
227
+ }
228
+ }
229
+
230
+ detekt {
231
+ input = files("$projectDir/src/main/kotlin")
232
+ config = files("$projectDir/detekt.yml")
233
+ reports {
234
+ xml {
235
+ enabled = true
236
+ destination = file("build/reports/detekt.xml")
237
+ }
238
+ }
239
+ }