@datadog/mobile-react-native 3.5.4 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +7 -7
- package/README.md +10 -0
- package/android/build.gradle +22 -9
- package/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +7 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +23 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +3 -2
- package/android/src/main/kotlin/com/datadog/reactnative/HeatmapActionHandler.kt +121 -0
- package/android/src/main/kotlin/com/datadog/reactnative/HeatmapTouchResolver.kt +108 -0
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +19 -2
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +1 -1
- package/android/src/oldarch/kotlin/com/datadog/reactnative/HeatmapViewResolverFactory.kt +38 -0
- package/android/src/oldarch65/kotlin/com/datadog/reactnative/HeatmapViewResolverFactory.kt +20 -0
- package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdRum.kt +15 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +482 -0
- package/android/src/test/kotlin/com/datadog/reactnative/HeatmapTouchResolverTest.kt +529 -0
- package/datadog-configuration.schema.json +4 -0
- package/ios/Sources/DdSdk.mm +2 -0
- package/ios/Sources/DdSdkImplementation.swift +0 -1
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +3 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/config/FileBasedConfiguration.js +1 -0
- package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +1 -0
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/commonjs/config/features/RumConfiguration.js +4 -0
- package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +27 -13
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +270 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +38 -72
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.js +33 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +39 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/ResourceReporter.js +4 -4
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/internalDevResourceBlocklist.js +0 -18
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/internalDevResourceBlocklist.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.js +109 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/resourceTiming.js +0 -9
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/resourceTiming.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +3 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/config/FileBasedConfiguration.js +1 -0
- package/lib/module/config/FileBasedConfiguration.js.map +1 -1
- package/lib/module/config/async/AutoInstrumentationConfiguration.js +1 -0
- package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/module/config/features/RumConfiguration.js +4 -0
- package/lib/module/config/features/RumConfiguration.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +27 -13
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +263 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +38 -72
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.js +25 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +32 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/ResourceReporter.js +4 -4
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/internalDevResourceBlocklist.js +0 -18
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/internalDevResourceBlocklist.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.js +101 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/resourceTiming.js +0 -9
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/resourceTiming.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts +1 -0
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +2 -0
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.d.ts +2 -0
- package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.type.d.ts +7 -0
- package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +3 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.d.ts +29 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts +20 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/ResourceReporter.d.ts +2 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/internalDevResourceBlocklist.d.ts +3 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/internalDevResourceBlocklist.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.d.ts +18 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/resourceTiming.d.ts +0 -6
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/resourceTiming.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +11 -2
- package/src/DdSdkReactNative.tsx +5 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +5 -2
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -0
- package/src/config/FileBasedConfiguration.ts +2 -0
- package/src/config/FileBasedConfiguration.type.ts +1 -0
- package/src/config/__tests__/FileBasedConfiguration.test.ts +3 -0
- package/src/config/__tests__/__fixtures__/configuration-all-fields.json +1 -0
- package/src/config/async/AutoInstrumentationConfiguration.ts +5 -0
- package/src/config/features/RumConfiguration.ts +4 -0
- package/src/config/features/RumConfiguration.type.ts +8 -0
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +38 -13
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +101 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.ts +316 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/__tests__/FetchProxy.test.ts +393 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/__tests__/ResourceReporter.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +49 -115
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.ts +25 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.ts +54 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/ResourceReporter.ts +5 -5
- package/src/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/internalDevResourceBlocklist.ts +1 -17
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.ts +106 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/resourceTiming.ts +0 -18
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -0
- package/src/version.ts +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.js.map +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts.map +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts +0 -7
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts.map +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.d.ts.map +0 -1
- /package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdFlags.kt +0 -0
- /package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdLogs.kt +0 -0
- /package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdSdk.kt +0 -0
- /package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdTrace.kt +0 -0
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
+
import com.datadog.android.heatmaps.CrossPlatformHeatmapActionData
|
|
9
10
|
import com.datadog.android.rum.RumActionType
|
|
10
11
|
import com.datadog.android.rum.RumAttributes
|
|
11
12
|
import com.datadog.android.rum.RumErrorSource
|
|
12
13
|
import com.datadog.android.rum.RumMonitor
|
|
13
14
|
import com.datadog.android.rum.RumResourceKind
|
|
14
15
|
import com.datadog.android.rum.RumResourceMethod
|
|
16
|
+
import com.datadog.android.rum._RumInternalProxy
|
|
15
17
|
import com.datadog.tools.unit.forge.BaseConfigurator
|
|
16
18
|
import com.datadog.tools.unit.toReadableArray
|
|
17
19
|
import com.datadog.tools.unit.toReadableMap
|
|
@@ -36,7 +38,11 @@ import org.junit.jupiter.api.extension.Extensions
|
|
|
36
38
|
import org.mockito.Mock
|
|
37
39
|
import org.mockito.junit.jupiter.MockitoExtension
|
|
38
40
|
import org.mockito.junit.jupiter.MockitoSettings
|
|
41
|
+
import org.mockito.kotlin.any
|
|
39
42
|
import org.mockito.kotlin.doReturn
|
|
43
|
+
import org.mockito.kotlin.eq
|
|
44
|
+
import org.mockito.kotlin.inOrder
|
|
45
|
+
import org.mockito.kotlin.never
|
|
40
46
|
import org.mockito.kotlin.verify
|
|
41
47
|
import org.mockito.kotlin.whenever
|
|
42
48
|
import org.mockito.quality.Strictness
|
|
@@ -49,6 +55,18 @@ import org.mockito.quality.Strictness
|
|
|
49
55
|
@ForgeConfiguration(BaseConfigurator::class)
|
|
50
56
|
internal class DdRumTest {
|
|
51
57
|
|
|
58
|
+
/**
|
|
59
|
+
* `RumMonitor._getInternal()` is a synthetic method (dd-sdk-android's `@NoOpImplementation`);
|
|
60
|
+
* Mockito can't override it, so stubbing it directly throws `AbstractMethodError`. A real
|
|
61
|
+
* compiled override sidesteps that.
|
|
62
|
+
*/
|
|
63
|
+
private class RumMonitorWithInternalProxy(
|
|
64
|
+
monitor: RumMonitor,
|
|
65
|
+
private val internalProxy: _RumInternalProxy?
|
|
66
|
+
) : RumMonitor by monitor {
|
|
67
|
+
override fun _getInternal(): _RumInternalProxy? = internalProxy
|
|
68
|
+
}
|
|
69
|
+
|
|
52
70
|
// TODO: 14/12/2020 RUMM-925 Add the relevant unit tests after merging the feature/bridge branch
|
|
53
71
|
|
|
54
72
|
lateinit var testedDdRum: DdRumImplementation
|
|
@@ -62,6 +80,12 @@ internal class DdRumTest {
|
|
|
62
80
|
@Mock
|
|
63
81
|
lateinit var mockPromise: Promise
|
|
64
82
|
|
|
83
|
+
@Mock
|
|
84
|
+
lateinit var mockInternalProxy: _RumInternalProxy
|
|
85
|
+
|
|
86
|
+
@Mock
|
|
87
|
+
lateinit var mockHeatmapTouchResolver: HeatmapTouchResolver
|
|
88
|
+
|
|
65
89
|
lateinit var fakeContext: Map<String, Any?>
|
|
66
90
|
|
|
67
91
|
@DoubleForgery(1000000000000.0, 2000000000000.0)
|
|
@@ -88,6 +112,8 @@ internal class DdRumTest {
|
|
|
88
112
|
|
|
89
113
|
@AfterEach
|
|
90
114
|
fun `tear down`() {
|
|
115
|
+
// Reset global heatmaps flag so it never leaks into subsequent tests
|
|
116
|
+
HeatmapActionHandler.heatmapsEnabled = false
|
|
91
117
|
}
|
|
92
118
|
|
|
93
119
|
@Test
|
|
@@ -555,4 +581,460 @@ internal class DdRumTest {
|
|
|
555
581
|
// Then
|
|
556
582
|
verify(mockRumMonitor).addFeatureFlagEvaluation(name, value)
|
|
557
583
|
}
|
|
584
|
+
|
|
585
|
+
@Test
|
|
586
|
+
fun `M call addActionWithHeatmap W addAction() with TAP type and resolver returns data`(
|
|
587
|
+
@StringForgery name: String,
|
|
588
|
+
@IntForgery(min = 1) fakeReactTag: Int,
|
|
589
|
+
@DoubleForgery(0.0, 300.0) fakeX: Double,
|
|
590
|
+
@DoubleForgery(0.0, 300.0) fakeY: Double,
|
|
591
|
+
@StringForgery fakeViewUrl: String
|
|
592
|
+
) {
|
|
593
|
+
// Given
|
|
594
|
+
val updatedContext = fakeContext.toReadableMap().toHashMap().toMutableMap().apply {
|
|
595
|
+
put(RumAttributes.INTERNAL_TIMESTAMP, fakeTimestamp.toLong())
|
|
596
|
+
}
|
|
597
|
+
HeatmapActionHandler.heatmapsEnabled = true
|
|
598
|
+
whenever(mockDatadog.getRumMonitor()) doReturn RumMonitorWithInternalProxy(
|
|
599
|
+
mockRumMonitor,
|
|
600
|
+
mockInternalProxy
|
|
601
|
+
)
|
|
602
|
+
whenever(mockInternalProxy.getCurrentViewUrl()) doReturn fakeViewUrl
|
|
603
|
+
|
|
604
|
+
val fakeHeatmapData = CrossPlatformHeatmapActionData(
|
|
605
|
+
elementPath = listOf("cls:android.view.View#0"),
|
|
606
|
+
viewUrl = fakeViewUrl,
|
|
607
|
+
positionX = fakeX.toLong(),
|
|
608
|
+
positionY = fakeY.toLong(),
|
|
609
|
+
targetWidth = 100L,
|
|
610
|
+
targetHeight = 50L
|
|
611
|
+
)
|
|
612
|
+
whenever(
|
|
613
|
+
mockHeatmapTouchResolver.resolveHeatmapActionData(
|
|
614
|
+
fakeReactTag,
|
|
615
|
+
fakeX.toLong(),
|
|
616
|
+
fakeY.toLong(),
|
|
617
|
+
fakeViewUrl
|
|
618
|
+
)
|
|
619
|
+
) doReturn fakeHeatmapData
|
|
620
|
+
|
|
621
|
+
val testedDdRumWithHeatmap = DdRumImplementation(
|
|
622
|
+
datadog = mockDatadog,
|
|
623
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
624
|
+
heatmapTouchResolver = mockHeatmapTouchResolver,
|
|
625
|
+
mainThreadExecutor = { it() }
|
|
626
|
+
)
|
|
627
|
+
)
|
|
628
|
+
val fakeTouch = mapOf<String, Any>(
|
|
629
|
+
"reactTag" to fakeReactTag,
|
|
630
|
+
"x" to fakeX,
|
|
631
|
+
"y" to fakeY,
|
|
632
|
+
"pageX" to fakeX,
|
|
633
|
+
"pageY" to fakeY
|
|
634
|
+
).toReadableMap()
|
|
635
|
+
|
|
636
|
+
// When
|
|
637
|
+
testedDdRumWithHeatmap.addAction(
|
|
638
|
+
"TAP",
|
|
639
|
+
name,
|
|
640
|
+
fakeTouch,
|
|
641
|
+
fakeContext.toReadableMap(),
|
|
642
|
+
fakeTimestamp,
|
|
643
|
+
mockPromise
|
|
644
|
+
)
|
|
645
|
+
|
|
646
|
+
// Then
|
|
647
|
+
verify(mockInternalProxy).addActionWithHeatmap(
|
|
648
|
+
eq(RumActionType.TAP),
|
|
649
|
+
eq(name),
|
|
650
|
+
eq(fakeHeatmapData),
|
|
651
|
+
eq(updatedContext)
|
|
652
|
+
)
|
|
653
|
+
verify(mockPromise).resolve(null)
|
|
654
|
+
verify(mockRumMonitor, never()).addAction(RumActionType.TAP, name, updatedContext)
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
@Test
|
|
658
|
+
fun `M fall back to addAction W addAction() with TAP type and resolver returns null`(
|
|
659
|
+
@StringForgery name: String,
|
|
660
|
+
@IntForgery(min = 1) fakeReactTag: Int,
|
|
661
|
+
@DoubleForgery(0.0, 300.0) fakeX: Double,
|
|
662
|
+
@DoubleForgery(0.0, 300.0) fakeY: Double,
|
|
663
|
+
@StringForgery fakeViewUrl: String
|
|
664
|
+
) {
|
|
665
|
+
// Given
|
|
666
|
+
val updatedContext = fakeContext.toReadableMap().toHashMap().toMutableMap().apply {
|
|
667
|
+
put(RumAttributes.INTERNAL_TIMESTAMP, fakeTimestamp.toLong())
|
|
668
|
+
}
|
|
669
|
+
HeatmapActionHandler.heatmapsEnabled = true
|
|
670
|
+
whenever(mockDatadog.getRumMonitor()) doReturn RumMonitorWithInternalProxy(
|
|
671
|
+
mockRumMonitor,
|
|
672
|
+
mockInternalProxy
|
|
673
|
+
)
|
|
674
|
+
whenever(mockInternalProxy.getCurrentViewUrl()) doReturn fakeViewUrl
|
|
675
|
+
whenever(
|
|
676
|
+
mockHeatmapTouchResolver.resolveHeatmapActionData(any(), any(), any(), any())
|
|
677
|
+
) doReturn null
|
|
678
|
+
|
|
679
|
+
val testedDdRumWithHeatmap = DdRumImplementation(
|
|
680
|
+
datadog = mockDatadog,
|
|
681
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
682
|
+
heatmapTouchResolver = mockHeatmapTouchResolver,
|
|
683
|
+
mainThreadExecutor = { it() }
|
|
684
|
+
)
|
|
685
|
+
)
|
|
686
|
+
val fakeTouch = mapOf<String, Any>(
|
|
687
|
+
"reactTag" to fakeReactTag,
|
|
688
|
+
"x" to fakeX,
|
|
689
|
+
"y" to fakeY,
|
|
690
|
+
"pageX" to fakeX,
|
|
691
|
+
"pageY" to fakeY
|
|
692
|
+
).toReadableMap()
|
|
693
|
+
|
|
694
|
+
// When
|
|
695
|
+
testedDdRumWithHeatmap.addAction(
|
|
696
|
+
"TAP",
|
|
697
|
+
name,
|
|
698
|
+
fakeTouch,
|
|
699
|
+
fakeContext.toReadableMap(),
|
|
700
|
+
fakeTimestamp,
|
|
701
|
+
mockPromise
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
// Then
|
|
705
|
+
verify(mockRumMonitor).addAction(RumActionType.TAP, name, updatedContext)
|
|
706
|
+
verify(mockInternalProxy, never()).addActionWithHeatmap(any(), any(), any(), any())
|
|
707
|
+
verify(mockPromise).resolve(null)
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
@Test
|
|
711
|
+
fun `M call addAction W addAction() with TAP type and no internal proxy`(
|
|
712
|
+
@StringForgery name: String,
|
|
713
|
+
@IntForgery(min = 1) fakeReactTag: Int,
|
|
714
|
+
@DoubleForgery(0.0, 300.0) fakeX: Double,
|
|
715
|
+
@DoubleForgery(0.0, 300.0) fakeY: Double
|
|
716
|
+
) {
|
|
717
|
+
// Given
|
|
718
|
+
val updatedContext = fakeContext.toReadableMap().toHashMap().toMutableMap().apply {
|
|
719
|
+
put(RumAttributes.INTERNAL_TIMESTAMP, fakeTimestamp.toLong())
|
|
720
|
+
}
|
|
721
|
+
HeatmapActionHandler.heatmapsEnabled = true
|
|
722
|
+
whenever(mockDatadog.getRumMonitor()) doReturn RumMonitorWithInternalProxy(
|
|
723
|
+
mockRumMonitor,
|
|
724
|
+
null
|
|
725
|
+
)
|
|
726
|
+
|
|
727
|
+
val fakeTouch = mapOf<String, Any>(
|
|
728
|
+
"reactTag" to fakeReactTag,
|
|
729
|
+
"x" to fakeX,
|
|
730
|
+
"y" to fakeY,
|
|
731
|
+
"pageX" to fakeX,
|
|
732
|
+
"pageY" to fakeY
|
|
733
|
+
).toReadableMap()
|
|
734
|
+
|
|
735
|
+
// When
|
|
736
|
+
testedDdRum.addAction(
|
|
737
|
+
"TAP",
|
|
738
|
+
name,
|
|
739
|
+
fakeTouch,
|
|
740
|
+
fakeContext.toReadableMap(),
|
|
741
|
+
fakeTimestamp,
|
|
742
|
+
mockPromise
|
|
743
|
+
)
|
|
744
|
+
|
|
745
|
+
// Then
|
|
746
|
+
verify(mockRumMonitor).addAction(RumActionType.TAP, name, updatedContext)
|
|
747
|
+
verify(mockPromise).resolve(null)
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// region heatmapsEnabled gate and type guard
|
|
751
|
+
|
|
752
|
+
@Test
|
|
753
|
+
fun `M call addAction W addAction() TAP with touch but heatmapsEnabled false`(
|
|
754
|
+
@StringForgery name: String,
|
|
755
|
+
@IntForgery(min = 1) fakeReactTag: Int,
|
|
756
|
+
@DoubleForgery(0.0, 300.0) fakeX: Double,
|
|
757
|
+
@DoubleForgery(0.0, 300.0) fakeY: Double
|
|
758
|
+
) {
|
|
759
|
+
// Given — heatmapsEnabled false short-circuits before _getInternal() is reached
|
|
760
|
+
val updatedContext = fakeContext.toReadableMap().toHashMap().toMutableMap().apply {
|
|
761
|
+
put(RumAttributes.INTERNAL_TIMESTAMP, fakeTimestamp.toLong())
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
val fakeTouch = mapOf<String, Any>(
|
|
765
|
+
"reactTag" to fakeReactTag,
|
|
766
|
+
"x" to fakeX,
|
|
767
|
+
"y" to fakeY,
|
|
768
|
+
"pageX" to fakeX,
|
|
769
|
+
"pageY" to fakeY
|
|
770
|
+
).toReadableMap()
|
|
771
|
+
|
|
772
|
+
// When
|
|
773
|
+
testedDdRum.addAction(
|
|
774
|
+
"TAP",
|
|
775
|
+
name,
|
|
776
|
+
fakeTouch,
|
|
777
|
+
fakeContext.toReadableMap(),
|
|
778
|
+
fakeTimestamp,
|
|
779
|
+
mockPromise
|
|
780
|
+
)
|
|
781
|
+
|
|
782
|
+
// Then
|
|
783
|
+
verify(mockRumMonitor).addAction(RumActionType.TAP, name, updatedContext)
|
|
784
|
+
verify(mockInternalProxy, never()).addActionWithHeatmap(
|
|
785
|
+
any(),
|
|
786
|
+
any(),
|
|
787
|
+
any(),
|
|
788
|
+
any()
|
|
789
|
+
)
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
@Test
|
|
793
|
+
fun `M call addAction W addAction() non-TAP type with touch and heatmapsEnabled`(
|
|
794
|
+
@StringForgery name: String,
|
|
795
|
+
@IntForgery(min = 1) fakeReactTag: Int,
|
|
796
|
+
@DoubleForgery(0.0, 300.0) fakeX: Double,
|
|
797
|
+
@DoubleForgery(0.0, 300.0) fakeY: Double
|
|
798
|
+
) {
|
|
799
|
+
// Given — non-TAP type short-circuits before _getInternal() is reached
|
|
800
|
+
val updatedContext = fakeContext.toReadableMap().toHashMap().toMutableMap().apply {
|
|
801
|
+
put(RumAttributes.INTERNAL_TIMESTAMP, fakeTimestamp.toLong())
|
|
802
|
+
}
|
|
803
|
+
HeatmapActionHandler.heatmapsEnabled = true
|
|
804
|
+
|
|
805
|
+
val fakeTouch = mapOf<String, Any>(
|
|
806
|
+
"reactTag" to fakeReactTag,
|
|
807
|
+
"x" to fakeX,
|
|
808
|
+
"y" to fakeY,
|
|
809
|
+
"pageX" to fakeX,
|
|
810
|
+
"pageY" to fakeY
|
|
811
|
+
).toReadableMap()
|
|
812
|
+
|
|
813
|
+
val testedDdRumWithHeatmap = DdRumImplementation(
|
|
814
|
+
datadog = mockDatadog,
|
|
815
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
816
|
+
heatmapTouchResolver = mockHeatmapTouchResolver,
|
|
817
|
+
mainThreadExecutor = { it() }
|
|
818
|
+
)
|
|
819
|
+
)
|
|
820
|
+
|
|
821
|
+
// When
|
|
822
|
+
testedDdRumWithHeatmap.addAction(
|
|
823
|
+
"SCROLL",
|
|
824
|
+
name,
|
|
825
|
+
fakeTouch,
|
|
826
|
+
fakeContext.toReadableMap(),
|
|
827
|
+
fakeTimestamp,
|
|
828
|
+
mockPromise
|
|
829
|
+
)
|
|
830
|
+
|
|
831
|
+
// Then
|
|
832
|
+
verify(mockRumMonitor).addAction(RumActionType.SCROLL, name, updatedContext)
|
|
833
|
+
verify(mockInternalProxy, never()).addActionWithHeatmap(
|
|
834
|
+
any(),
|
|
835
|
+
any(),
|
|
836
|
+
any(),
|
|
837
|
+
any()
|
|
838
|
+
)
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
@Test
|
|
842
|
+
fun `M fall back to addAction W addAction() TAP with touch missing required keys`(
|
|
843
|
+
@StringForgery name: String,
|
|
844
|
+
@StringForgery fakeViewUrl: String
|
|
845
|
+
) {
|
|
846
|
+
// Given
|
|
847
|
+
val updatedContext = fakeContext.toReadableMap().toHashMap().toMutableMap().apply {
|
|
848
|
+
put(RumAttributes.INTERNAL_TIMESTAMP, fakeTimestamp.toLong())
|
|
849
|
+
}
|
|
850
|
+
HeatmapActionHandler.heatmapsEnabled = true
|
|
851
|
+
whenever(mockDatadog.getRumMonitor()) doReturn RumMonitorWithInternalProxy(
|
|
852
|
+
mockRumMonitor,
|
|
853
|
+
mockInternalProxy
|
|
854
|
+
)
|
|
855
|
+
whenever(mockInternalProxy.getCurrentViewUrl()) doReturn fakeViewUrl
|
|
856
|
+
|
|
857
|
+
val fakeIncompleteTouch = mapOf<String, Any>("reactTag" to 1).toReadableMap()
|
|
858
|
+
|
|
859
|
+
val testedDdRumWithHeatmap = DdRumImplementation(
|
|
860
|
+
datadog = mockDatadog,
|
|
861
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
862
|
+
heatmapTouchResolver = mockHeatmapTouchResolver,
|
|
863
|
+
mainThreadExecutor = { it() }
|
|
864
|
+
)
|
|
865
|
+
)
|
|
866
|
+
|
|
867
|
+
// When
|
|
868
|
+
testedDdRumWithHeatmap.addAction(
|
|
869
|
+
"TAP",
|
|
870
|
+
name,
|
|
871
|
+
fakeIncompleteTouch,
|
|
872
|
+
fakeContext.toReadableMap(),
|
|
873
|
+
fakeTimestamp,
|
|
874
|
+
mockPromise
|
|
875
|
+
)
|
|
876
|
+
|
|
877
|
+
// Then
|
|
878
|
+
verify(mockRumMonitor).addAction(RumActionType.TAP, name, updatedContext)
|
|
879
|
+
verify(mockInternalProxy, never()).addActionWithHeatmap(any(), any(), any(), any())
|
|
880
|
+
verify(mockPromise).resolve(null)
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
@Test
|
|
884
|
+
fun `M fall back to addAction W addAction() TAP with touch fields of the wrong type`(
|
|
885
|
+
@StringForgery name: String,
|
|
886
|
+
@StringForgery fakeViewUrl: String
|
|
887
|
+
) {
|
|
888
|
+
// Given
|
|
889
|
+
val updatedContext = fakeContext.toReadableMap().toHashMap().toMutableMap().apply {
|
|
890
|
+
put(RumAttributes.INTERNAL_TIMESTAMP, fakeTimestamp.toLong())
|
|
891
|
+
}
|
|
892
|
+
HeatmapActionHandler.heatmapsEnabled = true
|
|
893
|
+
whenever(mockDatadog.getRumMonitor()) doReturn RumMonitorWithInternalProxy(
|
|
894
|
+
mockRumMonitor,
|
|
895
|
+
mockInternalProxy
|
|
896
|
+
)
|
|
897
|
+
whenever(mockInternalProxy.getCurrentViewUrl()) doReturn fakeViewUrl
|
|
898
|
+
|
|
899
|
+
val fakeMistypedTouch = mapOf<String, Any>(
|
|
900
|
+
"reactTag" to 1,
|
|
901
|
+
"x" to "not-a-number",
|
|
902
|
+
"y" to 2.0
|
|
903
|
+
).toReadableMap()
|
|
904
|
+
|
|
905
|
+
val testedDdRumWithHeatmap = DdRumImplementation(
|
|
906
|
+
datadog = mockDatadog,
|
|
907
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
908
|
+
heatmapTouchResolver = mockHeatmapTouchResolver,
|
|
909
|
+
mainThreadExecutor = { it() }
|
|
910
|
+
)
|
|
911
|
+
)
|
|
912
|
+
|
|
913
|
+
// When
|
|
914
|
+
testedDdRumWithHeatmap.addAction(
|
|
915
|
+
"TAP",
|
|
916
|
+
name,
|
|
917
|
+
fakeMistypedTouch,
|
|
918
|
+
fakeContext.toReadableMap(),
|
|
919
|
+
fakeTimestamp,
|
|
920
|
+
mockPromise
|
|
921
|
+
)
|
|
922
|
+
|
|
923
|
+
// Then
|
|
924
|
+
verify(mockRumMonitor).addAction(RumActionType.TAP, name, updatedContext)
|
|
925
|
+
verify(mockInternalProxy, never()).addActionWithHeatmap(any(), any(), any(), any())
|
|
926
|
+
verify(mockPromise).resolve(null)
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
@Test
|
|
930
|
+
fun `M fall back to addAction W addAction() TAP with no current view url`(
|
|
931
|
+
@StringForgery name: String,
|
|
932
|
+
@IntForgery(min = 1) fakeReactTag: Int,
|
|
933
|
+
@DoubleForgery(0.0, 300.0) fakeX: Double,
|
|
934
|
+
@DoubleForgery(0.0, 300.0) fakeY: Double
|
|
935
|
+
) {
|
|
936
|
+
// Given
|
|
937
|
+
val updatedContext = fakeContext.toReadableMap().toHashMap().toMutableMap().apply {
|
|
938
|
+
put(RumAttributes.INTERNAL_TIMESTAMP, fakeTimestamp.toLong())
|
|
939
|
+
}
|
|
940
|
+
HeatmapActionHandler.heatmapsEnabled = true
|
|
941
|
+
whenever(mockDatadog.getRumMonitor()) doReturn RumMonitorWithInternalProxy(
|
|
942
|
+
mockRumMonitor,
|
|
943
|
+
mockInternalProxy
|
|
944
|
+
)
|
|
945
|
+
whenever(mockInternalProxy.getCurrentViewUrl()) doReturn null
|
|
946
|
+
|
|
947
|
+
val fakeTouch = mapOf<String, Any>(
|
|
948
|
+
"reactTag" to fakeReactTag,
|
|
949
|
+
"x" to fakeX,
|
|
950
|
+
"y" to fakeY,
|
|
951
|
+
"pageX" to fakeX,
|
|
952
|
+
"pageY" to fakeY
|
|
953
|
+
).toReadableMap()
|
|
954
|
+
|
|
955
|
+
val testedDdRumWithHeatmap = DdRumImplementation(
|
|
956
|
+
datadog = mockDatadog,
|
|
957
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
958
|
+
heatmapTouchResolver = mockHeatmapTouchResolver,
|
|
959
|
+
mainThreadExecutor = { it() }
|
|
960
|
+
)
|
|
961
|
+
)
|
|
962
|
+
|
|
963
|
+
// When
|
|
964
|
+
testedDdRumWithHeatmap.addAction(
|
|
965
|
+
"TAP",
|
|
966
|
+
name,
|
|
967
|
+
fakeTouch,
|
|
968
|
+
fakeContext.toReadableMap(),
|
|
969
|
+
fakeTimestamp,
|
|
970
|
+
mockPromise
|
|
971
|
+
)
|
|
972
|
+
|
|
973
|
+
// Then
|
|
974
|
+
verify(mockRumMonitor).addAction(RumActionType.TAP, name, updatedContext)
|
|
975
|
+
verify(mockInternalProxy, never()).addActionWithHeatmap(any(), any(), any(), any())
|
|
976
|
+
verify(mockPromise).resolve(null)
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
@Test
|
|
980
|
+
fun `M resolve promise before dispatching heatmap work W addAction() with TAP type`(
|
|
981
|
+
@StringForgery name: String,
|
|
982
|
+
@IntForgery(min = 1) fakeReactTag: Int,
|
|
983
|
+
@DoubleForgery(0.0, 300.0) fakeX: Double,
|
|
984
|
+
@DoubleForgery(0.0, 300.0) fakeY: Double,
|
|
985
|
+
@StringForgery fakeViewUrl: String
|
|
986
|
+
) {
|
|
987
|
+
// Given
|
|
988
|
+
HeatmapActionHandler.heatmapsEnabled = true
|
|
989
|
+
whenever(mockDatadog.getRumMonitor()) doReturn RumMonitorWithInternalProxy(
|
|
990
|
+
mockRumMonitor,
|
|
991
|
+
mockInternalProxy
|
|
992
|
+
)
|
|
993
|
+
whenever(mockInternalProxy.getCurrentViewUrl()) doReturn fakeViewUrl
|
|
994
|
+
|
|
995
|
+
val fakeHeatmapData = CrossPlatformHeatmapActionData(
|
|
996
|
+
elementPath = listOf("cls:android.view.View#0"),
|
|
997
|
+
viewUrl = fakeViewUrl,
|
|
998
|
+
positionX = fakeX.toLong(),
|
|
999
|
+
positionY = fakeY.toLong(),
|
|
1000
|
+
targetWidth = 100L,
|
|
1001
|
+
targetHeight = 50L
|
|
1002
|
+
)
|
|
1003
|
+
whenever(
|
|
1004
|
+
mockHeatmapTouchResolver.resolveHeatmapActionData(any(), any(), any(), any())
|
|
1005
|
+
) doReturn fakeHeatmapData
|
|
1006
|
+
|
|
1007
|
+
val testedDdRumWithHeatmap = DdRumImplementation(
|
|
1008
|
+
datadog = mockDatadog,
|
|
1009
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
1010
|
+
heatmapTouchResolver = mockHeatmapTouchResolver,
|
|
1011
|
+
mainThreadExecutor = { it() }
|
|
1012
|
+
)
|
|
1013
|
+
)
|
|
1014
|
+
val fakeTouch = mapOf<String, Any>(
|
|
1015
|
+
"reactTag" to fakeReactTag,
|
|
1016
|
+
"x" to fakeX,
|
|
1017
|
+
"y" to fakeY,
|
|
1018
|
+
"pageX" to fakeX,
|
|
1019
|
+
"pageY" to fakeY
|
|
1020
|
+
).toReadableMap()
|
|
1021
|
+
|
|
1022
|
+
// When
|
|
1023
|
+
testedDdRumWithHeatmap.addAction(
|
|
1024
|
+
"TAP",
|
|
1025
|
+
name,
|
|
1026
|
+
fakeTouch,
|
|
1027
|
+
fakeContext.toReadableMap(),
|
|
1028
|
+
fakeTimestamp,
|
|
1029
|
+
mockPromise
|
|
1030
|
+
)
|
|
1031
|
+
|
|
1032
|
+
// Then — order holds even though mainThreadExecutor runs synchronously here
|
|
1033
|
+
inOrder(mockPromise, mockInternalProxy) {
|
|
1034
|
+
verify(mockPromise).resolve(null)
|
|
1035
|
+
verify(mockInternalProxy).addActionWithHeatmap(any(), any(), any(), any())
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// endregion
|
|
558
1040
|
}
|