@datadog/mobile-react-native 1.3.0 → 1.3.1
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/DatadogSDKReactNative.podspec +2 -2
- package/android/build.gradle +58 -64
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +20 -14
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +9 -0
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +9 -0
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/rum/eventMappers/resourceEventMapper.d.ts +0 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +0 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -6
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +2 -1
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +130 -114
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +8 -0
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -1
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -1
- package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +6 -1
- package/src/sdk/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +2 -1
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +5 -4
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +5 -1
- package/src/version.ts +1 -1
|
@@ -17,8 +17,8 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.source_files = "ios/Sources/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
|
-
s.dependency 'DatadogSDK', '~> 1.
|
|
21
|
-
s.dependency 'DatadogSDKCrashReporting', '~> 1.
|
|
20
|
+
s.dependency 'DatadogSDK', '~> 1.15.0'
|
|
21
|
+
s.dependency 'DatadogSDKCrashReporting', '~> 1.15.0'
|
|
22
22
|
|
|
23
23
|
s.test_spec 'Tests' do |test_spec|
|
|
24
24
|
test_spec.source_files = 'ios/Tests/*.swift'
|
package/android/build.gradle
CHANGED
|
@@ -25,6 +25,46 @@ apply plugin: 'kotlin-android'
|
|
|
25
25
|
apply plugin: 'org.jlleitschuh.gradle.ktlint'
|
|
26
26
|
apply plugin: "io.gitlab.arturbosch.detekt"
|
|
27
27
|
|
|
28
|
+
def resolveReactNativeDirectory() {
|
|
29
|
+
def reactNativeLocation = rootProject.hasProperty("reactNativeDir") ? rootProject.getProperty("reactNativeDir") : null
|
|
30
|
+
|
|
31
|
+
if (reactNativeLocation != null) {
|
|
32
|
+
return file(reactNativeLocation)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// Resolve React Native location with Node
|
|
37
|
+
// This will make sure that we get installation location correctly in monorepos
|
|
38
|
+
def reactNativePackageJsonPathStdout = new ByteArrayOutputStream()
|
|
39
|
+
|
|
40
|
+
exec {
|
|
41
|
+
commandLine("node", "-p", "require.resolve('react-native/package.json')")
|
|
42
|
+
ignoreExitValue true
|
|
43
|
+
standardOutput = reactNativePackageJsonPathStdout
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
def reactNativeFromProjectNodeModules = file(reactNativePackageJsonPathStdout.toString().trim()).getParentFile();
|
|
47
|
+
|
|
48
|
+
if (reactNativeFromProjectNodeModules.exists()) {
|
|
49
|
+
return reactNativeFromProjectNodeModules
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
// Ignore
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
throw new Exception(
|
|
56
|
+
"${project.name}: Failed to resolve 'react-native' in the project. " +
|
|
57
|
+
"Altenatively, you can specify 'reactNativeDir' with the path to 'react-native' in your 'gradle.properties' file."
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
62
|
+
def reactProperties = new Properties()
|
|
63
|
+
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
|
|
64
|
+
|
|
65
|
+
def reactNativeVersion = reactProperties.getProperty("VERSION_NAME")
|
|
66
|
+
def (reactNativeMajorVersion, reactNativeMinorVersion) = reactNativeVersion.split("\\.").collect { it.isInteger() ? it.toInteger() : it }
|
|
67
|
+
|
|
28
68
|
def getExtOrDefault(name) {
|
|
29
69
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['DdSdkReactNative_' + name]
|
|
30
70
|
}
|
|
@@ -78,81 +118,35 @@ repositories {
|
|
|
78
118
|
maven { url "https://jitpack.io" }
|
|
79
119
|
mavenLocal()
|
|
80
120
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
86
|
-
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
87
|
-
} else {
|
|
88
|
-
defaultDir = new File(
|
|
89
|
-
projectDir,
|
|
90
|
-
'/../../../node_modules/react-native/android'
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (defaultDir.exists()) {
|
|
95
|
-
maven {
|
|
96
|
-
url defaultDir.toString()
|
|
97
|
-
name androidSourcesName
|
|
98
|
-
}
|
|
121
|
+
if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
|
|
122
|
+
def androidSourcesDir = file("$reactNativeRootDir/android")
|
|
123
|
+
def androidSourcesName = "React Native sources"
|
|
99
124
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
1.upto(5, {
|
|
106
|
-
if (found) return true
|
|
107
|
-
parentDir = parentDir.parentFile
|
|
108
|
-
|
|
109
|
-
def androidSourcesDir = new File(
|
|
110
|
-
parentDir,
|
|
111
|
-
'node_modules/react-native'
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
def androidPrebuiltBinaryDir = new File(
|
|
115
|
-
parentDir,
|
|
116
|
-
'node_modules/react-native/android'
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
if (androidPrebuiltBinaryDir.exists()) {
|
|
120
|
-
maven {
|
|
121
|
-
url androidPrebuiltBinaryDir.toString()
|
|
122
|
-
name androidSourcesName
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
126
|
-
found = true
|
|
127
|
-
} else if (androidSourcesDir.exists()) {
|
|
128
|
-
maven {
|
|
129
|
-
url androidSourcesDir.toString()
|
|
130
|
-
name androidSourcesName
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
134
|
-
found = true
|
|
125
|
+
if (androidSourcesDir.exists()) {
|
|
126
|
+
maven {
|
|
127
|
+
url androidSourcesDir.toString()
|
|
128
|
+
name androidSourcesName
|
|
135
129
|
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (!found) {
|
|
140
|
-
throw new GradleException(
|
|
141
|
-
"${project.name}: unable to locate React Native android sources. " +
|
|
142
|
-
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
143
|
-
)
|
|
130
|
+
}
|
|
144
131
|
}
|
|
145
132
|
}
|
|
146
133
|
|
|
147
134
|
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
148
135
|
|
|
149
136
|
dependencies {
|
|
150
|
-
|
|
151
|
-
|
|
137
|
+
if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
|
|
138
|
+
// noinspection GradleDynamicVersion
|
|
139
|
+
api 'com.facebook.react:react-native:+'
|
|
140
|
+
} else {
|
|
141
|
+
// We specify the $reactNativeVersion, like it's done on the react-native-gradle-plugin, as the plugin is not applied in tests.
|
|
142
|
+
// There is no impact for apps as we apply the same logic:
|
|
143
|
+
// https://github.com/facebook/react-native/blob/e1a1e6aa8030bf11d691c3dcf7abd13b25175027/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
|
|
144
|
+
api "com.facebook.react:react-android:$reactNativeVersion"
|
|
145
|
+
}
|
|
152
146
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
153
147
|
compileOnly "com.squareup.okhttp3:okhttp:3.12.13"
|
|
154
148
|
|
|
155
|
-
implementation "com.datadoghq:dd-sdk-android:1.
|
|
149
|
+
implementation "com.datadoghq:dd-sdk-android:1.17.0"
|
|
156
150
|
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
157
151
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
|
|
158
152
|
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.6.2"
|
|
@@ -26,6 +26,7 @@ import com.datadog.android.rum.model.ActionEvent
|
|
|
26
26
|
import com.datadog.android.rum.model.ResourceEvent
|
|
27
27
|
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
|
|
28
28
|
import com.datadog.android.telemetry.model.TelemetryConfigurationEvent
|
|
29
|
+
import com.datadog.android.tracing.TracingHeaderType
|
|
29
30
|
import com.datadog.tools.unit.GenericAssert.Companion.assertThat
|
|
30
31
|
import com.datadog.tools.unit.forge.BaseConfigurator
|
|
31
32
|
import com.datadog.tools.unit.getStaticValue
|
|
@@ -178,7 +179,7 @@ internal class DdSdkTest {
|
|
|
178
179
|
assertThat(configCaptor.firstValue)
|
|
179
180
|
.hasField("coreConfig") {
|
|
180
181
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
181
|
-
it.hasFieldEqualTo("
|
|
182
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
182
183
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
183
184
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
184
185
|
}
|
|
@@ -228,7 +229,7 @@ internal class DdSdkTest {
|
|
|
228
229
|
assertThat(configCaptor.firstValue)
|
|
229
230
|
.hasField("coreConfig") {
|
|
230
231
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
231
|
-
it.hasFieldEqualTo("
|
|
232
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
232
233
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
233
234
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
234
235
|
}
|
|
@@ -276,7 +277,7 @@ internal class DdSdkTest {
|
|
|
276
277
|
assertThat(configCaptor.firstValue)
|
|
277
278
|
.hasField("coreConfig") {
|
|
278
279
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
279
|
-
it.hasFieldEqualTo("
|
|
280
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
280
281
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
281
282
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
282
283
|
}
|
|
@@ -328,7 +329,7 @@ internal class DdSdkTest {
|
|
|
328
329
|
assertThat(configCaptor.firstValue)
|
|
329
330
|
.hasField("coreConfig") {
|
|
330
331
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
331
|
-
it.hasFieldEqualTo("
|
|
332
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
332
333
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
333
334
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
334
335
|
}
|
|
@@ -380,7 +381,7 @@ internal class DdSdkTest {
|
|
|
380
381
|
assertThat(configCaptor.firstValue)
|
|
381
382
|
.hasField("coreConfig") {
|
|
382
383
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
383
|
-
it.hasFieldEqualTo("
|
|
384
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
384
385
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
385
386
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
386
387
|
}
|
|
@@ -432,7 +433,7 @@ internal class DdSdkTest {
|
|
|
432
433
|
assertThat(configCaptor.firstValue)
|
|
433
434
|
.hasField("coreConfig") {
|
|
434
435
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
435
|
-
it.hasFieldEqualTo("
|
|
436
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
436
437
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
437
438
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
438
439
|
}
|
|
@@ -475,7 +476,7 @@ internal class DdSdkTest {
|
|
|
475
476
|
assertThat(configCaptor.firstValue)
|
|
476
477
|
.hasField("coreConfig") {
|
|
477
478
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
478
|
-
it.hasFieldEqualTo("
|
|
479
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
479
480
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
480
481
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
481
482
|
}
|
|
@@ -528,7 +529,7 @@ internal class DdSdkTest {
|
|
|
528
529
|
assertThat(configCaptor.firstValue)
|
|
529
530
|
.hasField("coreConfig") {
|
|
530
531
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
531
|
-
it.hasFieldEqualTo("
|
|
532
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
532
533
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
533
534
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
534
535
|
}
|
|
@@ -585,7 +586,7 @@ internal class DdSdkTest {
|
|
|
585
586
|
assertThat(configCaptor.firstValue)
|
|
586
587
|
.hasField("coreConfig") {
|
|
587
588
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
588
|
-
it.hasFieldEqualTo("
|
|
589
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
589
590
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
590
591
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
591
592
|
}
|
|
@@ -642,7 +643,7 @@ internal class DdSdkTest {
|
|
|
642
643
|
assertThat(configCaptor.firstValue)
|
|
643
644
|
.hasField("coreConfig") {
|
|
644
645
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
645
|
-
it.hasFieldEqualTo("
|
|
646
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
646
647
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
647
648
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
648
649
|
}
|
|
@@ -699,7 +700,7 @@ internal class DdSdkTest {
|
|
|
699
700
|
assertThat(configCaptor.firstValue)
|
|
700
701
|
.hasField("coreConfig") {
|
|
701
702
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
702
|
-
it.hasFieldEqualTo("
|
|
703
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
703
704
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
704
705
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
705
706
|
}
|
|
@@ -756,7 +757,7 @@ internal class DdSdkTest {
|
|
|
756
757
|
assertThat(configCaptor.firstValue)
|
|
757
758
|
.hasField("coreConfig") {
|
|
758
759
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
759
|
-
it.hasFieldEqualTo("
|
|
760
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
760
761
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
761
762
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
762
763
|
}
|
|
@@ -813,7 +814,7 @@ internal class DdSdkTest {
|
|
|
813
814
|
assertThat(configCaptor.firstValue)
|
|
814
815
|
.hasField("coreConfig") {
|
|
815
816
|
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
816
|
-
it.hasFieldEqualTo("
|
|
817
|
+
it.hasFieldEqualTo("firstPartyHostsWithHeaderTypes", emptyMap<String, String>())
|
|
817
818
|
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
818
819
|
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
819
820
|
}
|
|
@@ -1309,7 +1310,12 @@ internal class DdSdkTest {
|
|
|
1309
1310
|
)
|
|
1310
1311
|
assertThat(configCaptor.firstValue)
|
|
1311
1312
|
.hasField("coreConfig") { coreConfig ->
|
|
1312
|
-
coreConfig.hasFieldEqualTo(
|
|
1313
|
+
coreConfig.hasFieldEqualTo(
|
|
1314
|
+
"firstPartyHostsWithHeaderTypes",
|
|
1315
|
+
firstPartyHosts.associateWith {
|
|
1316
|
+
setOf(TracingHeaderType.DATADOG)
|
|
1317
|
+
}
|
|
1318
|
+
)
|
|
1313
1319
|
}
|
|
1314
1320
|
}
|
|
1315
1321
|
|
package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js
CHANGED
|
@@ -55,6 +55,7 @@ class DdRumUserInteractionTracking {
|
|
|
55
55
|
try {
|
|
56
56
|
const jsxRuntime = (0, _getJsxRuntime.getJsxRuntime)();
|
|
57
57
|
const originaljsx = jsxRuntime.jsx;
|
|
58
|
+
this.originalJsx = originaljsx;
|
|
58
59
|
|
|
59
60
|
jsxRuntime.jsx = (...args) => {
|
|
60
61
|
return this.patchCreateElementFunction(originaljsx, args);
|
|
@@ -100,6 +101,12 @@ class DdRumUserInteractionTracking {
|
|
|
100
101
|
_react.default.createElement = this.originalCreateElement;
|
|
101
102
|
_react.default.memo = this.originalMemo;
|
|
102
103
|
DdRumUserInteractionTracking.isTracking = false;
|
|
104
|
+
|
|
105
|
+
if (this.originalJsx) {
|
|
106
|
+
const jsxRuntime = (0, _getJsxRuntime.getJsxRuntime)();
|
|
107
|
+
jsxRuntime.jsx = this.originalJsx;
|
|
108
|
+
this.originalJsx = null;
|
|
109
|
+
}
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
}
|
|
@@ -114,6 +121,8 @@ _defineProperty(DdRumUserInteractionTracking, "originalCreateElement", _react.de
|
|
|
114
121
|
|
|
115
122
|
_defineProperty(DdRumUserInteractionTracking, "originalMemo", _react.default.memo);
|
|
116
123
|
|
|
124
|
+
_defineProperty(DdRumUserInteractionTracking, "originalJsx", null);
|
|
125
|
+
|
|
117
126
|
_defineProperty(DdRumUserInteractionTracking, "patchCreateElementFunction", (originalFunction, [element, props, ...rest]) => {
|
|
118
127
|
if (props && typeof props.onPress === 'function') {
|
|
119
128
|
const originalOnPress = props. // eslint-disable-next-line @typescript-eslint/ban-types
|
package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["DdRumUserInteractionTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","eventsInterceptor","DdEventsInterceptor","original","React","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","e","DdSdk","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","NoOpEventsInterceptor","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,4BAAN,CAAmC;
|
|
1
|
+
{"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["DdRumUserInteractionTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","eventsInterceptor","DdEventsInterceptor","original","React","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","originalJsx","e","DdSdk","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","NoOpEventsInterceptor","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,4BAAN,CAAmC;AAgCtC;AACJ;AACA;AACA;AACA;AACwB,SAAbC,aAAa,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,IAAAA,KAAD,CAAmCd,OAAnC,GAA6C,CAAC,GAAGf,IAAJ,KAAoB;AAC7DZ,MAAAA,4BAA4B,CAACO,iBAA7B,CAA+CqC,gBAA/C,CACI,GAAGhC,IADP;AAGA,aAAO+B,eAAe,CAAC,GAAG/B,IAAJ,CAAtB;AACH,KALD,CAHF,CASE;;;AACC6B,IAAAA,KAAD,CAGGV,sCAHH,GAG4CY,eAH5C;AAIH;;AACD,SAAOJ,gBAAgB,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAAvB;AACH,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\nimport React from 'react';\n\nimport { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\nimport { getErrorMessage } from '../../../errorUtils';\nimport { DdSdk } from '../../../foundation';\n\nimport { DdEventsInterceptor } from './DdEventsInterceptor';\nimport type EventsInterceptor from './EventsInterceptor';\nimport NoOpEventsInterceptor from './NoOpEventsInterceptor';\nimport { areObjectShallowEqual } from './ShallowObjectEqualityChecker';\nimport { getJsxRuntime } from './getJsxRuntime';\n\n/**\n * Provides RUM auto-instrumentation feature to track user interaction as RUM events.\n * For now we are only covering the \"onPress\" events.\n */\nexport class DdRumUserInteractionTracking {\n private static isTracking = false;\n private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();\n private static originalCreateElement = React.createElement;\n private static originalMemo = React.memo;\n private static originalJsx = null;\n\n private static patchCreateElementFunction = (\n originalFunction: typeof React.createElement,\n [element, props, ...rest]: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n if (\n props &&\n typeof (props as Record<string, unknown>).onPress === 'function'\n ) {\n const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types\n .onPress as Function;\n (props as Record<string, unknown>).onPress = (...args: any[]) => {\n DdRumUserInteractionTracking.eventsInterceptor.interceptOnPress(\n ...args\n );\n return originalOnPress(...args);\n };\n // we store the original onPress prop so we can keep memoization working\n (props as Record<\n string,\n unknown\n >).__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;\n }\n return originalFunction(element, props, ...rest);\n };\n\n /**\n * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.\n * Please note that we are only considering as valid - for - tracking only the user interactions that have\n * a visible output (either an UI state change or a Resource request)\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumUserInteractionTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking interactions',\n SdkVerbosity.WARN\n );\n return;\n }\n DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor();\n\n const original = React.createElement;\n React.createElement = (\n ...args: Parameters<typeof React.createElement>\n ): any => {\n return this.patchCreateElementFunction(original, args);\n };\n\n try {\n const jsxRuntime = getJsxRuntime();\n const originaljsx = jsxRuntime.jsx;\n this.originalJsx = originaljsx;\n jsxRuntime.jsx = (\n ...args: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n return this.patchCreateElementFunction(originaljsx, args);\n };\n } catch (e) {\n DdSdk.telemetryDebug(getErrorMessage(e));\n }\n\n const originalMemo = React.memo;\n\n React.memo = (\n component: any,\n propsAreEqual?: (prevProps: any, newProps: any) => boolean\n ) => {\n return originalMemo(component, (prev, next) => {\n if (!next.onPress || !prev.onPress) {\n return propsAreEqual\n ? propsAreEqual(prev, next)\n : areObjectShallowEqual(prev, next);\n }\n // we replace \"our\" onPress from the props by the original for comparison\n const { onPress: _prevOnPress, ...partialPrevProps } = prev;\n const prevProps = {\n ...partialPrevProps,\n onPress: prev.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n const { onPress: _nextOnPress, ...partialNextProps } = next;\n const nextProps = {\n ...partialNextProps,\n onPress: next.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n // if no comparison function is provided we do shallow comparison\n return propsAreEqual\n ? propsAreEqual(prevProps, nextProps)\n : areObjectShallowEqual(nextProps, prevProps);\n });\n };\n\n DdRumUserInteractionTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking interactions',\n SdkVerbosity.INFO\n );\n }\n\n static stopTracking() {\n React.createElement = this.originalCreateElement;\n React.memo = this.originalMemo;\n DdRumUserInteractionTracking.isTracking = false;\n if (this.originalJsx) {\n const jsxRuntime = getJsxRuntime();\n jsxRuntime.jsx = this.originalJsx;\n this.originalJsx = null;\n }\n }\n}\n"]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.3.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.3.1';\n"]}
|
|
@@ -42,6 +42,7 @@ export class DdRumUserInteractionTracking {
|
|
|
42
42
|
try {
|
|
43
43
|
const jsxRuntime = getJsxRuntime();
|
|
44
44
|
const originaljsx = jsxRuntime.jsx;
|
|
45
|
+
this.originalJsx = originaljsx;
|
|
45
46
|
|
|
46
47
|
jsxRuntime.jsx = (...args) => {
|
|
47
48
|
return this.patchCreateElementFunction(originaljsx, args);
|
|
@@ -86,6 +87,12 @@ export class DdRumUserInteractionTracking {
|
|
|
86
87
|
React.createElement = this.originalCreateElement;
|
|
87
88
|
React.memo = this.originalMemo;
|
|
88
89
|
DdRumUserInteractionTracking.isTracking = false;
|
|
90
|
+
|
|
91
|
+
if (this.originalJsx) {
|
|
92
|
+
const jsxRuntime = getJsxRuntime();
|
|
93
|
+
jsxRuntime.jsx = this.originalJsx;
|
|
94
|
+
this.originalJsx = null;
|
|
95
|
+
}
|
|
89
96
|
}
|
|
90
97
|
|
|
91
98
|
}
|
|
@@ -98,6 +105,8 @@ _defineProperty(DdRumUserInteractionTracking, "originalCreateElement", React.cre
|
|
|
98
105
|
|
|
99
106
|
_defineProperty(DdRumUserInteractionTracking, "originalMemo", React.memo);
|
|
100
107
|
|
|
108
|
+
_defineProperty(DdRumUserInteractionTracking, "originalJsx", null);
|
|
109
|
+
|
|
101
110
|
_defineProperty(DdRumUserInteractionTracking, "patchCreateElementFunction", (originalFunction, [element, props, ...rest]) => {
|
|
102
111
|
if (props && typeof props.onPress === 'function') {
|
|
103
112
|
const originalOnPress = props. // eslint-disable-next-line @typescript-eslint/ban-types
|
package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["React","InternalLog","SdkVerbosity","getErrorMessage","DdSdk","DdEventsInterceptor","NoOpEventsInterceptor","areObjectShallowEqual","getJsxRuntime","DdRumUserInteractionTracking","startTracking","isTracking","log","WARN","eventsInterceptor","original","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","e","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAAN,CAAmC;
|
|
1
|
+
{"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["React","InternalLog","SdkVerbosity","getErrorMessage","DdSdk","DdEventsInterceptor","NoOpEventsInterceptor","areObjectShallowEqual","getJsxRuntime","DdRumUserInteractionTracking","startTracking","isTracking","log","WARN","eventsInterceptor","original","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","originalJsx","e","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAAN,CAAmC;AAgCtC;AACJ;AACA;AACA;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,4BAA4B,CAACE,UAAjC,EAA6C;AACzCV,MAAAA,WAAW,CAACW,GAAZ,CACI,8CADJ,EAEIV,YAAY,CAACW,IAFjB;AAIA;AACH;;AACDJ,IAAAA,4BAA4B,CAACK,iBAA7B,GAAiD,IAAIT,mBAAJ,EAAjD;AAEA,UAAMU,QAAQ,GAAGf,KAAK,CAACgB,aAAvB;;AACAhB,IAAAA,KAAK,CAACgB,aAAN,GAAsB,CACl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,eAAe,CAAC,GAAG7B,IAAJ,CAAtB;AACH,KALD,CAHF,CASE;;;AACC2B,IAAAA,KAAD,CAGGT,sCAHH,GAG4CW,eAH5C;AAIH;;AACD,SAAOJ,gBAAgB,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAAvB;AACH,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\nimport React from 'react';\n\nimport { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\nimport { getErrorMessage } from '../../../errorUtils';\nimport { DdSdk } from '../../../foundation';\n\nimport { DdEventsInterceptor } from './DdEventsInterceptor';\nimport type EventsInterceptor from './EventsInterceptor';\nimport NoOpEventsInterceptor from './NoOpEventsInterceptor';\nimport { areObjectShallowEqual } from './ShallowObjectEqualityChecker';\nimport { getJsxRuntime } from './getJsxRuntime';\n\n/**\n * Provides RUM auto-instrumentation feature to track user interaction as RUM events.\n * For now we are only covering the \"onPress\" events.\n */\nexport class DdRumUserInteractionTracking {\n private static isTracking = false;\n private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();\n private static originalCreateElement = React.createElement;\n private static originalMemo = React.memo;\n private static originalJsx = null;\n\n private static patchCreateElementFunction = (\n originalFunction: typeof React.createElement,\n [element, props, ...rest]: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n if (\n props &&\n typeof (props as Record<string, unknown>).onPress === 'function'\n ) {\n const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types\n .onPress as Function;\n (props as Record<string, unknown>).onPress = (...args: any[]) => {\n DdRumUserInteractionTracking.eventsInterceptor.interceptOnPress(\n ...args\n );\n return originalOnPress(...args);\n };\n // we store the original onPress prop so we can keep memoization working\n (props as Record<\n string,\n unknown\n >).__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;\n }\n return originalFunction(element, props, ...rest);\n };\n\n /**\n * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.\n * Please note that we are only considering as valid - for - tracking only the user interactions that have\n * a visible output (either an UI state change or a Resource request)\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumUserInteractionTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking interactions',\n SdkVerbosity.WARN\n );\n return;\n }\n DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor();\n\n const original = React.createElement;\n React.createElement = (\n ...args: Parameters<typeof React.createElement>\n ): any => {\n return this.patchCreateElementFunction(original, args);\n };\n\n try {\n const jsxRuntime = getJsxRuntime();\n const originaljsx = jsxRuntime.jsx;\n this.originalJsx = originaljsx;\n jsxRuntime.jsx = (\n ...args: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n return this.patchCreateElementFunction(originaljsx, args);\n };\n } catch (e) {\n DdSdk.telemetryDebug(getErrorMessage(e));\n }\n\n const originalMemo = React.memo;\n\n React.memo = (\n component: any,\n propsAreEqual?: (prevProps: any, newProps: any) => boolean\n ) => {\n return originalMemo(component, (prev, next) => {\n if (!next.onPress || !prev.onPress) {\n return propsAreEqual\n ? propsAreEqual(prev, next)\n : areObjectShallowEqual(prev, next);\n }\n // we replace \"our\" onPress from the props by the original for comparison\n const { onPress: _prevOnPress, ...partialPrevProps } = prev;\n const prevProps = {\n ...partialPrevProps,\n onPress: prev.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n const { onPress: _nextOnPress, ...partialNextProps } = next;\n const nextProps = {\n ...partialNextProps,\n onPress: next.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n // if no comparison function is provided we do shallow comparison\n return propsAreEqual\n ? propsAreEqual(prevProps, nextProps)\n : areObjectShallowEqual(nextProps, prevProps);\n });\n };\n\n DdRumUserInteractionTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking interactions',\n SdkVerbosity.INFO\n );\n }\n\n static stopTracking() {\n React.createElement = this.originalCreateElement;\n React.memo = this.originalMemo;\n DdRumUserInteractionTracking.isTracking = false;\n if (this.originalJsx) {\n const jsxRuntime = getJsxRuntime();\n jsxRuntime.jsx = this.originalJsx;\n this.originalJsx = null;\n }\n }\n}\n"]}
|
package/lib/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.3.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.3.1';\n"]}
|
package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class DdRumUserInteractionTracking {
|
|
|
7
7
|
private static eventsInterceptor;
|
|
8
8
|
private static originalCreateElement;
|
|
9
9
|
private static originalMemo;
|
|
10
|
+
private static originalJsx;
|
|
10
11
|
private static patchCreateElementFunction;
|
|
11
12
|
/**
|
|
12
13
|
* Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.3.
|
|
1
|
+
export declare const version = "1.3.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
]
|
|
78
78
|
]
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "c70d62caff28da6111c8e526de4dfbb82bb9bf2d"
|
|
81
81
|
}
|
|
@@ -28,12 +28,12 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
28
28
|
).toMatchInlineSnapshot(`
|
|
29
29
|
DdSdkReactNativeConfiguration {
|
|
30
30
|
"actionEventMapper": null,
|
|
31
|
-
"additionalConfig":
|
|
31
|
+
"additionalConfig": {},
|
|
32
32
|
"applicationId": "fake-app-id",
|
|
33
33
|
"clientToken": "fake-client-token",
|
|
34
34
|
"env": "fake-env",
|
|
35
35
|
"errorEventMapper": null,
|
|
36
|
-
"firstPartyHosts":
|
|
36
|
+
"firstPartyHosts": [],
|
|
37
37
|
"logEventMapper": null,
|
|
38
38
|
"longTaskThresholdMs": 0,
|
|
39
39
|
"nativeCrashReportEnabled": false,
|
|
@@ -85,6 +85,7 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
85
85
|
'api.com',
|
|
86
86
|
443
|
|
87
87
|
),
|
|
88
|
+
|
|
88
89
|
serviceName: 'com.test.app',
|
|
89
90
|
version: '1.4.5',
|
|
90
91
|
versionSuffix: 'codepush-3',
|
|
@@ -98,14 +99,14 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
98
99
|
).toMatchInlineSnapshot(`
|
|
99
100
|
DdSdkReactNativeConfiguration {
|
|
100
101
|
"actionEventMapper": [Function],
|
|
101
|
-
"additionalConfig":
|
|
102
|
+
"additionalConfig": {
|
|
102
103
|
"additionalField": "fake-value",
|
|
103
104
|
},
|
|
104
105
|
"applicationId": "fake-app-id",
|
|
105
106
|
"clientToken": "fake-client-token",
|
|
106
107
|
"env": "fake-env",
|
|
107
108
|
"errorEventMapper": [Function],
|
|
108
|
-
"firstPartyHosts":
|
|
109
|
+
"firstPartyHosts": [
|
|
109
110
|
"api.com",
|
|
110
111
|
],
|
|
111
112
|
"logEventMapper": [Function],
|
|
@@ -168,12 +169,12 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
168
169
|
).toMatchInlineSnapshot(`
|
|
169
170
|
DdSdkReactNativeConfiguration {
|
|
170
171
|
"actionEventMapper": null,
|
|
171
|
-
"additionalConfig":
|
|
172
|
+
"additionalConfig": {},
|
|
172
173
|
"applicationId": "",
|
|
173
174
|
"clientToken": "",
|
|
174
175
|
"env": "",
|
|
175
176
|
"errorEventMapper": null,
|
|
176
|
-
"firstPartyHosts":
|
|
177
|
+
"firstPartyHosts": [],
|
|
177
178
|
"logEventMapper": null,
|
|
178
179
|
"longTaskThresholdMs": false,
|
|
179
180
|
"nativeCrashReportEnabled": false,
|
|
@@ -32,7 +32,8 @@ const baseConsoleError = (...params: unknown) => {
|
|
|
32
32
|
};
|
|
33
33
|
let originalConsoleError;
|
|
34
34
|
|
|
35
|
-
const flushPromises = () =>
|
|
35
|
+
const flushPromises = () =>
|
|
36
|
+
new Promise(jest.requireActual('timers').setImmediate);
|
|
36
37
|
|
|
37
38
|
beforeEach(() => {
|
|
38
39
|
DdRum.addError.mockClear();
|
|
@@ -35,19 +35,14 @@ jest.mock(
|
|
|
35
35
|
|
|
36
36
|
// Silence the warning https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
|
|
37
37
|
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
38
|
-
jest.useFakeTimers();
|
|
39
|
-
|
|
40
|
-
let originalMethod: typeof React.createElement;
|
|
41
38
|
|
|
42
39
|
beforeEach(() => {
|
|
43
|
-
originalMethod = React.createElement;
|
|
44
40
|
jest.setTimeout(20000);
|
|
45
41
|
jest.clearAllMocks();
|
|
46
42
|
});
|
|
47
43
|
|
|
48
44
|
afterEach(() => {
|
|
49
|
-
DdRumUserInteractionTracking
|
|
50
|
-
React.createElement = originalMethod;
|
|
45
|
+
DdRumUserInteractionTracking.stopTracking();
|
|
51
46
|
});
|
|
52
47
|
|
|
53
48
|
// Because the way RN decouples the component we cannot assert how many times the `interceptOnPress` function was called.
|
|
@@ -219,130 +214,151 @@ it('M intercept and send a RUM event W onPress { TouchableWithoutFeedback compon
|
|
|
219
214
|
expect(mockedInterceptOnPressFunction).toBeCalled();
|
|
220
215
|
});
|
|
221
216
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
rendersCount++;
|
|
228
|
-
return (
|
|
229
|
-
<TouchableWithoutFeedback onPress={props.onPress}>
|
|
230
|
-
<View style={styles.button}>
|
|
231
|
-
<Text style={styles.button}>Click me</Text>
|
|
232
|
-
</View>
|
|
233
|
-
</TouchableWithoutFeedback>
|
|
234
|
-
);
|
|
235
|
-
};
|
|
236
|
-
const stableOnPress = () => {};
|
|
237
|
-
const MemoizedComponent = React.memo(DummyComponent);
|
|
238
|
-
const { rerender } = render(<MemoizedComponent onPress={stableOnPress} />);
|
|
239
|
-
expect(rendersCount).toBe(1);
|
|
240
|
-
|
|
241
|
-
// WHEN
|
|
242
|
-
rerender(<MemoizedComponent onPress={stableOnPress} />);
|
|
243
|
-
// THEN
|
|
244
|
-
expect(rendersCount).toBe(1);
|
|
217
|
+
describe('startTracking memoization', () => {
|
|
218
|
+
beforeEach(() => {
|
|
219
|
+
jest.setTimeout(20000);
|
|
220
|
+
jest.clearAllMocks();
|
|
221
|
+
});
|
|
245
222
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
expect(rendersCount).toBe(2);
|
|
250
|
-
});
|
|
223
|
+
afterEach(() => {
|
|
224
|
+
DdRumUserInteractionTracking.stopTracking();
|
|
225
|
+
});
|
|
251
226
|
|
|
252
|
-
it('M keep memoization working for elements W
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
227
|
+
it('M keep memoization working for elements W an onPress prop is passed', async () => {
|
|
228
|
+
// GIVEN
|
|
229
|
+
DdRumUserInteractionTracking.startTracking();
|
|
230
|
+
let rendersCount = 0;
|
|
231
|
+
const DummyComponent = props => {
|
|
232
|
+
rendersCount++;
|
|
233
|
+
return (
|
|
234
|
+
<TouchableWithoutFeedback onPress={props.onPress}>
|
|
235
|
+
<View style={styles.button}>
|
|
236
|
+
<Text style={styles.button}>Click me</Text>
|
|
237
|
+
</View>
|
|
238
|
+
</TouchableWithoutFeedback>
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
const stableOnPress = () => {};
|
|
242
|
+
const MemoizedComponent = React.memo(DummyComponent);
|
|
243
|
+
const { rerender } = render(
|
|
244
|
+
<MemoizedComponent onPress={stableOnPress} />
|
|
262
245
|
);
|
|
263
|
-
|
|
264
|
-
const MemoizedComponent = React.memo(DummyComponent);
|
|
265
|
-
const { rerender } = render(<MemoizedComponent title={'Click me'} />);
|
|
266
|
-
expect(rendersCount).toBe(1);
|
|
246
|
+
expect(rendersCount).toBe(1);
|
|
267
247
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
248
|
+
// WHEN
|
|
249
|
+
rerender(<MemoizedComponent onPress={stableOnPress} />);
|
|
250
|
+
// THEN
|
|
251
|
+
expect(rendersCount).toBe(1);
|
|
272
252
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
});
|
|
253
|
+
// WHEN
|
|
254
|
+
rerender(<MemoizedComponent onPress={() => {}} />);
|
|
255
|
+
// THEN
|
|
256
|
+
expect(rendersCount).toBe(2);
|
|
257
|
+
});
|
|
278
258
|
|
|
279
|
-
it('M keep memoization working for elements W
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
<TouchableWithoutFeedback onPress={props.onPress}>
|
|
259
|
+
it('M keep memoization working for elements W no onPress prop is passed', async () => {
|
|
260
|
+
// GIVEN
|
|
261
|
+
DdRumUserInteractionTracking.startTracking();
|
|
262
|
+
let rendersCount = 0;
|
|
263
|
+
const DummyComponent = props => {
|
|
264
|
+
rendersCount++;
|
|
265
|
+
return (
|
|
287
266
|
<View style={styles.button}>
|
|
288
267
|
<Text style={styles.button}>{props.title}</Text>
|
|
289
268
|
</View>
|
|
290
|
-
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
const MemoizedComponent = React.memo(DummyComponent);
|
|
272
|
+
const { rerender } = render(<MemoizedComponent title={'Click me'} />);
|
|
273
|
+
expect(rendersCount).toBe(1);
|
|
274
|
+
|
|
275
|
+
// WHEN
|
|
276
|
+
rerender(<MemoizedComponent title={'Click me'} />);
|
|
277
|
+
// THEN
|
|
278
|
+
expect(rendersCount).toBe(1);
|
|
279
|
+
|
|
280
|
+
// WHEN
|
|
281
|
+
rerender(<MemoizedComponent title={'New title'} />);
|
|
282
|
+
// THEN
|
|
283
|
+
expect(rendersCount).toBe(2);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('M keep memoization working for elements W an onPress prop is passed and custom arePropsEqual specified', async () => {
|
|
287
|
+
// GIVEN
|
|
288
|
+
DdRumUserInteractionTracking.startTracking();
|
|
289
|
+
let rendersCount = 0;
|
|
290
|
+
const DummyComponent = props => {
|
|
291
|
+
rendersCount++;
|
|
292
|
+
return (
|
|
293
|
+
<TouchableWithoutFeedback onPress={props.onPress}>
|
|
294
|
+
<View style={styles.button}>
|
|
295
|
+
<Text style={styles.button}>{props.title}</Text>
|
|
296
|
+
</View>
|
|
297
|
+
</TouchableWithoutFeedback>
|
|
298
|
+
);
|
|
299
|
+
};
|
|
300
|
+
const stableOnPress = () => {};
|
|
301
|
+
const MemoizedComponent = React.memo(
|
|
302
|
+
DummyComponent,
|
|
303
|
+
(previousProps, nextProps) =>
|
|
304
|
+
previousProps.title === nextProps.title
|
|
291
305
|
);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
(previousProps, nextProps) => previousProps.title === nextProps.title
|
|
297
|
-
);
|
|
298
|
-
const { rerender } = render(
|
|
299
|
-
<MemoizedComponent onPress={stableOnPress} title={'Click me'} />
|
|
300
|
-
);
|
|
301
|
-
expect(rendersCount).toBe(1);
|
|
306
|
+
const { rerender } = render(
|
|
307
|
+
<MemoizedComponent onPress={stableOnPress} title={'Click me'} />
|
|
308
|
+
);
|
|
309
|
+
expect(rendersCount).toBe(1);
|
|
302
310
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
311
|
+
// WHEN
|
|
312
|
+
rerender(
|
|
313
|
+
<MemoizedComponent onPress={stableOnPress} title={'Click me'} />
|
|
314
|
+
);
|
|
315
|
+
// THEN
|
|
316
|
+
expect(rendersCount).toBe(1);
|
|
307
317
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
318
|
+
// WHEN
|
|
319
|
+
rerender(
|
|
320
|
+
<MemoizedComponent onPress={stableOnPress} title={'New title'} />
|
|
321
|
+
);
|
|
322
|
+
// THEN
|
|
323
|
+
expect(rendersCount).toBe(2);
|
|
324
|
+
});
|
|
313
325
|
|
|
314
|
-
it('M keep memoization working for elements W an onPress prop is passed and custom arePropsEqual specified including onPress check', async () => {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
+
it('M keep memoization working for elements W an onPress prop is passed and custom arePropsEqual specified including onPress check', async () => {
|
|
327
|
+
// GIVEN
|
|
328
|
+
DdRumUserInteractionTracking.startTracking();
|
|
329
|
+
let rendersCount = 0;
|
|
330
|
+
const DummyComponent = props => {
|
|
331
|
+
rendersCount++;
|
|
332
|
+
return (
|
|
333
|
+
<TouchableWithoutFeedback onPress={props.onPress}>
|
|
334
|
+
<View style={styles.button}>
|
|
335
|
+
<Text style={styles.button}>Click me</Text>
|
|
336
|
+
</View>
|
|
337
|
+
</TouchableWithoutFeedback>
|
|
338
|
+
);
|
|
339
|
+
};
|
|
340
|
+
function stableOnPress() {}
|
|
341
|
+
function newOnPress() {}
|
|
342
|
+
const MemoizedComponent = React.memo(
|
|
343
|
+
DummyComponent,
|
|
344
|
+
(previousProps, nextProps) =>
|
|
345
|
+
previousProps.onPress === nextProps.onPress
|
|
326
346
|
);
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
(previousProps, nextProps) =>
|
|
332
|
-
previousProps.onPress === nextProps.onPress
|
|
333
|
-
);
|
|
334
|
-
const { rerender } = render(<MemoizedComponent onPress={stableOnPress} />);
|
|
335
|
-
expect(rendersCount).toBe(1);
|
|
347
|
+
const { rerender } = render(
|
|
348
|
+
<MemoizedComponent onPress={stableOnPress} />
|
|
349
|
+
);
|
|
350
|
+
expect(rendersCount).toBe(1);
|
|
336
351
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
352
|
+
// WHEN
|
|
353
|
+
rerender(<MemoizedComponent onPress={stableOnPress} />);
|
|
354
|
+
// THEN
|
|
355
|
+
expect(rendersCount).toBe(1);
|
|
341
356
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
357
|
+
// WHEN
|
|
358
|
+
rerender(<MemoizedComponent onPress={newOnPress} />);
|
|
359
|
+
// THEN
|
|
360
|
+
expect(rendersCount).toBe(2);
|
|
361
|
+
});
|
|
346
362
|
});
|
|
347
363
|
|
|
348
364
|
describe('startTracking', () => {
|
|
@@ -26,6 +26,7 @@ export class DdRumUserInteractionTracking {
|
|
|
26
26
|
private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();
|
|
27
27
|
private static originalCreateElement = React.createElement;
|
|
28
28
|
private static originalMemo = React.memo;
|
|
29
|
+
private static originalJsx = null;
|
|
29
30
|
|
|
30
31
|
private static patchCreateElementFunction = (
|
|
31
32
|
originalFunction: typeof React.createElement,
|
|
@@ -78,6 +79,7 @@ export class DdRumUserInteractionTracking {
|
|
|
78
79
|
try {
|
|
79
80
|
const jsxRuntime = getJsxRuntime();
|
|
80
81
|
const originaljsx = jsxRuntime.jsx;
|
|
82
|
+
this.originalJsx = originaljsx;
|
|
81
83
|
jsxRuntime.jsx = (
|
|
82
84
|
...args: Parameters<typeof React.createElement>
|
|
83
85
|
): ReturnType<typeof React.createElement> => {
|
|
@@ -88,6 +90,7 @@ export class DdRumUserInteractionTracking {
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
const originalMemo = React.memo;
|
|
93
|
+
|
|
91
94
|
React.memo = (
|
|
92
95
|
component: any,
|
|
93
96
|
propsAreEqual?: (prevProps: any, newProps: any) => boolean
|
|
@@ -129,5 +132,10 @@ export class DdRumUserInteractionTracking {
|
|
|
129
132
|
React.createElement = this.originalCreateElement;
|
|
130
133
|
React.memo = this.originalMemo;
|
|
131
134
|
DdRumUserInteractionTracking.isTracking = false;
|
|
135
|
+
if (this.originalJsx) {
|
|
136
|
+
const jsxRuntime = getJsxRuntime();
|
|
137
|
+
jsxRuntime.jsx = this.originalJsx;
|
|
138
|
+
this.originalJsx = null;
|
|
139
|
+
}
|
|
132
140
|
}
|
|
133
141
|
}
|
|
@@ -13,7 +13,8 @@ import { XMLHttpRequestMock } from './__utils__/XMLHttpRequestMock';
|
|
|
13
13
|
|
|
14
14
|
const DdRum = NativeModules.DdRum;
|
|
15
15
|
|
|
16
|
-
const flushPromises = () =>
|
|
16
|
+
const flushPromises = () =>
|
|
17
|
+
new Promise(jest.requireActual('timers').setImmediate);
|
|
17
18
|
|
|
18
19
|
beforeEach(() => {
|
|
19
20
|
DdRum.startResource.mockClear();
|
|
@@ -14,7 +14,8 @@ import { ResourceMockFactory } from './__utils__/ResourceMockFactory';
|
|
|
14
14
|
|
|
15
15
|
const resourceMockFactory = new ResourceMockFactory();
|
|
16
16
|
const DdRum = NativeModules.DdRum;
|
|
17
|
-
const flushPromises = () =>
|
|
17
|
+
const flushPromises = () =>
|
|
18
|
+
new Promise(jest.requireActual('timers').setImmediate);
|
|
18
19
|
|
|
19
20
|
beforeEach(() => {
|
|
20
21
|
DdRum.startResource.mockClear();
|
|
@@ -39,7 +39,8 @@ function randomInt(max: number): number {
|
|
|
39
39
|
return Math.floor(Math.random() * max);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const flushPromises = () =>
|
|
42
|
+
const flushPromises = () =>
|
|
43
|
+
new Promise(jest.requireActual('timers').setImmediate);
|
|
43
44
|
let xhrProxy;
|
|
44
45
|
|
|
45
46
|
beforeEach(() => {
|
|
@@ -519,7 +520,9 @@ describe('XHRPr', () => {
|
|
|
519
520
|
const xhr = new XMLHttpRequestMock();
|
|
520
521
|
xhr.open(method, url);
|
|
521
522
|
xhr.send();
|
|
523
|
+
jest.advanceTimersByTime(50);
|
|
522
524
|
xhr.notifyResponseArrived();
|
|
525
|
+
jest.advanceTimersByTime(50);
|
|
523
526
|
xhr.complete(200, 'ok');
|
|
524
527
|
await flushPromises();
|
|
525
528
|
|
|
@@ -564,7 +567,9 @@ describe('XHRPr', () => {
|
|
|
564
567
|
const xhr = new XMLHttpRequestMock();
|
|
565
568
|
xhr.open(method, url);
|
|
566
569
|
xhr.send();
|
|
570
|
+
jest.advanceTimersByTime(50);
|
|
567
571
|
xhr.notifyResponseArrived();
|
|
572
|
+
jest.advanceTimersByTime(50);
|
|
568
573
|
xhr.abort();
|
|
569
574
|
xhr.complete(0, undefined);
|
|
570
575
|
await flushPromises();
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { BufferSingleton } from '../BufferSingleton';
|
|
8
8
|
|
|
9
|
-
const flushPromises = () =>
|
|
9
|
+
const flushPromises = () =>
|
|
10
|
+
new Promise<void>(jest.requireActual('timers').setImmediate);
|
|
10
11
|
|
|
11
12
|
describe('BufferSingleton', () => {
|
|
12
13
|
afterEach(() => {
|
|
@@ -34,7 +34,8 @@ jest.mock('../../../TimeProvider', () => {
|
|
|
34
34
|
});
|
|
35
35
|
const nowMock = new TimeProvider().now;
|
|
36
36
|
|
|
37
|
-
const flushPromises = () =>
|
|
37
|
+
const flushPromises = () =>
|
|
38
|
+
new Promise<void>(jest.requireActual('timers').setImmediate);
|
|
38
39
|
|
|
39
40
|
describe('DatadogProvider', () => {
|
|
40
41
|
afterEach(() => {
|
|
@@ -59,15 +60,15 @@ describe('DatadogProvider', () => {
|
|
|
59
60
|
delete receivedConfiguration.additionalConfig['_dd.sdk_version'];
|
|
60
61
|
expect(receivedConfiguration).toMatchInlineSnapshot(`
|
|
61
62
|
DdSdkConfiguration {
|
|
62
|
-
"additionalConfig":
|
|
63
|
-
"_dd.first_party_hosts":
|
|
63
|
+
"additionalConfig": {
|
|
64
|
+
"_dd.first_party_hosts": [],
|
|
64
65
|
"_dd.native_interaction_tracking": false,
|
|
65
66
|
"_dd.native_view_tracking": false,
|
|
66
67
|
"_dd.source": "react-native",
|
|
67
68
|
},
|
|
68
69
|
"applicationId": "fakeApplicationId",
|
|
69
70
|
"clientToken": "fakeToken",
|
|
70
|
-
"configurationForTelemetry":
|
|
71
|
+
"configurationForTelemetry": {
|
|
71
72
|
"initializationType": "SYNC",
|
|
72
73
|
"trackErrors": true,
|
|
73
74
|
"trackInteractions": true,
|
|
@@ -11,6 +11,7 @@ import { InitializationMode } from '../../../DdSdkReactNativeConfiguration';
|
|
|
11
11
|
import { DdSdkReactNative } from '../../../DdSdkReactNative';
|
|
12
12
|
import { TimeProvider } from '../../../TimeProvider';
|
|
13
13
|
import { DdRumUserInteractionTracking } from '../../../rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';
|
|
14
|
+
import { XMLHttpRequestMock } from '../../../rum/instrumentation/resourceTracking/__tests__/__utils__/XMLHttpRequestMock';
|
|
14
15
|
import { BufferSingleton } from '../Buffer/BufferSingleton';
|
|
15
16
|
import {
|
|
16
17
|
DatadogProvider,
|
|
@@ -34,7 +35,8 @@ jest.mock('../../../TimeProvider', () => {
|
|
|
34
35
|
});
|
|
35
36
|
const nowMock = new TimeProvider().now;
|
|
36
37
|
|
|
37
|
-
const flushPromises = () =>
|
|
38
|
+
const flushPromises = () =>
|
|
39
|
+
new Promise<void>(jest.requireActual('timers').setImmediate);
|
|
38
40
|
|
|
39
41
|
describe('DatadogProvider', () => {
|
|
40
42
|
beforeEach(() => {
|
|
@@ -45,6 +47,7 @@ describe('DatadogProvider', () => {
|
|
|
45
47
|
BufferSingleton.reset();
|
|
46
48
|
DdRumUserInteractionTracking.stopTracking();
|
|
47
49
|
(nowMock as any).mockReturnValue('timestamp_not_specified');
|
|
50
|
+
global.XMLHttpRequest = XMLHttpRequestMock;
|
|
48
51
|
});
|
|
49
52
|
|
|
50
53
|
describe('initializationMode SYNC', () => {
|
|
@@ -106,6 +109,7 @@ describe('DatadogProvider', () => {
|
|
|
106
109
|
});
|
|
107
110
|
|
|
108
111
|
it('starts auto-instrumentation after animations are done (with InteractionManager)', async () => {
|
|
112
|
+
jest.useRealTimers();
|
|
109
113
|
const configuration = getDefaultConfiguration();
|
|
110
114
|
configuration.initializationMode = InitializationMode.ASYNC;
|
|
111
115
|
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '1.3.
|
|
2
|
+
export const version = '1.3.1';
|