@datadog/mobile-react-native 2.6.3 → 2.6.5
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 +6 -6
- package/android/build.gradle +4 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +17 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +26 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +12 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +5 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +7 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +39 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +33 -5
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +10 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +28 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +10 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +30 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +9 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +3 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +226 -4
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +6 -0
- package/android/src/test/resources/input/complete-configuration.json +2 -1
- package/datadog-configuration.schema.json +4 -0
- package/ios/Sources/DdRum.mm +11 -0
- package/ios/Sources/DdRumImplementation.swift +7 -0
- package/ios/Sources/DdSdk.h +5 -3
- package/ios/Sources/DdSdk.mm +27 -1
- package/ios/Sources/DdSdkConfiguration.swift +5 -1
- package/ios/Sources/DdSdkImplementation.swift +31 -2
- package/ios/Sources/DdSdkNativeInitialization.swift +17 -6
- package/ios/Sources/RNDdSdkConfiguration.swift +7 -3
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +6 -0
- package/lib/commonjs/DdSdkReactNative.js +24 -4
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +36 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +2 -1
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +19 -3
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +33 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +6 -4
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +31 -12
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +9 -8
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/rum/sessionId/sessionIdHelper.js +67 -0
- package/lib/commonjs/rum/sessionId/sessionIdHelper.js.map +1 -0
- package/lib/commonjs/rum/types.js +5 -0
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/sdk/EventEmitter/EventEmitter.js +51 -0
- package/lib/commonjs/sdk/EventEmitter/EventEmitter.js.map +1 -0
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
- package/lib/commonjs/types.js +4 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/Timer.js +2 -2
- package/lib/commonjs/utils/Timer.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +24 -4
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +36 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +2 -1
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +19 -3
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +33 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +6 -4
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +30 -11
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +8 -6
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/rum/sessionId/sessionIdHelper.js +56 -0
- package/lib/module/rum/sessionId/sessionIdHelper.js.map +1 -0
- package/lib/module/rum/types.js +5 -0
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/sdk/EventEmitter/EventEmitter.js +43 -0
- package/lib/module/sdk/EventEmitter/EventEmitter.js.map +1 -0
- package/lib/module/specs/NativeDdRum.js.map +1 -1
- package/lib/module/specs/NativeDdSdk.js.map +1 -1
- package/lib/module/types.js +4 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/Timer.js +1 -1
- package/lib/module/utils/Timer.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +17 -2
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +8 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts.map +1 -1
- package/lib/typescript/rum/DdRum.d.ts +3 -0
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts +2 -2
- package/lib/typescript/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +4 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +3 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
- package/lib/typescript/rum/sessionId/sessionIdHelper.d.ts +26 -0
- package/lib/typescript/rum/sessionId/sessionIdHelper.d.ts.map +1 -0
- package/lib/typescript/rum/types.d.ts +6 -0
- package/lib/typescript/rum/types.d.ts.map +1 -1
- package/lib/typescript/sdk/EventEmitter/EventEmitter.d.ts +12 -0
- package/lib/typescript/sdk/EventEmitter/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +3 -2
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdRum.d.ts +6 -0
- package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdSdk.d.ts +17 -0
- package/lib/typescript/specs/NativeDdSdk.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +22 -5
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/Timer.d.ts +1 -1
- package/lib/typescript/utils/Timer.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +40 -5
- package/src/DdSdkReactNativeConfiguration.tsx +10 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +101 -12
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
- package/src/__tests__/mock.test.ts +2 -1
- package/src/nativeModulesTypes.ts +1 -1
- package/src/rum/DdRum.ts +39 -4
- package/src/rum/__mocks__/MockTimeProvider.ts +1 -1
- package/src/rum/__tests__/DdRum.test.ts +17 -0
- package/src/rum/__tests__/DdRumTimeProvider.test.ts +1 -1
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +1 -1
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +2 -2
- package/src/rum/instrumentation/interactionTracking/EventsInterceptor.tsx +1 -1
- package/src/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.tsx +2 -2
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +10 -4
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +42 -15
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +8 -6
- package/src/rum/sessionId/__tests__/sessionIdHelper.test.ts +162 -0
- package/src/rum/sessionId/sessionIdHelper.ts +59 -0
- package/src/rum/types.ts +7 -0
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -0
- package/src/sdk/EventEmitter/EventEmitter.ts +55 -0
- package/src/sdk/EventEmitter/__tests__/EventEmitter.test.ts +181 -0
- package/src/sdk/UserInfoSingleton/types.ts +5 -2
- package/src/specs/NativeDdRum.ts +7 -0
- package/src/specs/NativeDdSdk.ts +20 -0
- package/src/types.tsx +23 -5
- package/src/utils/Timer.ts +1 -1
- package/src/utils/__tests__/TimeProvider.test.tsx +1 -1
- package/src/utils/__tests__/Timer.test.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -22,6 +22,7 @@ import com.datadog.android.rum.RumConfiguration
|
|
|
22
22
|
import com.datadog.android.rum.RumPerformanceMetric
|
|
23
23
|
import com.datadog.android.rum._RumInternalProxy
|
|
24
24
|
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
|
|
25
|
+
import com.datadog.android.rum.metric.networksettled.TimeBasedInitialResourceIdentifier
|
|
25
26
|
import com.datadog.android.rum.model.ActionEvent
|
|
26
27
|
import com.datadog.android.rum.model.ResourceEvent
|
|
27
28
|
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
|
|
@@ -42,6 +43,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
42
43
|
import fr.xgouchet.elmyr.Forge
|
|
43
44
|
import fr.xgouchet.elmyr.annotation.AdvancedForgery
|
|
44
45
|
import fr.xgouchet.elmyr.annotation.BoolForgery
|
|
46
|
+
import fr.xgouchet.elmyr.annotation.DoubleForgery
|
|
45
47
|
import fr.xgouchet.elmyr.annotation.Forgery
|
|
46
48
|
import fr.xgouchet.elmyr.annotation.IntForgery
|
|
47
49
|
import fr.xgouchet.elmyr.annotation.LongForgery
|
|
@@ -52,6 +54,7 @@ import fr.xgouchet.elmyr.junit5.ForgeConfiguration
|
|
|
52
54
|
import fr.xgouchet.elmyr.junit5.ForgeExtension
|
|
53
55
|
import java.util.Locale
|
|
54
56
|
import java.util.stream.Stream
|
|
57
|
+
import kotlin.time.Duration.Companion.seconds
|
|
55
58
|
import org.assertj.core.api.Assertions.assertThat
|
|
56
59
|
import org.junit.jupiter.api.AfterEach
|
|
57
60
|
import org.junit.jupiter.api.BeforeEach
|
|
@@ -72,6 +75,7 @@ import org.mockito.kotlin.doReturn
|
|
|
72
75
|
import org.mockito.kotlin.doThrow
|
|
73
76
|
import org.mockito.kotlin.eq
|
|
74
77
|
import org.mockito.kotlin.inOrder
|
|
78
|
+
import org.mockito.kotlin.isNotNull
|
|
75
79
|
import org.mockito.kotlin.isNull
|
|
76
80
|
import org.mockito.kotlin.mock
|
|
77
81
|
import org.mockito.kotlin.never
|
|
@@ -1784,6 +1788,80 @@ internal class DdSdkTest {
|
|
|
1784
1788
|
|
|
1785
1789
|
// endregion
|
|
1786
1790
|
|
|
1791
|
+
// region initial resource threshold TNS
|
|
1792
|
+
|
|
1793
|
+
@Test
|
|
1794
|
+
fun `𝕄 initialize W initialize() { initialResourceThreshold is null }`(
|
|
1795
|
+
@Forgery configuration: DdSdkConfiguration
|
|
1796
|
+
) {
|
|
1797
|
+
// Given
|
|
1798
|
+
val sdkConfigCaptor = argumentCaptor<Configuration>()
|
|
1799
|
+
val rumConfigCaptor = argumentCaptor<RumConfiguration>()
|
|
1800
|
+
val logsConfigCaptor = argumentCaptor<LogsConfiguration>()
|
|
1801
|
+
val traceConfigCaptor = argumentCaptor<TraceConfiguration>()
|
|
1802
|
+
val defaultTimeBasedIdentifier = TimeBasedInitialResourceIdentifier(100)
|
|
1803
|
+
|
|
1804
|
+
// When
|
|
1805
|
+
testedBridgeSdk.initialize(configuration.toReadableJavaOnlyMap(), mockPromise)
|
|
1806
|
+
|
|
1807
|
+
// Then
|
|
1808
|
+
inOrder(mockDatadog) {
|
|
1809
|
+
verify(mockDatadog).initialize(
|
|
1810
|
+
same(mockContext),
|
|
1811
|
+
sdkConfigCaptor.capture(),
|
|
1812
|
+
any()
|
|
1813
|
+
)
|
|
1814
|
+
verify(mockDatadog).enableRum(rumConfigCaptor.capture())
|
|
1815
|
+
verify(mockDatadog).enableTrace(traceConfigCaptor.capture())
|
|
1816
|
+
verify(mockDatadog).enableLogs(logsConfigCaptor.capture())
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
assertThat(rumConfigCaptor.firstValue)
|
|
1820
|
+
.hasField("featureConfiguration") {
|
|
1821
|
+
it.hasFieldEqualTo("initialResourceIdentifier", defaultTimeBasedIdentifier)
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
@Test
|
|
1826
|
+
fun `𝕄 initialize W initialize() { initialResourceThreshold is not null}`(
|
|
1827
|
+
@DoubleForgery(min = 0.1, max = 5.0) thresholdInSeconds: Double,
|
|
1828
|
+
@Forgery configuration: DdSdkConfiguration
|
|
1829
|
+
) {
|
|
1830
|
+
// Given
|
|
1831
|
+
val bridgeConfiguration = configuration.copy(
|
|
1832
|
+
initialResourceThreshold = thresholdInSeconds
|
|
1833
|
+
)
|
|
1834
|
+
val sdkConfigCaptor = argumentCaptor<Configuration>()
|
|
1835
|
+
val rumConfigCaptor = argumentCaptor<RumConfiguration>()
|
|
1836
|
+
val logsConfigCaptor = argumentCaptor<LogsConfiguration>()
|
|
1837
|
+
val traceConfigCaptor = argumentCaptor<TraceConfiguration>()
|
|
1838
|
+
val timeBasedIdentifier = TimeBasedInitialResourceIdentifier(
|
|
1839
|
+
thresholdInSeconds.seconds.inWholeMilliseconds
|
|
1840
|
+
)
|
|
1841
|
+
|
|
1842
|
+
// When
|
|
1843
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
1844
|
+
|
|
1845
|
+
// Then
|
|
1846
|
+
inOrder(mockDatadog) {
|
|
1847
|
+
verify(mockDatadog).initialize(
|
|
1848
|
+
same(mockContext),
|
|
1849
|
+
sdkConfigCaptor.capture(),
|
|
1850
|
+
any()
|
|
1851
|
+
)
|
|
1852
|
+
verify(mockDatadog).enableRum(rumConfigCaptor.capture())
|
|
1853
|
+
verify(mockDatadog).enableTrace(traceConfigCaptor.capture())
|
|
1854
|
+
verify(mockDatadog).enableLogs(logsConfigCaptor.capture())
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
assertThat(rumConfigCaptor.firstValue)
|
|
1858
|
+
.hasField("featureConfiguration") {
|
|
1859
|
+
it.hasFieldEqualTo("initialResourceIdentifier", timeBasedIdentifier)
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
// endregion
|
|
1864
|
+
|
|
1787
1865
|
// region version suffix
|
|
1788
1866
|
|
|
1789
1867
|
@Test
|
|
@@ -2064,7 +2142,7 @@ internal class DdSdkTest {
|
|
|
2064
2142
|
// Then
|
|
2065
2143
|
argumentCaptor<Map<String, Any?>> {
|
|
2066
2144
|
verify(mockDatadog)
|
|
2067
|
-
.
|
|
2145
|
+
.setUser(
|
|
2068
2146
|
isNull(),
|
|
2069
2147
|
isNull(),
|
|
2070
2148
|
isNull(),
|
|
@@ -2096,7 +2174,7 @@ internal class DdSdkTest {
|
|
|
2096
2174
|
// Then
|
|
2097
2175
|
argumentCaptor<Map<String, Any?>> {
|
|
2098
2176
|
verify(mockDatadog)
|
|
2099
|
-
.
|
|
2177
|
+
.setUser(
|
|
2100
2178
|
eq(id),
|
|
2101
2179
|
isNull(),
|
|
2102
2180
|
isNull(),
|
|
@@ -2128,7 +2206,7 @@ internal class DdSdkTest {
|
|
|
2128
2206
|
// Then
|
|
2129
2207
|
argumentCaptor<Map<String, Any?>> {
|
|
2130
2208
|
verify(mockDatadog)
|
|
2131
|
-
.
|
|
2209
|
+
.setUser(
|
|
2132
2210
|
isNull(),
|
|
2133
2211
|
eq(name),
|
|
2134
2212
|
isNull(),
|
|
@@ -2160,7 +2238,7 @@ internal class DdSdkTest {
|
|
|
2160
2238
|
// Then
|
|
2161
2239
|
argumentCaptor<Map<String, Any?>> {
|
|
2162
2240
|
verify(mockDatadog)
|
|
2163
|
-
.
|
|
2241
|
+
.setUser(
|
|
2164
2242
|
isNull(),
|
|
2165
2243
|
isNull(),
|
|
2166
2244
|
eq(email),
|
|
@@ -2193,6 +2271,127 @@ internal class DdSdkTest {
|
|
|
2193
2271
|
// When
|
|
2194
2272
|
testedBridgeSdk.setUser(user.toReadableMap(), mockPromise)
|
|
2195
2273
|
|
|
2274
|
+
// Then
|
|
2275
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2276
|
+
verify(mockDatadog)
|
|
2277
|
+
.setUser(
|
|
2278
|
+
eq(id),
|
|
2279
|
+
eq(name),
|
|
2280
|
+
eq(email),
|
|
2281
|
+
capture()
|
|
2282
|
+
)
|
|
2283
|
+
|
|
2284
|
+
assertThat(firstValue)
|
|
2285
|
+
.containsAllEntriesOf(extraInfo)
|
|
2286
|
+
.hasSize(extraInfo.size)
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
@Test
|
|
2291
|
+
fun `𝕄 set native user info 𝕎 setUserInfo() {with id}`(
|
|
2292
|
+
@StringForgery id: String
|
|
2293
|
+
) {
|
|
2294
|
+
// Given
|
|
2295
|
+
val userInfo = mapOf(
|
|
2296
|
+
"id" to id
|
|
2297
|
+
)
|
|
2298
|
+
|
|
2299
|
+
// When
|
|
2300
|
+
testedBridgeSdk.setUserInfo(userInfo.toReadableMap(), mockPromise)
|
|
2301
|
+
|
|
2302
|
+
// Then
|
|
2303
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2304
|
+
verify(mockDatadog)
|
|
2305
|
+
.setUserInfo(
|
|
2306
|
+
eq(id),
|
|
2307
|
+
isNull(),
|
|
2308
|
+
isNull(),
|
|
2309
|
+
capture()
|
|
2310
|
+
)
|
|
2311
|
+
|
|
2312
|
+
assertThat(firstValue).isEmpty()
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
@Test
|
|
2317
|
+
fun `𝕄 set native user info 𝕎 setUserInfo() {with id and name}`(
|
|
2318
|
+
@StringForgery id: String,
|
|
2319
|
+
@StringForgery name: String
|
|
2320
|
+
) {
|
|
2321
|
+
// Given
|
|
2322
|
+
val userInfo = mapOf(
|
|
2323
|
+
"id" to id,
|
|
2324
|
+
"name" to name
|
|
2325
|
+
)
|
|
2326
|
+
|
|
2327
|
+
// When
|
|
2328
|
+
testedBridgeSdk.setUserInfo(userInfo.toReadableMap(), mockPromise)
|
|
2329
|
+
|
|
2330
|
+
// Then
|
|
2331
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2332
|
+
verify(mockDatadog)
|
|
2333
|
+
.setUserInfo(
|
|
2334
|
+
eq(id),
|
|
2335
|
+
eq(name),
|
|
2336
|
+
isNull(),
|
|
2337
|
+
capture()
|
|
2338
|
+
)
|
|
2339
|
+
|
|
2340
|
+
assertThat(firstValue).isEmpty()
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
@Test
|
|
2345
|
+
fun `𝕄 set native user info 𝕎 setUserInfo() {with id, name and email}`(
|
|
2346
|
+
@StringForgery id: String,
|
|
2347
|
+
@StringForgery name: String,
|
|
2348
|
+
@StringForgery(regex = "\\w+@\\w+\\.[a-z]{3}") email: String
|
|
2349
|
+
) {
|
|
2350
|
+
// Given
|
|
2351
|
+
val userInfo = mapOf(
|
|
2352
|
+
"id" to id,
|
|
2353
|
+
"name" to name,
|
|
2354
|
+
"email" to email
|
|
2355
|
+
)
|
|
2356
|
+
|
|
2357
|
+
// When
|
|
2358
|
+
testedBridgeSdk.setUserInfo(userInfo.toReadableMap(), mockPromise)
|
|
2359
|
+
|
|
2360
|
+
// Then
|
|
2361
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2362
|
+
verify(mockDatadog)
|
|
2363
|
+
.setUserInfo(
|
|
2364
|
+
eq(id),
|
|
2365
|
+
eq(name),
|
|
2366
|
+
eq(email),
|
|
2367
|
+
capture()
|
|
2368
|
+
)
|
|
2369
|
+
|
|
2370
|
+
assertThat(firstValue).isEmpty()
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
@Test
|
|
2375
|
+
fun `𝕄 set native user info 𝕎 setUserInfo() {with id, name, email and extraInfo}`(
|
|
2376
|
+
@StringForgery id: String,
|
|
2377
|
+
@StringForgery name: String,
|
|
2378
|
+
@StringForgery(regex = "\\w+@\\w+\\.[a-z]{3}") email: String,
|
|
2379
|
+
@MapForgery(
|
|
2380
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
2381
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
2382
|
+
) extraInfo: Map<String, String>
|
|
2383
|
+
) {
|
|
2384
|
+
// Given
|
|
2385
|
+
val userInfo = mapOf(
|
|
2386
|
+
"id" to id,
|
|
2387
|
+
"name" to name,
|
|
2388
|
+
"email" to email,
|
|
2389
|
+
"extraInfo" to extraInfo
|
|
2390
|
+
)
|
|
2391
|
+
|
|
2392
|
+
// When
|
|
2393
|
+
testedBridgeSdk.setUserInfo(userInfo.toReadableMap(), mockPromise)
|
|
2394
|
+
|
|
2196
2395
|
// Then
|
|
2197
2396
|
argumentCaptor<Map<String, Any?>> {
|
|
2198
2397
|
verify(mockDatadog)
|
|
@@ -2209,6 +2408,29 @@ internal class DdSdkTest {
|
|
|
2209
2408
|
}
|
|
2210
2409
|
}
|
|
2211
2410
|
|
|
2411
|
+
@Test
|
|
2412
|
+
fun `𝕄 add native extra user info 𝕎 addUserExtraInfo() {with userExtraInfo}`(
|
|
2413
|
+
@MapForgery(
|
|
2414
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
2415
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
2416
|
+
) userExtraInfo: Map<String, String>
|
|
2417
|
+
) {
|
|
2418
|
+
// When
|
|
2419
|
+
testedBridgeSdk.addUserExtraInfo(userExtraInfo.toReadableMap(), mockPromise)
|
|
2420
|
+
|
|
2421
|
+
// Then
|
|
2422
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2423
|
+
verify(mockDatadog)
|
|
2424
|
+
.addUserExtraInfo(
|
|
2425
|
+
capture()
|
|
2426
|
+
)
|
|
2427
|
+
|
|
2428
|
+
assertThat(firstValue)
|
|
2429
|
+
.containsAllEntriesOf(userExtraInfo)
|
|
2430
|
+
.hasSize(userExtraInfo.size)
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2212
2434
|
@Test
|
|
2213
2435
|
fun `𝕄 set RUM attributes 𝕎 setAttributes`(
|
|
2214
2436
|
@MapForgery(
|
|
@@ -108,6 +108,12 @@ fun DdSdkConfiguration.toReadableJavaOnlyMap(): ReadableMap {
|
|
|
108
108
|
map["batchProcessingLevel"] = BatchProcessingLevel.MEDIUM.toString()
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
if (initialResourceThreshold != null) {
|
|
112
|
+
map.put("initialResourceThreshold", initialResourceThreshold)
|
|
113
|
+
} else {
|
|
114
|
+
map.put("initialResourceThreshold", 0.1f)
|
|
115
|
+
}
|
|
116
|
+
|
|
111
117
|
return map.toReadableMap()
|
|
112
118
|
}
|
|
113
119
|
|
|
@@ -241,6 +241,10 @@
|
|
|
241
241
|
"trackNonFatalAnrs": {
|
|
242
242
|
"description": "Enables tracking of non-fatal ANRs on Android.",
|
|
243
243
|
"type": "boolean"
|
|
244
|
+
},
|
|
245
|
+
"initialResourceThreshold" : {
|
|
246
|
+
"description": "The amount of time after a view starts where a Resource should be considered when calculating Time to Network-Settled (TNS)",
|
|
247
|
+
"type": "number"
|
|
244
248
|
}
|
|
245
249
|
},
|
|
246
250
|
"required": [
|
package/ios/Sources/DdRum.mm
CHANGED
|
@@ -107,6 +107,13 @@ RCT_REMAP_METHOD(addTiming, withName:(NSString*)name
|
|
|
107
107
|
[self addTiming:name resolve:resolve reject:reject];
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
RCT_REMAP_METHOD(addViewLoadingTime, withOverwrite:(BOOL)overwrite
|
|
111
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
112
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
113
|
+
{
|
|
114
|
+
[self addViewLoadingTime:overwrite resolve:resolve reject:reject];
|
|
115
|
+
}
|
|
116
|
+
|
|
110
117
|
RCT_REMAP_METHOD(stopSession, withResolve:(RCTPromiseResolveBlock)resolve
|
|
111
118
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
112
119
|
{
|
|
@@ -173,6 +180,10 @@ RCT_REMAP_METHOD(getCurrentSessionId,
|
|
|
173
180
|
[self.ddRumImplementation addTimingWithName:name resolve:resolve reject:reject];
|
|
174
181
|
}
|
|
175
182
|
|
|
183
|
+
- (void)addViewLoadingTime:(BOOL)overwrite resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {\
|
|
184
|
+
[self.ddRumImplementation addViewLoadingTimeWithOverwrite:overwrite resolve:resolve reject:reject];
|
|
185
|
+
}
|
|
186
|
+
|
|
176
187
|
- (void)startAction:(NSString *)type name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
177
188
|
[self.ddRumImplementation startActionWithType:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
|
|
178
189
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
|
+
@_spi(Experimental)
|
|
8
9
|
import DatadogRUM
|
|
9
10
|
import DatadogInternal
|
|
10
11
|
|
|
@@ -179,6 +180,12 @@ public class DdRumImplementation: NSObject {
|
|
|
179
180
|
nativeRUM.addTiming(name: name)
|
|
180
181
|
resolve(nil)
|
|
181
182
|
}
|
|
183
|
+
|
|
184
|
+
@objc
|
|
185
|
+
public func addViewLoadingTime(overwrite: Bool, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
186
|
+
nativeRUM.addViewLoadingTime(overwrite: overwrite)
|
|
187
|
+
resolve(nil)
|
|
188
|
+
}
|
|
182
189
|
|
|
183
190
|
@objc
|
|
184
191
|
public func stopSession(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
package/ios/Sources/DdSdk.h
CHANGED
|
@@ -5,21 +5,23 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
#import <Foundation/Foundation.h>
|
|
8
|
+
#import <React/RCTEventEmitter.h>
|
|
9
|
+
|
|
8
10
|
@class DdSdkImplementation;
|
|
9
11
|
|
|
10
12
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
11
13
|
|
|
12
14
|
#import <DdSdkReactNative/DdSdkReactNative.h>
|
|
13
|
-
@interface DdSdk:
|
|
15
|
+
@interface DdSdk : RCTEventEmitter <NativeDdSdkSpec>
|
|
14
16
|
|
|
15
17
|
#else
|
|
16
18
|
|
|
17
19
|
#import <React/RCTBridgeModule.h>
|
|
18
|
-
@interface DdSdk :
|
|
20
|
+
@interface DdSdk : RCTEventEmitter <RCTBridgeModule>
|
|
19
21
|
|
|
20
22
|
#endif
|
|
21
23
|
|
|
22
|
-
@property
|
|
24
|
+
@property(nonatomic, strong) DdSdkImplementation *ddSdkImplementation;
|
|
23
25
|
|
|
24
26
|
+ (void)initFromNative;
|
|
25
27
|
|
package/ios/Sources/DdSdk.mm
CHANGED
|
@@ -38,6 +38,20 @@ RCT_REMAP_METHOD(setUser, withUser:(NSDictionary*)user
|
|
|
38
38
|
[self setUser:user resolve:resolve reject:reject];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
RCT_REMAP_METHOD(setUserInfo, withUserInfo:(NSDictionary*)userInfo
|
|
42
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
43
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
44
|
+
{
|
|
45
|
+
[self setUserInfo:userInfo resolve:resolve reject:reject];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
RCT_REMAP_METHOD(addUserExtraInfo, withExtraInfo:(NSDictionary*)extraInfo
|
|
49
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
50
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
51
|
+
{
|
|
52
|
+
[self addUserExtraInfo:extraInfo resolve:resolve reject:reject];
|
|
53
|
+
}
|
|
54
|
+
|
|
41
55
|
RCT_REMAP_METHOD(setTrackingConsent, withTrackingConsent:(NSString*)trackingConsent
|
|
42
56
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
43
57
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
@@ -84,6 +98,10 @@ RCT_REMAP_METHOD(clearAllData, withResolver:(RCTPromiseResolveBlock)resolve
|
|
|
84
98
|
#endif
|
|
85
99
|
|
|
86
100
|
|
|
101
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
102
|
+
return @[@"RumSessionStarted"];
|
|
103
|
+
}
|
|
104
|
+
|
|
87
105
|
- (DdSdkImplementation*)ddSdkImplementation
|
|
88
106
|
{
|
|
89
107
|
if (_ddSdkImplementation == nil) {
|
|
@@ -110,7 +128,7 @@ RCT_REMAP_METHOD(clearAllData, withResolver:(RCTPromiseResolveBlock)resolve
|
|
|
110
128
|
}
|
|
111
129
|
|
|
112
130
|
- (void)initialize:(NSDictionary *)configuration resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
113
|
-
[self.ddSdkImplementation initializeWithConfiguration:configuration resolve:resolve reject:reject];
|
|
131
|
+
[self.ddSdkImplementation initializeWithConfiguration:configuration eventEmitter:self resolve:resolve reject:reject];
|
|
114
132
|
}
|
|
115
133
|
|
|
116
134
|
- (void)setAttributes:(NSDictionary *)attributes resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
@@ -125,6 +143,14 @@ RCT_REMAP_METHOD(clearAllData, withResolver:(RCTPromiseResolveBlock)resolve
|
|
|
125
143
|
[self.ddSdkImplementation setUserWithUser:user resolve:resolve reject:reject];
|
|
126
144
|
}
|
|
127
145
|
|
|
146
|
+
- (void)setUserInfo:(NSDictionary *)userInfo resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
147
|
+
[self.ddSdkImplementation setUserInfoWithUserInfo:userInfo resolve:resolve reject:reject];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
-(void)addUserExtraInfo:(NSDictionary *)extraInfo resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
151
|
+
[self.ddSdkImplementation addUserExtraInfoWithExtraInfo:extraInfo resolve:resolve reject:reject];
|
|
152
|
+
}
|
|
153
|
+
|
|
128
154
|
- (void)telemetryDebug:(NSString *)message resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
129
155
|
[self.ddSdkImplementation telemetryDebugWithMessage:message resolve:resolve reject:reject];
|
|
130
156
|
}
|
|
@@ -41,6 +41,7 @@ import DatadogRUM
|
|
|
41
41
|
- appHangThreshold: The threshold for non-fatal app hangs reporting in seconds.
|
|
42
42
|
- trackWatchdogTerminations: Whether the SDK should track application termination by the watchdog
|
|
43
43
|
- batchProcessingLevel: Maximum number of batches processed sequentially without a delay
|
|
44
|
+
- initialResourceThreshold: The amount of time after a view starts where a Resource should be considered when calculating Time to Network-Settled (TNS)
|
|
44
45
|
*/
|
|
45
46
|
@objc(DdSdkConfiguration)
|
|
46
47
|
public class DdSdkConfiguration: NSObject {
|
|
@@ -74,6 +75,7 @@ public class DdSdkConfiguration: NSObject {
|
|
|
74
75
|
public var appHangThreshold: Double? = nil
|
|
75
76
|
public var trackWatchdogTerminations: Bool
|
|
76
77
|
public var batchProcessingLevel: Datadog.Configuration.BatchProcessingLevel
|
|
78
|
+
public var initialResourceThreshold: Double? = nil
|
|
77
79
|
|
|
78
80
|
public init(
|
|
79
81
|
clientToken: String,
|
|
@@ -105,7 +107,8 @@ public class DdSdkConfiguration: NSObject {
|
|
|
105
107
|
bundleLogsWithTraces: Bool,
|
|
106
108
|
appHangThreshold: Double?,
|
|
107
109
|
trackWatchdogTerminations: Bool,
|
|
108
|
-
batchProcessingLevel: Datadog.Configuration.BatchProcessingLevel
|
|
110
|
+
batchProcessingLevel: Datadog.Configuration.BatchProcessingLevel,
|
|
111
|
+
initialResourceThreshold: Double?
|
|
109
112
|
) {
|
|
110
113
|
self.clientToken = clientToken
|
|
111
114
|
self.env = env
|
|
@@ -137,6 +140,7 @@ public class DdSdkConfiguration: NSObject {
|
|
|
137
140
|
self.appHangThreshold = appHangThreshold
|
|
138
141
|
self.trackWatchdogTerminations = trackWatchdogTerminations
|
|
139
142
|
self.batchProcessingLevel = batchProcessingLevel
|
|
143
|
+
self.initialResourceThreshold = initialResourceThreshold
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
146
|
|
|
@@ -59,11 +59,11 @@ public class DdSdkImplementation: NSObject {
|
|
|
59
59
|
|
|
60
60
|
// Using @escaping RCTPromiseResolveBlock type will result in an issue when compiling the Swift header file.
|
|
61
61
|
@objc
|
|
62
|
-
public func initialize(configuration: NSDictionary, resolve:@escaping ((Any?) -> Void), reject:RCTPromiseRejectBlock) -> Void {
|
|
62
|
+
public func initialize(configuration: NSDictionary, eventEmitter: RCTEventEmitter?, resolve:@escaping ((Any?) -> Void), reject:RCTPromiseRejectBlock) -> Void {
|
|
63
63
|
let sdkConfiguration = configuration.asDdSdkConfiguration()
|
|
64
64
|
let nativeInitialization = DdSdkNativeInitialization()
|
|
65
65
|
|
|
66
|
-
nativeInitialization.initialize(sdkConfiguration: sdkConfiguration)
|
|
66
|
+
nativeInitialization.initialize(sdkConfiguration: sdkConfiguration, eventEmitter: eventEmitter)
|
|
67
67
|
self.startJSRefreshRateMonitoring(sdkConfiguration: sdkConfiguration)
|
|
68
68
|
self.overrideReactNativeTelemetry(rnConfiguration: sdkConfiguration)
|
|
69
69
|
|
|
@@ -93,6 +93,35 @@ public class DdSdkImplementation: NSObject {
|
|
|
93
93
|
resolve(nil)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
@objc
|
|
97
|
+
public func setUserInfo(userInfo: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
98
|
+
let castedUserInfo = castAttributesToSwift(userInfo)
|
|
99
|
+
let id = castedUserInfo["id"] as? String
|
|
100
|
+
let name = castedUserInfo["name"] as? String
|
|
101
|
+
let email = castedUserInfo["email"] as? String
|
|
102
|
+
var extraInfo: [AttributeKey: AttributeValue] = [:]
|
|
103
|
+
|
|
104
|
+
if let extraInfoEncodable = castedUserInfo["extraInfo"] as? AnyEncodable,
|
|
105
|
+
let extraInfoDict = extraInfoEncodable.value as? [String: Any] {
|
|
106
|
+
extraInfo = castAttributesToSwift(extraInfoDict)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if let validId = id {
|
|
110
|
+
Datadog.setUserInfo(id: validId, name: name, email: email, extraInfo: extraInfo)
|
|
111
|
+
} else {
|
|
112
|
+
Datadog.setUserInfo(name: name, email: email, extraInfo: extraInfo)
|
|
113
|
+
}
|
|
114
|
+
resolve(nil)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@objc
|
|
118
|
+
public func addUserExtraInfo(extraInfo: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
119
|
+
let castedExtraInfo = castAttributesToSwift(extraInfo)
|
|
120
|
+
|
|
121
|
+
Datadog.addUserExtraInfo(castedExtraInfo)
|
|
122
|
+
resolve(nil)
|
|
123
|
+
}
|
|
124
|
+
|
|
96
125
|
@objc
|
|
97
126
|
public func setTrackingConsent(trackingConsent: NSString, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
98
127
|
Datadog.set(trackingConsent: (trackingConsent as NSString?).asTrackingConsent())
|
|
@@ -29,7 +29,7 @@ public class DdSdkNativeInitialization: NSObject {
|
|
|
29
29
|
self.jsonFileReader = jsonFileReader
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
internal func initialize(sdkConfiguration: DdSdkConfiguration) {
|
|
32
|
+
internal func initialize(sdkConfiguration: DdSdkConfiguration, eventEmitter: RCTEventEmitter?) {
|
|
33
33
|
// TODO: see if this `if` is still needed
|
|
34
34
|
if DatadogSDKWrapper.shared.isInitialized() {
|
|
35
35
|
// Initializing the SDK twice results in Global.rum and
|
|
@@ -47,7 +47,7 @@ public class DdSdkNativeInitialization: NSObject {
|
|
|
47
47
|
trackingConsent: sdkConfiguration.trackingConsent
|
|
48
48
|
)
|
|
49
49
|
|
|
50
|
-
self.enableFeatures(sdkConfiguration: sdkConfiguration)
|
|
50
|
+
self.enableFeatures(sdkConfiguration: sdkConfiguration, eventEmitter: eventEmitter)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
internal func getConfigurationFromJSONFile() -> DdSdkConfiguration? {
|
|
@@ -66,12 +66,12 @@ public class DdSdkNativeInitialization: NSObject {
|
|
|
66
66
|
@objc
|
|
67
67
|
public func initializeFromNative() -> Void {
|
|
68
68
|
if let configuration = getConfigurationFromJSONFile() {
|
|
69
|
-
self.initialize(sdkConfiguration: configuration)
|
|
69
|
+
self.initialize(sdkConfiguration: configuration, eventEmitter: nil)
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
func enableFeatures(sdkConfiguration: DdSdkConfiguration) {
|
|
74
|
-
let rumConfig = buildRUMConfiguration(configuration: sdkConfiguration)
|
|
73
|
+
func enableFeatures(sdkConfiguration: DdSdkConfiguration, eventEmitter: RCTEventEmitter?) {
|
|
74
|
+
let rumConfig = buildRUMConfiguration(configuration: sdkConfiguration, eventEmitter: eventEmitter)
|
|
75
75
|
DatadogSDKWrapper.shared.enableRUM(with: rumConfig)
|
|
76
76
|
|
|
77
77
|
let logsConfig = buildLogsConfiguration(configuration: sdkConfiguration)
|
|
@@ -113,7 +113,7 @@ public class DdSdkNativeInitialization: NSObject {
|
|
|
113
113
|
return config
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
func buildRUMConfiguration(configuration: DdSdkConfiguration) -> RUM.Configuration {
|
|
116
|
+
func buildRUMConfiguration(configuration: DdSdkConfiguration, eventEmitter: RCTEventEmitter?) -> RUM.Configuration {
|
|
117
117
|
var longTaskThreshold: TimeInterval? = nil
|
|
118
118
|
if let threshold = configuration.nativeLongTaskThresholdMs {
|
|
119
119
|
if (threshold != 0) {
|
|
@@ -150,6 +150,15 @@ public class DdSdkNativeInitialization: NSObject {
|
|
|
150
150
|
customRUMEndpointURL = URL(string: "\(customRUMEndpoint)/api/v2/rum" as String)
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
let onSessionStart: RUM.SessionListener = { sessionId, isDiscarded in
|
|
154
|
+
let body: [String: Any?] = ["sessionId": sessionId, "isDiscarded": isDiscarded]
|
|
155
|
+
eventEmitter?.sendEvent(withName: "RumSessionStarted", body: body)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
var networkSettledResourcePredicate: TimeBasedTNSResourcePredicate? = nil
|
|
159
|
+
if let initialResourceThreshold = configuration.initialResourceThreshold as TimeInterval? {
|
|
160
|
+
networkSettledResourcePredicate = TimeBasedTNSResourcePredicate(threshold: initialResourceThreshold)
|
|
161
|
+
}
|
|
153
162
|
|
|
154
163
|
return RUM.Configuration(
|
|
155
164
|
applicationID: configuration.applicationId,
|
|
@@ -163,6 +172,7 @@ public class DdSdkNativeInitialization: NSObject {
|
|
|
163
172
|
appHangThreshold: configuration.appHangThreshold,
|
|
164
173
|
trackWatchdogTerminations: configuration.trackWatchdogTerminations,
|
|
165
174
|
vitalsUpdateFrequency: configuration.vitalsUpdateFrequency,
|
|
175
|
+
networkSettledResourcePredicate: networkSettledResourcePredicate ?? TimeBasedTNSResourcePredicate(),
|
|
166
176
|
resourceEventMapper: { resourceEvent in
|
|
167
177
|
if resourceEvent.context?.contextInfo[InternalConfigurationAttributes.dropResource] != nil {
|
|
168
178
|
return nil
|
|
@@ -175,6 +185,7 @@ public class DdSdkNativeInitialization: NSObject {
|
|
|
175
185
|
}
|
|
176
186
|
return actionEvent
|
|
177
187
|
},
|
|
188
|
+
onSessionStart: onSessionStart,
|
|
178
189
|
customEndpoint: customRUMEndpointURL,
|
|
179
190
|
telemetrySampleRate: (configuration.telemetrySampleRate as? NSNumber)?.floatValue ?? Float(DefaultConfiguration.telemetrySampleRate)
|
|
180
191
|
)
|
|
@@ -42,6 +42,7 @@ extension NSDictionary {
|
|
|
42
42
|
let appHangThreshold = object(forKey: "appHangThreshold") as? Double
|
|
43
43
|
let trackWatchdogTerminations = object(forKey: "trackWatchdogTerminations") as? Bool
|
|
44
44
|
let batchProcessingLevel = object(forKey: "batchProcessingLevel") as? NSString
|
|
45
|
+
let initialResourceThreshold = object(forKey: "initialResourceThreshold") as? Double
|
|
45
46
|
|
|
46
47
|
return DdSdkConfiguration(
|
|
47
48
|
clientToken: (clientToken != nil) ? clientToken! : String(),
|
|
@@ -73,7 +74,8 @@ extension NSDictionary {
|
|
|
73
74
|
bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces,
|
|
74
75
|
appHangThreshold: appHangThreshold,
|
|
75
76
|
trackWatchdogTerminations: trackWatchdogTerminations ?? DefaultConfiguration.trackWatchdogTerminations,
|
|
76
|
-
batchProcessingLevel: batchProcessingLevel.asBatchProcessingLevel()
|
|
77
|
+
batchProcessingLevel: batchProcessingLevel.asBatchProcessingLevel(),
|
|
78
|
+
initialResourceThreshold: initialResourceThreshold
|
|
77
79
|
)
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -241,7 +243,8 @@ extension Dictionary where Key == String, Value == AnyObject {
|
|
|
241
243
|
let appHangThreshold = configuration["appHangThreshold"] as? Double
|
|
242
244
|
let trackWatchdogTerminations = configuration["trackWatchdogTerminations"] as? Bool
|
|
243
245
|
let batchProcessingLevel = configuration["batchProcessingLevel"] as? NSString
|
|
244
|
-
|
|
246
|
+
let initialResourceThreshold = configuration["initialResourceThreshold"] as? Double
|
|
247
|
+
|
|
245
248
|
return DdSdkConfiguration(
|
|
246
249
|
clientToken: clientToken ?? String(),
|
|
247
250
|
env: env ?? String(),
|
|
@@ -275,7 +278,8 @@ extension Dictionary where Key == String, Value == AnyObject {
|
|
|
275
278
|
bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces,
|
|
276
279
|
appHangThreshold: appHangThreshold,
|
|
277
280
|
trackWatchdogTerminations: trackWatchdogTerminations ?? DefaultConfiguration.trackWatchdogTerminations,
|
|
278
|
-
batchProcessingLevel: batchProcessingLevel.asBatchProcessingLevel()
|
|
281
|
+
batchProcessingLevel: batchProcessingLevel.asBatchProcessingLevel(),
|
|
282
|
+
initialResourceThreshold: initialResourceThreshold
|
|
279
283
|
)
|
|
280
284
|
}
|
|
281
285
|
}
|