@datadog/mobile-react-native 1.4.0 → 1.5.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.
Files changed (184) hide show
  1. package/DatadogSDKReactNative.podspec +2 -2
  2. package/android/build.gradle +5 -5
  3. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +4 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +6 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +124 -95
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +2 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -0
  8. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +148 -25
  9. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +5 -0
  10. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +2 -1
  11. package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +10 -0
  12. package/datadog-sourcemaps.gradle +6 -1
  13. package/ios/Sources/DdSdk.m +4 -0
  14. package/ios/Sources/DdSdk.swift +17 -0
  15. package/ios/Sources/DdSdkConfiguration.swift +6 -0
  16. package/ios/Sources/RNDdSdkConfiguration.swift +2 -0
  17. package/jest/mock.js +1 -1
  18. package/lib/commonjs/DdSdkReactNative.js +7 -7
  19. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  20. package/lib/commonjs/DdSdkReactNativeConfiguration.js +8 -1
  21. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  22. package/lib/commonjs/index.js +8 -8
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  25. package/lib/commonjs/rum/DdRum.js +3 -3
  26. package/lib/commonjs/rum/DdRum.js.map +1 -1
  27. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -2
  28. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  29. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +4 -4
  30. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  31. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -0
  32. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -0
  33. package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.js +1 -1
  34. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -0
  35. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
  36. package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js +2 -2
  37. package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js.map +1 -1
  38. package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.js +4 -4
  39. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -0
  40. package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.js +2 -2
  41. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -0
  42. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
  43. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  44. package/lib/commonjs/sdk/DdSdk.js +17 -0
  45. package/lib/commonjs/sdk/DdSdk.js.map +1 -0
  46. package/lib/commonjs/sdk/EventMappers/EventMapper.js +2 -2
  47. package/lib/commonjs/sdk/EventMappers/EventMapper.js.map +1 -1
  48. package/lib/commonjs/{foundation.js → trace/DdTrace.js} +9 -19
  49. package/lib/commonjs/trace/DdTrace.js.map +1 -0
  50. package/lib/commonjs/types.js +2 -1
  51. package/lib/commonjs/types.js.map +1 -1
  52. package/lib/commonjs/version.js +1 -1
  53. package/lib/commonjs/version.js.map +1 -1
  54. package/lib/module/DdSdkReactNative.js +2 -2
  55. package/lib/module/DdSdkReactNative.js.map +1 -1
  56. package/lib/module/DdSdkReactNativeConfiguration.js +8 -1
  57. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  58. package/lib/module/index.js +1 -1
  59. package/lib/module/index.js.map +1 -1
  60. package/lib/module/nativeModulesTypes.js.map +1 -1
  61. package/lib/module/rum/DdRum.js +1 -1
  62. package/lib/module/rum/DdRum.js.map +1 -1
  63. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +1 -1
  64. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  65. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -5
  66. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  67. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -0
  68. package/lib/module/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.js.map +1 -1
  69. package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.js +1 -1
  70. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -0
  71. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
  72. package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js +2 -2
  73. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js.map +1 -0
  74. package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.js +4 -4
  75. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -0
  76. package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.js +2 -2
  77. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -0
  78. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +1 -1
  79. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  80. package/lib/module/sdk/DdSdk.js +9 -0
  81. package/lib/module/sdk/DdSdk.js.map +1 -0
  82. package/lib/module/sdk/EventMappers/EventMapper.js +1 -1
  83. package/lib/module/sdk/EventMappers/EventMapper.js.map +1 -1
  84. package/lib/module/{foundation.js → trace/DdTrace.js} +9 -11
  85. package/lib/module/trace/DdTrace.js.map +1 -0
  86. package/lib/module/types.js +2 -1
  87. package/lib/module/types.js.map +1 -1
  88. package/lib/module/version.js +1 -1
  89. package/lib/module/version.js.map +1 -1
  90. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +5 -0
  91. package/lib/typescript/index.d.ts +1 -1
  92. package/lib/typescript/nativeModulesTypes.d.ts +5 -0
  93. package/lib/typescript/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracing.d.ts +1 -1
  94. package/lib/typescript/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.d.ts +1 -1
  95. package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.d.ts +1 -1
  96. package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.d.ts +1 -1
  97. package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.d.ts +1 -1
  98. package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.d.ts +2 -2
  99. package/lib/typescript/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.d.ts +1 -1
  100. package/lib/typescript/sdk/DdSdk.d.ts +3 -0
  101. package/lib/typescript/trace/DdTrace.d.ts +3 -0
  102. package/lib/typescript/types.d.ts +2 -1
  103. package/lib/typescript/version.d.ts +1 -1
  104. package/package.json +76 -76
  105. package/src/DdSdkReactNative.tsx +2 -1
  106. package/src/DdSdkReactNativeConfiguration.tsx +8 -1
  107. package/src/__tests__/DdSdkReactNative.test.tsx +1 -1
  108. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -2
  109. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +1 -1
  110. package/src/index.tsx +1 -1
  111. package/src/nativeModulesTypes.ts +6 -0
  112. package/src/rum/DdRum.ts +1 -1
  113. package/src/rum/__tests__/DdRum.test.ts +1 -1
  114. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +1 -1
  115. package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +5 -5
  116. package/src/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracing.tsx +1 -1
  117. package/src/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.ts +1 -2
  118. package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.ts +2 -2
  119. package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -2
  120. package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/__utils__/ResourceMockFactory.ts +1 -1
  121. package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.ts +1 -1
  122. package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.ts +3 -3
  123. package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.ts +6 -6
  124. package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/__tests__/XHRProxy.test.ts +9 -9
  125. package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.ts +2 -2
  126. package/src/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.ts +1 -1
  127. package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +1 -1
  128. package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +1 -1
  129. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +2 -1
  130. package/src/sdk/DdSdk.ts +13 -0
  131. package/src/sdk/EventMappers/EventMapper.ts +1 -1
  132. package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +1 -1
  133. package/src/trace/DdTrace.ts +54 -0
  134. package/src/types.tsx +1 -0
  135. package/src/version.ts +1 -1
  136. package/lib/commonjs/foundation.js.map +0 -1
  137. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +0 -1
  138. package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +0 -1
  139. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +0 -1
  140. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
  141. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +0 -1
  142. package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +0 -1
  143. package/lib/module/foundation.js.map +0 -1
  144. package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +0 -1
  145. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +0 -1
  146. package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
  147. package/lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +0 -1
  148. package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +0 -1
  149. package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +0 -1
  150. package/lib/typescript/foundation.d.ts +0 -5
  151. package/src/foundation.tsx +0 -36
  152. /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracing.js +0 -0
  153. /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracingHeaders.js +0 -0
  154. /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracingHeaders.js.map +0 -0
  155. /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.js +0 -0
  156. /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.js +0 -0
  157. /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js +0 -0
  158. /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js.map +0 -0
  159. /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.js +0 -0
  160. /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.js.map +0 -0
  161. /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js +0 -0
  162. /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js.map +0 -0
  163. /package/lib/module/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracing.js +0 -0
  164. /package/lib/module/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracingHeaders.js +0 -0
  165. /package/lib/module/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracingHeaders.js.map +0 -0
  166. /package/lib/module/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.js +0 -0
  167. /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.js +0 -0
  168. /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js +0 -0
  169. /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js.map +0 -0
  170. /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.js +0 -0
  171. /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.js.map +0 -0
  172. /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js +0 -0
  173. /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js.map +0 -0
  174. /package/lib/typescript/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracingHeaders.d.ts +0 -0
  175. /package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.d.ts +0 -0
  176. /package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.d.ts +0 -0
  177. /package/lib/typescript/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.d.ts +0 -0
  178. /package/src/rum/instrumentation/resourceTracking/{domain → distributedTracing}/__tests__/distributedTracing.test.ts +0 -0
  179. /package/src/rum/instrumentation/resourceTracking/{domain → distributedTracing}/__tests__/firstPartyHosts.test.ts +0 -0
  180. /package/src/rum/instrumentation/resourceTracking/{domain → distributedTracing}/distributedTracingHeaders.ts +0 -0
  181. /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +0 -0
  182. /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.ts +0 -0
  183. /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/__tests__/URLHostParser.test.ts +0 -0
  184. /package/src/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.ts +0 -0
@@ -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.15.0'
21
- s.dependency 'DatadogSDKCrashReporting', '~> 1.15.0'
20
+ s.dependency 'DatadogSDK', '~> 1.16.0'
21
+ s.dependency 'DatadogSDKCrashReporting', '~> 1.16.0'
22
22
 
23
23
  s.test_spec 'Tests' do |test_spec|
24
24
  test_spec.source_files = 'ios/Tests/*.swift'
@@ -73,15 +73,15 @@ def getExtOrIntegerDefault(name) {
73
73
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['DdSdkReactNative_' + name]).toInteger()
74
74
  }
75
75
 
76
- android {
76
+ android {
77
77
  compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
78
78
  buildToolsVersion getExtOrDefault('buildToolsVersion')
79
79
  defaultConfig {
80
- minSdkVersion 19
80
+ minSdkVersion 21
81
81
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
82
82
  versionCode 1
83
83
  versionName "1.0"
84
-
84
+
85
85
  }
86
86
 
87
87
  sourceSets.named("main") {
@@ -97,7 +97,7 @@ android {
97
97
  returnDefaultValues = true
98
98
  }
99
99
  }
100
-
100
+
101
101
  buildTypes {
102
102
  release {
103
103
  minifyEnabled false
@@ -146,7 +146,7 @@ dependencies {
146
146
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
147
147
  compileOnly "com.squareup.okhttp3:okhttp:3.12.13"
148
148
 
149
- implementation "com.datadoghq:dd-sdk-android:1.17.0"
149
+ implementation "com.datadoghq:dd-sdk-android:1.18.1"
150
150
  testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
151
151
  testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
152
152
  testImplementation "org.junit.jupiter:junit-jupiter-engine:5.6.2"
@@ -63,4 +63,8 @@ internal class DatadogSDKWrapper : DatadogWrapper {
63
63
  override fun telemetryError(message: String, throwable: Throwable?) {
64
64
  Datadog._internal._telemetry.error(message, throwable)
65
65
  }
66
+
67
+ override fun consumeWebviewEvent(message: String) {
68
+ Datadog._internal.consumeWebviewEvent(message)
69
+ }
66
70
  }
@@ -16,6 +16,7 @@ import java.lang.IllegalArgumentException
16
16
  /**
17
17
  * Wrapper around [Datadog].
18
18
  */
19
+ @Suppress("ComplexInterface")
19
20
  interface DatadogWrapper {
20
21
 
21
22
  /**
@@ -98,4 +99,9 @@ interface DatadogWrapper {
98
99
  * Sends telemetry error.
99
100
  */
100
101
  fun telemetryError(message: String, throwable: Throwable?)
102
+
103
+ /**
104
+ * Sends Webview events.
105
+ */
106
+ fun consumeWebviewEvent(message: String)
101
107
  }
@@ -37,9 +37,7 @@ import java.util.Locale
37
37
  import java.util.concurrent.TimeUnit
38
38
  import java.util.concurrent.atomic.AtomicBoolean
39
39
 
40
- /**
41
- * The entry point to initialize Datadog's features.
42
- */
40
+ /** The entry point to initialize Datadog's features. */
43
41
  class DdSdk(
44
42
  reactContext: ReactApplicationContext,
45
43
  private val datadog: DatadogWrapper = DatadogSDKWrapper()
@@ -76,21 +74,21 @@ class DdSdk(
76
74
  }
77
75
 
78
76
  /**
79
- * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
77
+ * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM
78
+ * events.
80
79
  * @param attributes The global context attributes.
81
80
  */
82
81
  @ReactMethod
83
82
  fun setAttributes(attributes: ReadableMap, promise: Promise) {
84
83
  datadog.addRumGlobalAttributes(attributes.toHashMap())
85
- attributes.toHashMap().forEach { (k, v) ->
86
- GlobalState.addAttribute(k, v)
87
- }
84
+ attributes.toHashMap().forEach { (k, v) -> GlobalState.addAttribute(k, v) }
88
85
  promise.resolve(null)
89
86
  }
90
87
 
91
88
  /**
92
89
  * Set the user information.
93
- * @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
90
+ * @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
91
+ * attribute).
94
92
  */
95
93
  @ReactMethod
96
94
  fun setUser(user: ReadableMap, promise: Promise) {
@@ -104,7 +102,8 @@ class DdSdk(
104
102
 
105
103
  /**
106
104
  * Set the tracking consent regarding the data collection.
107
- * @param trackingConsent Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
105
+ * @param trackingConsent Consent, which can take one of the following values: 'pending',
106
+ * 'granted', 'not_granted'.
108
107
  */
109
108
  @ReactMethod
110
109
  fun setTrackingConsent(trackingConsent: String, promise: Promise) {
@@ -134,19 +133,30 @@ class DdSdk(
134
133
  promise.resolve(null)
135
134
  }
136
135
 
136
+ /**
137
+ * Sends WebView Events.
138
+ * @param message User action.
139
+ */
140
+ @ReactMethod
141
+ fun consumeWebviewEvent(message: String, promise: Promise) {
142
+ datadog.consumeWebviewEvent(message)
143
+ promise.resolve(null)
144
+ }
145
+
137
146
  // endregion
138
147
 
139
148
  // region Internal
140
149
 
141
150
  private fun configureSdkVerbosity(configuration: DdSdkConfiguration) {
142
151
  val verbosityConfig = configuration.additionalConfig?.get(DD_SDK_VERBOSITY) as? String
143
- val verbosity = when (verbosityConfig?.lowercase(Locale.US)) {
144
- "debug" -> Log.DEBUG
145
- "info" -> Log.INFO
146
- "warn" -> Log.WARN
147
- "error" -> Log.ERROR
148
- else -> null
149
- }
152
+ val verbosity =
153
+ when (verbosityConfig?.lowercase(Locale.US)) {
154
+ "debug" -> Log.DEBUG
155
+ "info" -> Log.INFO
156
+ "warn" -> Log.WARN
157
+ "error" -> Log.ERROR
158
+ else -> null
159
+ }
150
160
  if (verbosity != null) {
151
161
  datadog.setVerbosity(verbosity)
152
162
  }
@@ -154,19 +164,20 @@ class DdSdk(
154
164
 
155
165
  private fun getDefaultAppVersion(): String {
156
166
  val packageName = appContext.packageName
157
- val packageInfo = try {
158
- appContext.packageManager.getPackageInfo(packageName, 0)
159
- } catch (e: PackageManager.NameNotFoundException) {
160
- datadog.telemetryError(e.message ?: PACKAGE_INFO_NOT_FOUND_ERROR_MESSAGE, e)
161
- return DEFAULT_APP_VERSION
162
- }
167
+ val packageInfo =
168
+ try {
169
+ appContext.packageManager.getPackageInfo(packageName, 0)
170
+ } catch (e: PackageManager.NameNotFoundException) {
171
+ datadog.telemetryError(e.message ?: PACKAGE_INFO_NOT_FOUND_ERROR_MESSAGE, e)
172
+ return DEFAULT_APP_VERSION
173
+ }
163
174
 
164
175
  return packageInfo?.let {
165
176
  // we need to use the deprecated method because getLongVersionCode method is only
166
177
  // available from API 28 and above
167
- @Suppress("DEPRECATION")
168
- it.versionName ?: it.versionCode.toString()
169
- } ?: DEFAULT_APP_VERSION
178
+ @Suppress("DEPRECATION") it.versionName ?: it.versionCode.toString()
179
+ }
180
+ ?: DEFAULT_APP_VERSION
170
181
  }
171
182
 
172
183
  @Suppress("ComplexMethod", "LongMethod", "UnsafeCallOnNullableType")
@@ -179,21 +190,26 @@ class DdSdk(
179
190
  additionalConfig.put(DD_VERSION, defaultVersion + versionSuffix)
180
191
  }
181
192
 
182
- val configBuilder = Configuration.Builder(
183
- logsEnabled = true,
184
- tracesEnabled = true,
185
- crashReportsEnabled = configuration.nativeCrashReportEnabled ?: false,
186
- rumEnabled = true
187
- )
188
- .setAdditionalConfiguration(
189
- additionalConfig
190
- ?.filterValues { it != null }
191
- ?.mapValues { it.value!! } ?: emptyMap()
193
+ val configBuilder =
194
+ Configuration.Builder(
195
+ logsEnabled = true,
196
+ tracesEnabled = true,
197
+ crashReportsEnabled = configuration.nativeCrashReportEnabled
198
+ ?: false,
199
+ rumEnabled = true
192
200
  )
201
+ .setAdditionalConfiguration(
202
+ additionalConfig?.filterValues { it != null }?.mapValues {
203
+ it.value!!
204
+ }
205
+ ?: emptyMap()
206
+ )
193
207
  if (configuration.sampleRate != null) {
194
208
  configBuilder.sampleRumSessions(configuration.sampleRate.toFloat())
195
209
  }
196
210
 
211
+ configBuilder.trackFrustrations(configuration.trackFrustrations ?: true)
212
+
197
213
  configBuilder.useSite(buildSite(configuration.site))
198
214
  configBuilder.setVitalsUpdateFrequency(
199
215
  buildVitalUpdateFrequency(configuration.vitalsUpdateFrequency)
@@ -215,9 +231,8 @@ class DdSdk(
215
231
  configBuilder.useViewTrackingStrategy(NoOpViewTrackingStrategy)
216
232
  }
217
233
 
218
- val interactionTracking = configuration.additionalConfig?.get(
219
- DD_NATIVE_INTERACTION_TRACKING
220
- ) as? Boolean
234
+ val interactionTracking =
235
+ configuration.additionalConfig?.get(DD_NATIVE_INTERACTION_TRACKING) as? Boolean
221
236
  if (interactionTracking == false) {
222
237
  configBuilder.disableInteractionTracking()
223
238
  }
@@ -225,7 +240,8 @@ class DdSdk(
225
240
  @Suppress("UNCHECKED_CAST")
226
241
  val firstPartyHosts =
227
242
  (configuration.additionalConfig?.get(DD_FIRST_PARTY_HOSTS) as? ReadableArray)
228
- ?.toArrayList() as? List<ReadableMap>
243
+ ?.toArrayList() as?
244
+ List<ReadableMap>
229
245
  if (firstPartyHosts != null) {
230
246
  val firstPartyHostsWithHeaderTypes = buildFirstPartyHosts(firstPartyHosts)
231
247
 
@@ -236,28 +252,37 @@ class DdSdk(
236
252
  configBuilder.setProxy(proxy, authenticator)
237
253
  }
238
254
 
239
- configBuilder.setRumResourceEventMapper(object : EventMapper<ResourceEvent> {
240
- override fun map(event: ResourceEvent): ResourceEvent? {
241
- if (event.context?.additionalProperties?.containsKey(DD_DROP_RESOURCE) == true) {
242
- return null
255
+ configBuilder.setRumResourceEventMapper(
256
+ object : EventMapper<ResourceEvent> {
257
+ override fun map(event: ResourceEvent): ResourceEvent? {
258
+ if (event.context?.additionalProperties?.containsKey(DD_DROP_RESOURCE) ==
259
+ true
260
+ ) {
261
+ return null
262
+ }
263
+ return event
243
264
  }
244
- return event
245
265
  }
246
- })
266
+ )
247
267
 
248
- configBuilder.setRumActionEventMapper(object : EventMapper<ActionEvent> {
249
- override fun map(event: ActionEvent): ActionEvent? {
250
- if (event.context?.additionalProperties?.containsKey(DD_DROP_ACTION) == true) {
251
- return null
268
+ configBuilder.setRumActionEventMapper(
269
+ object : EventMapper<ActionEvent> {
270
+ override fun map(event: ActionEvent): ActionEvent? {
271
+ if (event.context?.additionalProperties?.containsKey(DD_DROP_ACTION) == true
272
+ ) {
273
+ return null
274
+ }
275
+ return event
252
276
  }
253
- return event
254
277
  }
255
- })
278
+ )
256
279
 
257
280
  _InternalProxy.setTelemetryConfigurationEventMapper(
258
281
  configBuilder,
259
282
  object : EventMapper<TelemetryConfigurationEvent> {
260
- override fun map(event: TelemetryConfigurationEvent): TelemetryConfigurationEvent? {
283
+ override fun map(
284
+ event: TelemetryConfigurationEvent
285
+ ): TelemetryConfigurationEvent? {
261
286
  event.telemetry.configuration.trackNativeErrors =
262
287
  configuration.nativeCrashReportEnabled
263
288
  // trackCrossPlatformLongTasks will be deprecated for trackLongTask
@@ -291,11 +316,11 @@ class DdSdk(
291
316
  firstPartyHosts: List<ReadableMap>
292
317
  ): Map<String, Set<TracingHeaderType>> {
293
318
  /**
294
- * Adapts the data format from the React Native SDK configuration to match with the
295
- * Android SDK configuration. For example:
319
+ * Adapts the data format from the React Native SDK configuration to match with the Android
320
+ * SDK configuration. For example:
296
321
  *
297
- * RN config: [{ match: "example.com", propagatorTypes: [DATADOG, B3] }]
298
- * Android config: { "example.com": [DATADOG, B3] }
322
+ * RN config: [{ match: "example.com", propagatorTypes: [DATADOG, B3] }] Android config: {
323
+ * "example.com": [DATADOG, B3] }
299
324
  */
300
325
  val firstPartyHostsWithHeaderTypes = mutableMapOf<String, MutableSet<TracingHeaderType>>()
301
326
 
@@ -342,40 +367,44 @@ class DdSdk(
342
367
  }
343
368
  }
344
369
 
345
- internal fun buildProxyConfiguration(configuration: DdSdkConfiguration):
346
- Pair<Proxy, ProxyAuthenticator?>? {
370
+ internal fun buildProxyConfiguration(
371
+ configuration: DdSdkConfiguration
372
+ ): Pair<Proxy, ProxyAuthenticator?>? {
347
373
  val additionalConfig = configuration.additionalConfig ?: return null
348
374
 
349
375
  val address = additionalConfig[DD_PROXY_ADDRESS] as? String
350
376
  val port = (additionalConfig[DD_PROXY_PORT] as? Number)?.toInt()
351
- val type = (additionalConfig[DD_PROXY_TYPE] as? String)?.let {
352
- when (it.lowercase(Locale.US)) {
353
- "http", "https" -> Proxy.Type.HTTP
354
- "socks" -> Proxy.Type.SOCKS
355
- else -> {
356
- Log.w(
357
- DdSdk::class.java.canonicalName,
358
- "Unknown proxy type given: $it, skipping proxy configuration."
359
- )
360
- null
377
+ val type =
378
+ (additionalConfig[DD_PROXY_TYPE] as? String)?.let {
379
+ when (it.lowercase(Locale.US)) {
380
+ "http", "https" -> Proxy.Type.HTTP
381
+ "socks" -> Proxy.Type.SOCKS
382
+ else -> {
383
+ Log.w(
384
+ DdSdk::class.java.canonicalName,
385
+ "Unknown proxy type given: $it, skipping proxy configuration."
386
+ )
387
+ null
388
+ }
361
389
  }
362
390
  }
363
- }
364
391
 
365
- val proxy = if (address != null && port != null && type != null) {
366
- Proxy(type, InetSocketAddress(address, port))
367
- } else {
368
- return null
369
- }
392
+ val proxy =
393
+ if (address != null && port != null && type != null) {
394
+ Proxy(type, InetSocketAddress(address, port))
395
+ } else {
396
+ return null
397
+ }
370
398
 
371
399
  val username = additionalConfig[DD_PROXY_USERNAME] as? String
372
400
  val password = additionalConfig[DD_PROXY_PASSWORD] as? String
373
401
 
374
- val authenticator = if (username != null && password != null) {
375
- ProxyAuthenticator(username, password)
376
- } else {
377
- null
378
- }
402
+ val authenticator =
403
+ if (username != null && password != null) {
404
+ ProxyAuthenticator(username, password)
405
+ } else {
406
+ null
407
+ }
379
408
 
380
409
  return Pair(proxy, authenticator)
381
410
  }
@@ -388,6 +417,7 @@ class DdSdk(
388
417
  "us3" -> DatadogSite.US3
389
418
  "us5" -> DatadogSite.US5
390
419
  "us1_fed", "gov" -> DatadogSite.US1_FED
420
+ "ap1" -> DatadogSite.AP1
391
421
  else -> DatadogSite.US1
392
422
  }
393
423
  }
@@ -412,10 +442,7 @@ class DdSdk(
412
442
  if (frameTimeCallback != null) {
413
443
  reactContext.runOnJSQueueThread {
414
444
  val vitalFrameCallback =
415
- VitalFrameCallback(
416
- frameTimeCallback,
417
- ::handlePostFrameCallbackError
418
- ) {
445
+ VitalFrameCallback(frameTimeCallback, ::handlePostFrameCallbackError) {
419
446
  initialized.get()
420
447
  }
421
448
  try {
@@ -428,11 +455,12 @@ class DdSdk(
428
455
  }
429
456
  }
430
457
 
431
- private fun buildFrameTimeCallback(ddSdkConfiguration: DdSdkConfiguration):
432
- ((Double) -> Unit)? {
433
- val jsRefreshRateMonitoringEnabled = buildVitalUpdateFrequency(
434
- ddSdkConfiguration.vitalsUpdateFrequency
435
- ) != VitalsUpdateFrequency.NEVER
458
+ private fun buildFrameTimeCallback(
459
+ ddSdkConfiguration: DdSdkConfiguration
460
+ ): ((Double) -> Unit)? {
461
+ val jsRefreshRateMonitoringEnabled =
462
+ buildVitalUpdateFrequency(ddSdkConfiguration.vitalsUpdateFrequency) !=
463
+ VitalsUpdateFrequency.NEVER
436
464
  val jsLongTasksMonitoringEnabled = ddSdkConfiguration.longTaskThresholdMs != 0.0
437
465
 
438
466
  if (!jsLongTasksMonitoringEnabled && !jsRefreshRateMonitoringEnabled) {
@@ -441,14 +469,15 @@ class DdSdk(
441
469
 
442
470
  return {
443
471
  if (jsRefreshRateMonitoringEnabled && it > 0.0) {
444
- GlobalRum.get()._getInternal()?.updatePerformanceMetric(
445
- RumPerformanceMetric.JS_FRAME_TIME,
446
- it
447
- )
472
+ GlobalRum.get()
473
+ ._getInternal()
474
+ ?.updatePerformanceMetric(RumPerformanceMetric.JS_FRAME_TIME, it)
448
475
  }
449
- if (jsLongTasksMonitoringEnabled && it > TimeUnit.MILLISECONDS.toNanos(
450
- ddSdkConfiguration.longTaskThresholdMs?.toLong() ?: 0L
451
- )
476
+ if (jsLongTasksMonitoringEnabled &&
477
+ it >
478
+ TimeUnit.MILLISECONDS.toNanos(
479
+ ddSdkConfiguration.longTaskThresholdMs?.toLong() ?: 0L
480
+ )
452
481
  ) {
453
482
  GlobalRum.get()._getInternal()?.addLongTask(it.toLong(), "javascript")
454
483
  }
@@ -19,6 +19,7 @@ package com.datadog.reactnative
19
19
  * @param trackingConsent Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
20
20
  * @param telemetrySampleRate The sample rate (between 0 and 100) of telemetry events.
21
21
  * @param vitalsUpdateFrequency The frequency to which vitals update are sent (can be 'NEVER', 'RARE', 'AVERAGE' (default), 'FREQUENT').
22
+ * @param trackFrustrations Whether to track frustration signals or not.
22
23
  * @param additionalConfig Additional configuration parameters.
23
24
  * @param configurationForTelemetry Additional configuration data for Datadog telemetry.
24
25
  */
@@ -34,6 +35,7 @@ data class DdSdkConfiguration(
34
35
  val trackingConsent: String? = null,
35
36
  val telemetrySampleRate: Double? = null,
36
37
  val vitalsUpdateFrequency: String? = null,
38
+ val trackFrustrations: Boolean? = null,
37
39
  val additionalConfig: Map<String, Any?>? = null,
38
40
  val configurationForTelemetry: ConfigurationForTelemetry? = null
39
41
  )
@@ -24,6 +24,7 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
24
24
  trackingConsent = getString("trackingConsent"),
25
25
  telemetrySampleRate = getDouble("telemetrySampleRate"),
26
26
  vitalsUpdateFrequency = getString("vitalsUpdateFrequency"),
27
+ trackFrustrations = getBoolean("trackFrustrations"),
27
28
  additionalConfig = getMap("additionalConfig")?.toHashMap(),
28
29
  configurationForTelemetry = getMap(
29
30
  "configurationForTelemetry"
@@ -66,6 +67,7 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
66
67
  trackingConsent?.let { map.putString("trackingConsent", it) }
67
68
  telemetrySampleRate?.let { map.putDouble("telemetrySampleRate", it) }
68
69
  vitalsUpdateFrequency?.let { map.putString("vitalsUpdateFrequency", it) }
70
+ trackFrustrations?.let { map.putBoolean("trackFrustrations", it) }
69
71
  additionalConfig?.let { map.putMap("additionalConfig", it.toWritableMap()) }
70
72
  return map
71
73
  }