@datadog/mobile-react-native 2.4.0 → 2.4.2

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 (447) hide show
  1. package/DatadogSDKReactNative.podspec +7 -7
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +6 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +31 -24
  5. package/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt +63 -0
  6. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  7. package/android/src/main/kotlin/com/datadog/reactnative/UiThreadExecutor.kt +25 -0
  8. package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +10 -1
  9. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +10 -1
  10. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +29 -0
  11. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +34 -14
  12. package/android/src/test/kotlin/com/datadog/tools/unit/TestUiThreadExecutor.kt +16 -0
  13. package/datadog-sourcemaps.gradle +3 -5
  14. package/ios/Sources/DdRum.mm +4 -3
  15. package/ios/Sources/DdRumImplementation.swift +15 -2
  16. package/ios/Sources/SdkVersion.swift +1 -1
  17. package/lib/commonjs/DdSdkReactNative.js +105 -150
  18. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  19. package/lib/commonjs/DdSdkReactNativeConfiguration.js +54 -119
  20. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  21. package/lib/commonjs/InternalLog.js +8 -19
  22. package/lib/commonjs/InternalLog.js.map +1 -1
  23. package/lib/commonjs/ProxyConfiguration.js +3 -15
  24. package/lib/commonjs/ProxyConfiguration.js.map +1 -1
  25. package/lib/commonjs/SdkVerbosity.js +3 -7
  26. package/lib/commonjs/SdkVerbosity.js.map +1 -1
  27. package/lib/commonjs/TrackingConsent.js +3 -7
  28. package/lib/commonjs/TrackingConsent.js.map +1 -1
  29. package/lib/commonjs/index.js +51 -65
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/logs/DdLogs.js +103 -123
  32. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  33. package/lib/commonjs/logs/eventMapper.js +4 -11
  34. package/lib/commonjs/logs/eventMapper.js.map +1 -1
  35. package/lib/commonjs/logs/types.js +4 -0
  36. package/lib/commonjs/logs/types.js.map +1 -1
  37. package/lib/commonjs/nativeModulesTypes.js +4 -3
  38. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  39. package/lib/commonjs/polyfills.js +28 -0
  40. package/lib/commonjs/polyfills.js.map +1 -0
  41. package/lib/commonjs/rum/DdAttributes.js +26 -0
  42. package/lib/commonjs/rum/DdAttributes.js.map +1 -0
  43. package/lib/commonjs/rum/DdRum.js +145 -210
  44. package/lib/commonjs/rum/DdRum.js.map +1 -1
  45. package/lib/commonjs/rum/eventMappers/actionEventMapper.js +5 -8
  46. package/lib/commonjs/rum/eventMappers/actionEventMapper.js.map +1 -1
  47. package/lib/commonjs/rum/eventMappers/errorEventMapper.js +3 -7
  48. package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -1
  49. package/lib/commonjs/rum/eventMappers/resourceEventMapper.js +5 -8
  50. package/lib/commonjs/rum/eventMappers/resourceEventMapper.js.map +1 -1
  51. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +68 -89
  52. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  53. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +13 -46
  54. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  55. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +52 -66
  56. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  57. package/lib/commonjs/rum/instrumentation/interactionTracking/EventsInterceptor.js.map +1 -1
  58. package/lib/commonjs/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js +3 -4
  59. package/lib/commonjs/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js.map +1 -1
  60. package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +0 -6
  61. package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
  62. package/lib/commonjs/rum/instrumentation/interactionTracking/getJsxRuntime.js +18 -19
  63. package/lib/commonjs/rum/instrumentation/interactionTracking/getJsxRuntime.js.map +1 -1
  64. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +6 -21
  65. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  66. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +32 -55
  67. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
  68. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +1 -9
  69. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
  70. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +15 -41
  71. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
  72. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +3 -13
  73. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -1
  74. package/lib/commonjs/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js +5 -10
  75. package/lib/commonjs/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js.map +1 -1
  76. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +16 -35
  77. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
  78. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js +2 -5
  79. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -1
  80. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.js +4 -7
  81. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.js.map +1 -1
  82. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js +4 -10
  83. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js.map +1 -1
  84. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +25 -58
  85. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
  86. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js +4 -26
  87. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -1
  88. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js +1 -11
  89. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
  90. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.js +4 -0
  91. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.js.map +1 -1
  92. package/lib/commonjs/rum/types.js +15 -27
  93. package/lib/commonjs/rum/types.js.map +1 -1
  94. package/lib/commonjs/sdk/AttributesSingleton/AttributesSingleton.js +20 -30
  95. package/lib/commonjs/sdk/AttributesSingleton/AttributesSingleton.js.map +1 -1
  96. package/lib/commonjs/sdk/AttributesSingleton/types.js.map +1 -1
  97. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +112 -144
  98. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  99. package/lib/commonjs/sdk/DatadogProvider/Buffer/BufferSingleton.js +19 -22
  100. package/lib/commonjs/sdk/DatadogProvider/Buffer/BufferSingleton.js.map +1 -1
  101. package/lib/commonjs/sdk/DatadogProvider/Buffer/DatadogBuffer.js +1 -15
  102. package/lib/commonjs/sdk/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -1
  103. package/lib/commonjs/sdk/DatadogProvider/Buffer/PassThroughBuffer.js +9 -16
  104. package/lib/commonjs/sdk/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -1
  105. package/lib/commonjs/sdk/DatadogProvider/Buffer/bufferNativeCall.js +2 -8
  106. package/lib/commonjs/sdk/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -1
  107. package/lib/commonjs/sdk/DatadogProvider/DatadogProvider.js +8 -25
  108. package/lib/commonjs/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
  109. package/lib/commonjs/sdk/DdSdk.js +2 -4
  110. package/lib/commonjs/sdk/DdSdk.js.map +1 -1
  111. package/lib/commonjs/sdk/EventMappers/EventMapper.js +31 -51
  112. package/lib/commonjs/sdk/EventMappers/EventMapper.js.map +1 -1
  113. package/lib/commonjs/sdk/EventMappers/utils/deepClone.js +9 -24
  114. package/lib/commonjs/sdk/EventMappers/utils/deepClone.js.map +1 -1
  115. package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js +6 -38
  116. package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +1 -1
  117. package/lib/commonjs/sdk/GlobalState/GlobalState.js +33 -0
  118. package/lib/commonjs/sdk/GlobalState/GlobalState.js.map +1 -0
  119. package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js +17 -28
  120. package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -1
  121. package/lib/commonjs/sdk/UserInfoSingleton/types.js.map +1 -1
  122. package/lib/commonjs/specs/NativeDdLogs.js +5 -6
  123. package/lib/commonjs/specs/NativeDdLogs.js.map +1 -1
  124. package/lib/commonjs/specs/NativeDdRum.js +5 -6
  125. package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
  126. package/lib/commonjs/specs/NativeDdSdk.js +5 -6
  127. package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
  128. package/lib/commonjs/specs/NativeDdTrace.js +5 -6
  129. package/lib/commonjs/specs/NativeDdTrace.js.map +1 -1
  130. package/lib/commonjs/trace/DdTrace.js +17 -29
  131. package/lib/commonjs/trace/DdTrace.js.map +1 -1
  132. package/lib/commonjs/types.js +4 -3
  133. package/lib/commonjs/types.js.map +1 -1
  134. package/lib/commonjs/utils/Timer.js +7 -22
  135. package/lib/commonjs/utils/Timer.js.map +1 -1
  136. package/lib/commonjs/utils/argsUtils.js +3 -11
  137. package/lib/commonjs/utils/argsUtils.js.map +1 -1
  138. package/lib/commonjs/utils/errorUtils.js +9 -22
  139. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  140. package/lib/commonjs/utils/jsUtils.js +1 -2
  141. package/lib/commonjs/utils/jsUtils.js.map +1 -1
  142. package/lib/commonjs/utils/longTasksUtils.js +2 -7
  143. package/lib/commonjs/utils/longTasksUtils.js.map +1 -1
  144. package/lib/commonjs/utils/time-provider/DefaultTimeProvider.js +9 -15
  145. package/lib/commonjs/utils/time-provider/DefaultTimeProvider.js.map +1 -1
  146. package/lib/commonjs/utils/time-provider/TimeProvider.js +1 -11
  147. package/lib/commonjs/utils/time-provider/TimeProvider.js.map +1 -1
  148. package/lib/commonjs/version.js +1 -2
  149. package/lib/commonjs/version.js.map +1 -1
  150. package/lib/module/DdSdkReactNative.js +102 -122
  151. package/lib/module/DdSdkReactNative.js.map +1 -1
  152. package/lib/module/DdSdkReactNativeConfiguration.js +49 -101
  153. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  154. package/lib/module/InternalLog.js +4 -15
  155. package/lib/module/InternalLog.js.map +1 -1
  156. package/lib/module/ProxyConfiguration.js +3 -14
  157. package/lib/module/ProxyConfiguration.js.map +1 -1
  158. package/lib/module/SdkVerbosity.js +3 -4
  159. package/lib/module/SdkVerbosity.js.map +1 -1
  160. package/lib/module/TrackingConsent.js +3 -4
  161. package/lib/module/TrackingConsent.js.map +1 -1
  162. package/lib/module/index.js +5 -0
  163. package/lib/module/index.js.map +1 -1
  164. package/lib/module/logs/DdLogs.js +98 -117
  165. package/lib/module/logs/DdLogs.js.map +1 -1
  166. package/lib/module/logs/eventMapper.js +3 -1
  167. package/lib/module/logs/eventMapper.js.map +1 -1
  168. package/lib/module/logs/types.js +1 -1
  169. package/lib/module/logs/types.js.map +1 -1
  170. package/lib/module/nativeModulesTypes.js +5 -1
  171. package/lib/module/nativeModulesTypes.js.map +1 -1
  172. package/lib/module/polyfills.js +26 -0
  173. package/lib/module/polyfills.js.map +1 -0
  174. package/lib/module/rum/DdAttributes.js +20 -0
  175. package/lib/module/rum/DdAttributes.js.map +1 -0
  176. package/lib/module/rum/DdRum.js +140 -187
  177. package/lib/module/rum/DdRum.js.map +1 -1
  178. package/lib/module/rum/eventMappers/actionEventMapper.js +5 -5
  179. package/lib/module/rum/eventMappers/actionEventMapper.js.map +1 -1
  180. package/lib/module/rum/eventMappers/errorEventMapper.js +3 -4
  181. package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -1
  182. package/lib/module/rum/eventMappers/resourceEventMapper.js +5 -5
  183. package/lib/module/rum/eventMappers/resourceEventMapper.js.map +1 -1
  184. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +64 -79
  185. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  186. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +7 -36
  187. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  188. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +49 -54
  189. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  190. package/lib/module/rum/instrumentation/interactionTracking/EventsInterceptor.js.map +1 -1
  191. package/lib/module/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js +3 -2
  192. package/lib/module/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js.map +1 -1
  193. package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +0 -4
  194. package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
  195. package/lib/module/rum/instrumentation/interactionTracking/getJsxRuntime.js +16 -14
  196. package/lib/module/rum/instrumentation/interactionTracking/getJsxRuntime.js.map +1 -1
  197. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +2 -12
  198. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  199. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +33 -45
  200. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
  201. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +1 -4
  202. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
  203. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +2 -10
  204. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
  205. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +3 -5
  206. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -1
  207. package/lib/module/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js +1 -0
  208. package/lib/module/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js.map +1 -1
  209. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +12 -30
  210. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
  211. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js +2 -3
  212. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -1
  213. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.js +4 -4
  214. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.js.map +1 -1
  215. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js +4 -5
  216. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js.map +1 -1
  217. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +20 -48
  218. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
  219. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js +2 -20
  220. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -1
  221. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js +1 -9
  222. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
  223. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.js +1 -1
  224. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.js.map +1 -1
  225. package/lib/module/rum/types.js +14 -18
  226. package/lib/module/rum/types.js.map +1 -1
  227. package/lib/module/sdk/AttributesSingleton/AttributesSingleton.js +20 -28
  228. package/lib/module/sdk/AttributesSingleton/AttributesSingleton.js.map +1 -1
  229. package/lib/module/sdk/AttributesSingleton/types.js.map +1 -1
  230. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +108 -137
  231. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  232. package/lib/module/sdk/DatadogProvider/Buffer/BufferSingleton.js +14 -18
  233. package/lib/module/sdk/DatadogProvider/Buffer/BufferSingleton.js.map +1 -1
  234. package/lib/module/sdk/DatadogProvider/Buffer/DatadogBuffer.js +1 -13
  235. package/lib/module/sdk/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -1
  236. package/lib/module/sdk/DatadogProvider/Buffer/PassThroughBuffer.js +5 -14
  237. package/lib/module/sdk/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -1
  238. package/lib/module/sdk/DatadogProvider/Buffer/bufferNativeCall.js +1 -0
  239. package/lib/module/sdk/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -1
  240. package/lib/module/sdk/DatadogProvider/DatadogProvider.js +6 -14
  241. package/lib/module/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
  242. package/lib/module/sdk/DdSdk.js +1 -1
  243. package/lib/module/sdk/DdSdk.js.map +1 -1
  244. package/lib/module/sdk/EventMappers/EventMapper.js +27 -41
  245. package/lib/module/sdk/EventMappers/EventMapper.js.map +1 -1
  246. package/lib/module/sdk/EventMappers/utils/deepClone.js +9 -22
  247. package/lib/module/sdk/EventMappers/utils/deepClone.js.map +1 -1
  248. package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js +5 -29
  249. package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +1 -1
  250. package/lib/module/sdk/GlobalState/GlobalState.js +26 -0
  251. package/lib/module/sdk/GlobalState/GlobalState.js.map +1 -0
  252. package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js +17 -26
  253. package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -1
  254. package/lib/module/sdk/UserInfoSingleton/types.js.map +1 -1
  255. package/lib/module/specs/NativeDdLogs.js +3 -0
  256. package/lib/module/specs/NativeDdLogs.js.map +1 -1
  257. package/lib/module/specs/NativeDdRum.js +3 -0
  258. package/lib/module/specs/NativeDdRum.js.map +1 -1
  259. package/lib/module/specs/NativeDdSdk.js +3 -0
  260. package/lib/module/specs/NativeDdSdk.js.map +1 -1
  261. package/lib/module/specs/NativeDdTrace.js +3 -0
  262. package/lib/module/specs/NativeDdTrace.js.map +1 -1
  263. package/lib/module/trace/DdTrace.js +12 -19
  264. package/lib/module/trace/DdTrace.js.map +1 -1
  265. package/lib/module/types.js +5 -1
  266. package/lib/module/types.js.map +1 -1
  267. package/lib/module/utils/Timer.js +3 -20
  268. package/lib/module/utils/Timer.js.map +1 -1
  269. package/lib/module/utils/argsUtils.js +3 -5
  270. package/lib/module/utils/argsUtils.js.map +1 -1
  271. package/lib/module/utils/errorUtils.js +6 -9
  272. package/lib/module/utils/errorUtils.js.map +1 -1
  273. package/lib/module/utils/jsUtils.js +1 -0
  274. package/lib/module/utils/jsUtils.js.map +1 -1
  275. package/lib/module/utils/longTasksUtils.js +2 -5
  276. package/lib/module/utils/longTasksUtils.js.map +1 -1
  277. package/lib/module/utils/time-provider/DefaultTimeProvider.js +5 -13
  278. package/lib/module/utils/time-provider/DefaultTimeProvider.js.map +1 -1
  279. package/lib/module/utils/time-provider/TimeProvider.js +1 -9
  280. package/lib/module/utils/time-provider/TimeProvider.js.map +1 -1
  281. package/lib/module/version.js +1 -1
  282. package/lib/module/version.js.map +1 -1
  283. package/lib/typescript/DdSdkReactNative.d.ts +1 -5
  284. package/lib/typescript/DdSdkReactNative.d.ts.map +1 -0
  285. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +1 -0
  286. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts.map +1 -0
  287. package/lib/typescript/InternalLog.d.ts +1 -0
  288. package/lib/typescript/InternalLog.d.ts.map +1 -0
  289. package/lib/typescript/ProxyConfiguration.d.ts +1 -0
  290. package/lib/typescript/ProxyConfiguration.d.ts.map +1 -0
  291. package/lib/typescript/SdkVerbosity.d.ts +1 -0
  292. package/lib/typescript/SdkVerbosity.d.ts.map +1 -0
  293. package/lib/typescript/TrackingConsent.d.ts +1 -0
  294. package/lib/typescript/TrackingConsent.d.ts.map +1 -0
  295. package/lib/typescript/index.d.ts +2 -0
  296. package/lib/typescript/index.d.ts.map +1 -0
  297. package/lib/typescript/logs/DdLogs.d.ts +1 -0
  298. package/lib/typescript/logs/DdLogs.d.ts.map +1 -0
  299. package/lib/typescript/logs/eventMapper.d.ts +1 -0
  300. package/lib/typescript/logs/eventMapper.d.ts.map +1 -0
  301. package/lib/typescript/logs/types.d.ts +6 -1
  302. package/lib/typescript/logs/types.d.ts.map +1 -0
  303. package/lib/typescript/nativeModulesTypes.d.ts +3 -1
  304. package/lib/typescript/nativeModulesTypes.d.ts.map +1 -0
  305. package/lib/typescript/rum/DdAttributes.d.ts +14 -0
  306. package/lib/typescript/rum/DdAttributes.d.ts.map +1 -0
  307. package/lib/typescript/rum/DdRum.d.ts +3 -2
  308. package/lib/typescript/rum/DdRum.d.ts.map +1 -0
  309. package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts +1 -0
  310. package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts.map +1 -0
  311. package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +3 -0
  312. package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts.map +1 -0
  313. package/lib/typescript/rum/eventMappers/resourceEventMapper.d.ts +1 -0
  314. package/lib/typescript/rum/eventMappers/resourceEventMapper.d.ts.map +1 -0
  315. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +1 -0
  316. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts.map +1 -0
  317. package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +1 -0
  318. package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts.map +1 -0
  319. package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +2 -0
  320. package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts.map +1 -0
  321. package/lib/typescript/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts +1 -0
  322. package/lib/typescript/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts.map +1 -0
  323. package/lib/typescript/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts +1 -0
  324. package/lib/typescript/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts.map +1 -0
  325. package/lib/typescript/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts +1 -0
  326. package/lib/typescript/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts.map +1 -0
  327. package/lib/typescript/rum/instrumentation/interactionTracking/getJsxRuntime.d.ts +2 -1
  328. package/lib/typescript/rum/instrumentation/interactionTracking/getJsxRuntime.d.ts.map +1 -0
  329. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +1 -0
  330. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -0
  331. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts +1 -0
  332. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts.map +1 -0
  333. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +1 -0
  334. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts.map +1 -0
  335. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +1 -0
  336. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts.map +1 -0
  337. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +1 -0
  338. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts.map +1 -0
  339. package/lib/typescript/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts +1 -0
  340. package/lib/typescript/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts.map +1 -0
  341. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts +1 -0
  342. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts.map +1 -0
  343. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts +1 -0
  344. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts.map +1 -0
  345. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.d.ts +1 -0
  346. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.d.ts.map +1 -0
  347. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.d.ts +1 -0
  348. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.d.ts.map +1 -0
  349. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +1 -0
  350. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -0
  351. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.d.ts +1 -0
  352. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.d.ts.map +1 -0
  353. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +1 -0
  354. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts.map +1 -0
  355. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +1 -0
  356. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts.map +1 -0
  357. package/lib/typescript/rum/types.d.ts +1 -0
  358. package/lib/typescript/rum/types.d.ts.map +1 -0
  359. package/lib/typescript/sdk/AttributesSingleton/AttributesSingleton.d.ts +1 -0
  360. package/lib/typescript/sdk/AttributesSingleton/AttributesSingleton.d.ts.map +1 -0
  361. package/lib/typescript/sdk/AttributesSingleton/types.d.ts +1 -0
  362. package/lib/typescript/sdk/AttributesSingleton/types.d.ts.map +1 -0
  363. package/lib/typescript/sdk/DatadogProvider/Buffer/BoundedBuffer.d.ts +1 -0
  364. package/lib/typescript/sdk/DatadogProvider/Buffer/BoundedBuffer.d.ts.map +1 -0
  365. package/lib/typescript/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts +1 -0
  366. package/lib/typescript/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts.map +1 -0
  367. package/lib/typescript/sdk/DatadogProvider/Buffer/DatadogBuffer.d.ts +1 -0
  368. package/lib/typescript/sdk/DatadogProvider/Buffer/DatadogBuffer.d.ts.map +1 -0
  369. package/lib/typescript/sdk/DatadogProvider/Buffer/PassThroughBuffer.d.ts +1 -0
  370. package/lib/typescript/sdk/DatadogProvider/Buffer/PassThroughBuffer.d.ts.map +1 -0
  371. package/lib/typescript/sdk/DatadogProvider/Buffer/bufferNativeCall.d.ts +1 -0
  372. package/lib/typescript/sdk/DatadogProvider/Buffer/bufferNativeCall.d.ts.map +1 -0
  373. package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts +1 -0
  374. package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts.map +1 -0
  375. package/lib/typescript/sdk/DdSdk.d.ts +1 -0
  376. package/lib/typescript/sdk/DdSdk.d.ts.map +1 -0
  377. package/lib/typescript/sdk/EventMappers/EventMapper.d.ts +1 -0
  378. package/lib/typescript/sdk/EventMappers/EventMapper.d.ts.map +1 -0
  379. package/lib/typescript/sdk/EventMappers/utils/deepClone.d.ts +1 -0
  380. package/lib/typescript/sdk/EventMappers/utils/deepClone.d.ts.map +1 -0
  381. package/lib/typescript/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts +1 -0
  382. package/lib/typescript/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts.map +1 -0
  383. package/lib/typescript/sdk/GlobalState/GlobalState.d.ts +13 -0
  384. package/lib/typescript/sdk/GlobalState/GlobalState.d.ts.map +1 -0
  385. package/lib/typescript/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +1 -0
  386. package/lib/typescript/sdk/UserInfoSingleton/UserInfoSingleton.d.ts.map +1 -0
  387. package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +1 -0
  388. package/lib/typescript/sdk/UserInfoSingleton/types.d.ts.map +1 -0
  389. package/lib/typescript/specs/NativeDdLogs.d.ts +1 -0
  390. package/lib/typescript/specs/NativeDdLogs.d.ts.map +1 -0
  391. package/lib/typescript/specs/NativeDdRum.d.ts +3 -1
  392. package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -0
  393. package/lib/typescript/specs/NativeDdSdk.d.ts +1 -0
  394. package/lib/typescript/specs/NativeDdSdk.d.ts.map +1 -0
  395. package/lib/typescript/specs/NativeDdTrace.d.ts +1 -0
  396. package/lib/typescript/specs/NativeDdTrace.d.ts.map +1 -0
  397. package/lib/typescript/trace/DdTrace.d.ts +1 -0
  398. package/lib/typescript/trace/DdTrace.d.ts.map +1 -0
  399. package/lib/typescript/types.d.ts +1 -0
  400. package/lib/typescript/types.d.ts.map +1 -0
  401. package/lib/typescript/utils/Timer.d.ts +1 -0
  402. package/lib/typescript/utils/Timer.d.ts.map +1 -0
  403. package/lib/typescript/utils/argsUtils.d.ts +1 -0
  404. package/lib/typescript/utils/argsUtils.d.ts.map +1 -0
  405. package/lib/typescript/utils/errorUtils.d.ts +1 -0
  406. package/lib/typescript/utils/errorUtils.d.ts.map +1 -0
  407. package/lib/typescript/utils/jsUtils.d.ts +1 -0
  408. package/lib/typescript/utils/jsUtils.d.ts.map +1 -0
  409. package/lib/typescript/utils/longTasksUtils.d.ts +1 -0
  410. package/lib/typescript/utils/longTasksUtils.d.ts.map +1 -0
  411. package/lib/typescript/utils/time-provider/DefaultTimeProvider.d.ts +1 -0
  412. package/lib/typescript/utils/time-provider/DefaultTimeProvider.d.ts.map +1 -0
  413. package/lib/typescript/utils/time-provider/TimeProvider.d.ts +1 -0
  414. package/lib/typescript/utils/time-provider/TimeProvider.d.ts.map +1 -0
  415. package/lib/typescript/version.d.ts +2 -1
  416. package/lib/typescript/version.d.ts.map +1 -0
  417. package/package.json +3 -3
  418. package/src/DdSdkReactNative.tsx +3 -10
  419. package/src/__tests__/DdSdkReactNative.test.tsx +5 -3
  420. package/src/__tests__/mock.test.ts +0 -1
  421. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +32 -16
  422. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +17 -15
  423. package/src/index.tsx +4 -0
  424. package/src/logs/DdLogs.ts +25 -8
  425. package/src/logs/__tests__/DdLogs.test.ts +122 -0
  426. package/src/logs/types.ts +5 -1
  427. package/src/nativeModulesTypes.ts +3 -1
  428. package/src/polyfills.js +37 -0
  429. package/src/rum/DdAttributes.ts +20 -0
  430. package/src/rum/DdRum.ts +13 -8
  431. package/src/rum/__tests__/DdRum.test.ts +43 -7
  432. package/src/rum/eventMappers/errorEventMapper.ts +2 -0
  433. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +33 -10
  434. package/src/rum/instrumentation/interactionTracking/getJsxRuntime.ts +10 -3
  435. package/src/rum/instrumentation/resourceTracking/__tests__/__utils__/XMLHttpRequestMock.ts +1 -0
  436. package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/__utils__/TracingIdentifierUtils.ts +1 -1
  437. package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +1 -1
  438. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +1 -1
  439. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +3 -3
  440. package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +3 -2
  441. package/src/sdk/GlobalState/GlobalState.tsx +26 -0
  442. package/src/specs/NativeDdLogs.ts +1 -0
  443. package/src/specs/NativeDdRum.ts +4 -1
  444. package/src/specs/NativeDdSdk.ts +1 -0
  445. package/src/specs/NativeDdTrace.ts +1 -0
  446. package/src/version.ts +1 -1
  447. package/android/src/main/kotlin/com/datadog/reactnative/VitalFrameCallback.kt +0 -41
@@ -3,15 +3,16 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
+
6
7
  import { InternalLog } from '../../../../InternalLog';
7
8
  import { SdkVerbosity } from '../../../../SdkVerbosity';
8
9
  // This regex does not match anything
9
- export const NO_MATCH_REGEX = new RegExp('a^'); // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
10
+ export const NO_MATCH_REGEX = new RegExp('a^');
10
11
 
12
+ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
11
13
  const escapeRegExp = string => {
12
14
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
13
15
  };
14
-
15
16
  export const firstPartyHostsRegexMapBuilder = firstPartyHosts => {
16
17
  const hostsMap = {
17
18
  datadog: [],
@@ -35,12 +36,10 @@ export const firstPartyHostsRegexMapBuilder = firstPartyHosts => {
35
36
  });
36
37
  return regexMap;
37
38
  };
38
-
39
39
  const firstPartyHostsRegexBuilder = firstPartyHosts => {
40
40
  if (firstPartyHosts.length === 0) {
41
41
  return NO_MATCH_REGEX;
42
42
  }
43
-
44
43
  try {
45
44
  // A regexp for matching hosts, e.g. when `hosts` is "example.com", it will match
46
45
  // "example.com", "api.example.com", but not "foo.com".
@@ -52,7 +51,6 @@ const firstPartyHostsRegexBuilder = firstPartyHosts => {
52
51
  return NO_MATCH_REGEX;
53
52
  }
54
53
  };
55
-
56
54
  export const getPropagatorsForHost = (hostname, firstPartyHostsRegexMap) => {
57
55
  const matchedPropagatorTypes = [];
58
56
  firstPartyHostsRegexMap.forEach(({
@@ -1 +1 @@
1
- {"version":3,"sources":["firstPartyHosts.ts"],"names":["InternalLog","SdkVerbosity","NO_MATCH_REGEX","RegExp","escapeRegExp","string","replace","firstPartyHostsRegexMapBuilder","firstPartyHosts","hostsMap","datadog","tracecontext","b3","b3multi","forEach","host","propagatorTypes","propagatorType","push","match","regexMap","Object","entries","hosts","length","regex","firstPartyHostsRegexBuilder","firstPartyHostsRegex","map","join","test","e","log","JSON","stringify","WARN","getPropagatorsForHost","hostname","firstPartyHostsRegexMap","matchedPropagatorTypes"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,yBAA5B;AACA,SAASC,YAAT,QAA6B,0BAA7B;AAMA;AACA,OAAO,MAAMC,cAAc,GAAG,IAAIC,MAAJ,CAAW,IAAX,CAAvB,C,CAEP;;AACA,MAAMC,YAAY,GAAIC,MAAD,IAAoB;AACrC,SAAOA,MAAM,CAACC,OAAP,CAAe,qBAAf,EAAsC,MAAtC,CAAP,CADqC,CACiB;AACzD,CAFD;;AAIA,OAAO,MAAMC,8BAA8B,GACvCC,eAD0C,IAE/B;AACX,QAAMC,QAA0C,GAAG;AAC/CC,IAAAA,OAAO,EAAE,EADsC;AAE/CC,IAAAA,YAAY,EAAE,EAFiC;AAG/CC,IAAAA,EAAE,EAAE,EAH2C;AAI/CC,IAAAA,OAAO,EAAE;AAJsC,GAAnD;AAOAL,EAAAA,eAAe,CAACM,OAAhB,CAAwBC,IAAI,IAAI;AAC5BA,IAAAA,IAAI,CAACC,eAAL,CAAqBF,OAArB,CAA6BG,cAAc,IAAI;AAC3CR,MAAAA,QAAQ,CAACQ,cAAD,CAAR,CAAyBC,IAAz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,GAAD,KAA+B;AAC3D,QAAIQ,KAAK,CAACK,IAAN,CAAWO,QAAX,CAAJ,EAA0B;AACtBE,MAAAA,sBAAsB,CAACrB,IAAvB,CAA4BD,cAA5B;AACH;AACJ,GAJD;AAKA,SAAOsB,sBAAsB,CAACf,MAAvB,GAAgC,CAAhC,GAAoCe,sBAApC,GAA6D,IAApE;AACH,CAXM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\nimport type { FirstPartyHost, PropagatorType } from '../../../types';\nimport type { RegexMap } from '../requestProxy/interfaces/RequestProxy';\n\nexport type Hostname = { _type: 'Hostname' } & string;\n\n// This regex does not match anything\nexport const NO_MATCH_REGEX = new RegExp('a^');\n\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\nconst escapeRegExp = (string: string) => {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n};\n\nexport const firstPartyHostsRegexMapBuilder = (\n firstPartyHosts: FirstPartyHost[]\n): RegexMap => {\n const hostsMap: Record<PropagatorType, string[]> = {\n datadog: [],\n tracecontext: [],\n b3: [],\n b3multi: []\n };\n\n firstPartyHosts.forEach(host => {\n host.propagatorTypes.forEach(propagatorType => {\n hostsMap[propagatorType].push(host.match);\n });\n });\n\n const regexMap: { regex: RegExp; propagatorType: PropagatorType }[] = [];\n Object.entries(hostsMap).forEach(([propagatorType, hosts]) => {\n if (hosts.length > 0) {\n regexMap.push({\n propagatorType: propagatorType as PropagatorType,\n regex: firstPartyHostsRegexBuilder(hosts)\n });\n }\n });\n\n return regexMap;\n};\n\nconst firstPartyHostsRegexBuilder = (firstPartyHosts: string[]): RegExp => {\n if (firstPartyHosts.length === 0) {\n return NO_MATCH_REGEX;\n }\n try {\n // A regexp for matching hosts, e.g. when `hosts` is \"example.com\", it will match\n // \"example.com\", \"api.example.com\", but not \"foo.com\".\n const firstPartyHostsRegex = new RegExp(\n `^(.*\\\\.)*(${firstPartyHosts\n .map(host => `${escapeRegExp(host)}$`)\n .join('|')})`\n );\n firstPartyHostsRegex.test('test_the_regex_is_valid');\n return firstPartyHostsRegex;\n } catch (e) {\n InternalLog.log(\n `Invalid first party hosts list ${JSON.stringify(\n firstPartyHosts\n )}. Regular expressions are not allowed.`,\n SdkVerbosity.WARN\n );\n return NO_MATCH_REGEX;\n }\n};\n\nexport const getPropagatorsForHost = (\n hostname: Hostname,\n firstPartyHostsRegexMap: RegexMap\n): PropagatorType[] | null => {\n const matchedPropagatorTypes: PropagatorType[] = [];\n firstPartyHostsRegexMap.forEach(({ regex, propagatorType }) => {\n if (regex.test(hostname)) {\n matchedPropagatorTypes.push(propagatorType);\n }\n });\n return matchedPropagatorTypes.length > 0 ? matchedPropagatorTypes : null;\n};\n"]}
1
+ {"version":3,"names":["InternalLog","SdkVerbosity","NO_MATCH_REGEX","RegExp","escapeRegExp","string","replace","firstPartyHostsRegexMapBuilder","firstPartyHosts","hostsMap","datadog","tracecontext","b3","b3multi","forEach","host","propagatorTypes","propagatorType","push","match","regexMap","Object","entries","hosts","length","regex","firstPartyHostsRegexBuilder","firstPartyHostsRegex","map","join","test","e","log","JSON","stringify","WARN","getPropagatorsForHost","hostname","firstPartyHostsRegexMap","matchedPropagatorTypes"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,yBAAyB;AACrD,SAASC,YAAY,QAAQ,0BAA0B;AAMvD;AACA,OAAO,MAAMC,cAAc,GAAG,IAAIC,MAAM,CAAC,IAAI,CAAC;;AAE9C;AACA,MAAMC,YAAY,GAAIC,MAAc,IAAK;EACrC,OAAOA,MAAM,CAACC,OA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,CAAC,EAAE;IACR/B,WAAW,CAACgC,GAAG,CACX,kCAAkCC,IAAI,CAACC,SAAS,CAC5C1B,eACJ,CAAC,wCAAwC,EACzCP,YAAY,CAACkC,IACjB,CAAC;IACD,OAAOjC,cAAc;EACzB;AACJ,CAAC;AAED,OAAO,MAAMkC,qBAAqB,GAAGA,CACjCC,QAAkB,EAClBC,uBAAiC,KACP;EAC1B,MAAMC,sBAAwC,GAAG,EAAE;EACnDD,uBAAuB,CAACxB,OAAO,CAAC,CAAC;IAAEW,KAAK;IAAER;EAAe,CAAC,KAAK;IAC3D,IAAIQ,KAAK,CAACK,IAAI,CAACO,QAAQ,CAAC,EAAE;MACtBE,sBAAsB,CAACrB,IAAI,CAACD,cAAc,CAAC;IAC/C;EACJ,CAAC,CAAC;EACF,OAAOsB,sBAAsB,CAACf,MAAM,GAAG,CAAC,GAAGe,sBAAsB,GAAG,IAAI;AAC5E,CAAC","ignoreList":[]}
@@ -3,6 +3,7 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
+
6
7
  const DATADOG_CUSTOM_HEADER_PREFIX = '_dd-custom-header';
7
8
  export const DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-name`;
8
9
  export const DATADOG_GRAPH_QL_VARIABLES_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-variables`;
@@ -1 +1 @@
1
- {"version":3,"sources":["graphqlHeaders.ts"],"names":["DATADOG_CUSTOM_HEADER_PREFIX","DATADOG_GRAPH_QL_OPERATION_NAME_HEADER","DATADOG_GRAPH_QL_VARIABLES_HEADER","DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER","isDatadogCustomHeader","header","match","RegExp"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,MAAMA,4BAA4B,GAAG,mBAArC;AAEA,OAAO,MAAMC,sCAAsC,GAAI,GAAED,4BAA6B,0BAA/E;AACP,OAAO,MAAME,iCAAiC,GAAI,GAAEF,4BAA6B,qBAA1E;AACP,OAAO,MAAMG,sCAAsC,GAAI,GAAEH,4BAA6B,0BAA/E;AAEP,OAAO,MAAMI,qBAAqB,GAAIC,MAAD,IAAoB;AACrD,SAAOA,MAAM,CAACC,KAAP,CAAa,IAAIC,MAAJ,CAAY,IAAGP,4BAA6B,EAA5C,CAAb,CAAP;AACH,CAFM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nconst DATADOG_CUSTOM_HEADER_PREFIX = '_dd-custom-header';\n\nexport const DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-name`;\nexport const DATADOG_GRAPH_QL_VARIABLES_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-variables`;\nexport const DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-type`;\n\nexport const isDatadogCustomHeader = (header: string) => {\n return header.match(new RegExp(`^${DATADOG_CUSTOM_HEADER_PREFIX}`));\n};\n"]}
1
+ {"version":3,"names":["DATADOG_CUSTOM_HEADER_PREFIX","DATADOG_GRAPH_QL_OPERATION_NAME_HEADER","DATADOG_GRAPH_QL_VARIABLES_HEADER","DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER","isDatadogCustomHeader","header","match","RegExp"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/graphql/graphqlHeaders.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,4BAA4B,GAAG,mBAAmB;AAExD,OAAO,MAAMC,sCAAsC,GAAG,GAAGD,4BAA4B,0BAA0B;AAC/G,OAAO,MAAME,iCAAiC,GAAG,GAAGF,4BAA4B,qBAAqB;AACrG,OAAO,MAAMG,sCAAsC,GAAG,GAAGH,4BAA4B,0BAA0B;AAE/G,OAAO,MAAMI,qBAAqB,GAAIC,MAAc,IAAK;EACrD,OAAOA,MAAM,CAACC,KAAK,CAAC,IAAIC,MAAM,CAAC,IAAIP,4BAA4B,EAAE,CAAC,CAAC;AACvE,CAAC","ignoreList":[]}
@@ -1,70 +1,52 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
1
  /*
4
2
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
5
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
6
4
  * Copyright 2016-Present Datadog, Inc.
7
5
  */
6
+
8
7
  import { DdRum } from '../../../../../DdRum';
9
8
  import { TracingIdFormat } from '../../../distributedTracing/TracingIdentifier';
10
9
  import { createTimings } from './resourceTiming';
11
10
  export class ResourceReporter {
12
11
  constructor(resourceMappers) {
13
- _defineProperty(this, "mappers", void 0);
14
-
15
- _defineProperty(this, "reportResource", resource => {
16
- let modifiedResource = resource;
17
-
18
- for (const mapper of this.mappers) {
19
- modifiedResource = mapper(resource);
20
-
21
- if (modifiedResource === null) {
22
- return;
23
- }
24
- }
25
-
26
- reportResource(modifiedResource);
27
- });
28
-
29
12
  this.mappers = resourceMappers;
30
13
  }
31
-
14
+ reportResource = resource => {
15
+ let modifiedResource = resource;
16
+ for (const mapper of this.mappers) {
17
+ modifiedResource = mapper(resource);
18
+ if (modifiedResource === null) {
19
+ return;
20
+ }
21
+ }
22
+ reportResource(modifiedResource);
23
+ };
32
24
  }
33
-
34
25
  const formatResourceStartContext = tracingAttributes => {
35
26
  const attributes = {};
36
-
37
27
  if (tracingAttributes.samplingPriorityHeader !== '0') {
38
28
  attributes['_dd.span_id'] = tracingAttributes.spanId.toString(TracingIdFormat.decimal);
39
29
  attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(TracingIdFormat.paddedHex);
40
30
  attributes['_dd.rule_psr'] = tracingAttributes.rulePsr;
41
31
  }
42
-
43
32
  return attributes;
44
33
  };
45
-
46
34
  const formatResourceStopContext = (timings, graphqlAttributes) => {
47
35
  const attributes = {};
48
-
49
36
  if (timings.responseStartTime !== undefined) {
50
37
  attributes['_dd.resource_timings'] = createTimings(timings.startTime, timings.responseStartTime, timings.stopTime);
51
38
  }
52
-
53
- if (graphqlAttributes !== null && graphqlAttributes !== void 0 && graphqlAttributes.operationType) {
39
+ if (graphqlAttributes?.operationType) {
54
40
  attributes['_dd.graphql.operation_type'] = graphqlAttributes.operationType;
55
-
56
41
  if (graphqlAttributes.operationName) {
57
42
  attributes['_dd.graphql.operation_name'] = graphqlAttributes.operationName;
58
43
  }
59
-
60
44
  if (graphqlAttributes.variables) {
61
45
  attributes['_dd.graphql.variables'] = graphqlAttributes.variables;
62
46
  }
63
47
  }
64
-
65
48
  return attributes;
66
49
  };
67
-
68
50
  const reportResource = async resource => {
69
51
  await DdRum.startResource(resource.key, resource.request.method, resource.request.url, formatResourceStartContext(resource.tracingAttributes), resource.timings.startTime);
70
52
  DdRum.stopResource(resource.key, resource.response.statusCode, resource.request.kind, resource.response.size, formatResourceStopContext(resource.timings, resource.graphqlAttributes), resource.timings.stopTime, resource.resourceContext);
@@ -1 +1 @@
1
- {"version":3,"sources":["ResourceReporter.ts"],"names":["DdRum","TracingIdFormat","createTimings","ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","attributes","samplingPriorityHeader","spanId","toString","decimal","traceId","paddedHex","rulePsr","formatResourceStopContext","timings","graphqlAttributes","responseStartTime","undefined","startTime","stopTime","operationType","operationName","variables","startResource","key","request","method","url","stopResource","response","statusCode","kind","size","resourceContext"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,QAAsB,sBAAtB;AACA,SAASC,eAAT,QAAgC,+CAAhC;AAGA,SA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AAKH;;AAED,MAAIJ,iBAAJ,aAAIA,iBAAJ,eAAIA,iBAAiB,CAAEK,aAAvB,EAAsC;AAClCf,IAAAA,UAAU,CAAC,4BAAD,CAAV,GACIU,iBAAiB,CAACK,aADtB;;AAEA,QAAIL,iBAAiB,CAACM,aAAtB,EAAqC;AACjChB,MAAAA,UAAU,CAAC,4BAAD,CAAV,GACIU,iBAAiB,CAACM,aADtB;AAEH;;AACD,QAAIN,iBAAiB,CAACO,SAAtB,EAAiC;AAC7BjB,MAAAA,UAAU,CAAC,uBAAD,CAAV,GAAsCU,iBAAiB,CAACO,SAAxD;AACH;AACJ;;AAED,SAAOjB,UAAP;AACH,CA3BD;;AA6BA,MAAMH,cAAc,GAAG,MAAOJ,QAAP,IAAiC;AACpD,QAAMN,KAAK,CAAC+B,aAAN,CACFzB,QAAQ,CAAC0B,GADP,EAEF1B,QAAQ,CAAC2B,OAAT,CAAiBC,MAFf,EAGF5B,QAAQ,CAAC2B,OAAT,CAAiBE,GAHf,EAIFxB,0BAA0B,CAACL,QAAQ,CAACM,iBAAV,CAJxB,EAKFN,QAAQ,CAACgB,OAAT,CAAiBI,SALf,CAAN;AAQA1B,EAAAA,KAAK,CAACoC,YAAN,CACI9B,QAAQ,CAAC0B,GADb,EAEI1B,QAAQ,CAAC+B,QAAT,CAAkBC,UAFtB,EAGIhC,QAAQ,CAAC2B,OAAT,CAAiBM,IAHrB,EAIIjC,QAAQ,CAAC+B,QAAT,CAAkBG,IAJtB,EAKInB,yBAAyB,CAACf,QAAQ,CAACgB,OAAV,EAAmBhB,QAAQ,CAACiB,iBAA5B,CAL7B,EAMIjB,QAAQ,CAACgB,OAAT,CAAiBK,QANrB,EAOIrB,QAAQ,CAACmC,eAPb;AASH,CAlBD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRum } from '../../../../../DdRum';\nimport { TracingIdFormat } from '../../../distributedTracing/TracingIdentifier';\nimport type { RUMResource } from '../../interfaces/RumResource';\n\nimport { createTimings } from './resourceTiming';\n\ntype ResourceMapper = (resource: RUMResource) => RUMResource | null;\n\nexport class ResourceReporter {\n private mappers: ResourceMapper[];\n\n constructor(resourceMappers: ResourceMapper[]) {\n this.mappers = resourceMappers;\n }\n\n reportResource = (resource: RUMResource) => {\n let modifiedResource: RUMResource | null = resource;\n\n for (const mapper of this.mappers) {\n modifiedResource = mapper(resource);\n if (modifiedResource === null) {\n return;\n }\n }\n\n reportResource(modifiedResource);\n };\n}\n\nconst formatResourceStartContext = (\n tracingAttributes: RUMResource['tracingAttributes']\n): Record<string, string | number> => {\n const attributes: Record<string, string | number> = {};\n if (tracingAttributes.samplingPriorityHeader !== '0') {\n attributes['_dd.span_id'] = tracingAttributes.spanId.toString(\n TracingIdFormat.decimal\n );\n attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(\n TracingIdFormat.paddedHex\n );\n attributes['_dd.rule_psr'] = tracingAttributes.rulePsr;\n }\n\n return attributes;\n};\n\nconst formatResourceStopContext = (\n timings: RUMResource['timings'],\n graphqlAttributes: RUMResource['graphqlAttributes']\n): Record<string, unknown> => {\n const attributes: Record<string, unknown> = {};\n\n if (timings.responseStartTime !== undefined) {\n attributes['_dd.resource_timings'] = createTimings(\n timings.startTime,\n timings.responseStartTime,\n timings.stopTime\n );\n }\n\n if (graphqlAttributes?.operationType) {\n attributes['_dd.graphql.operation_type'] =\n graphqlAttributes.operationType;\n if (graphqlAttributes.operationName) {\n attributes['_dd.graphql.operation_name'] =\n graphqlAttributes.operationName;\n }\n if (graphqlAttributes.variables) {\n attributes['_dd.graphql.variables'] = graphqlAttributes.variables;\n }\n }\n\n return attributes;\n};\n\nconst reportResource = async (resource: RUMResource) => {\n await DdRum.startResource(\n resource.key,\n resource.request.method,\n resource.request.url,\n formatResourceStartContext(resource.tracingAttributes),\n resource.timings.startTime\n );\n\n DdRum.stopResource(\n resource.key,\n resource.response.statusCode,\n resource.request.kind,\n resource.response.size,\n formatResourceStopContext(resource.timings, resource.graphqlAttributes),\n resource.timings.stopTime,\n resource.resourceContext\n );\n};\n"]}
1
+ {"version":3,"names":["DdRum","TracingIdFormat","createTimings","ResourceReporter","constructor","resourceMappers","mappers","reportResource","resource","modifiedResource","mapper","formatResourceStartContext","tracingAttributes","attributes","samplingPriorityHeader","spanId","toString","decimal","traceId","paddedHex","rulePsr","formatResourceStopContext","timings","graphqlAttributes","responseStartTime","undefined","startTime","stopTime","operationType","operationName","variables","startResource","key","request","method","url","stopResource","response","statusCode","kind","size","resourceContext"],"sourceRoot":"../../../../../../../../src","sources":["rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,sBAAsB;AAC5C,SAASC,eAAe,QAAQ,+CAA+C;AAG/E,SAASC,aAAa,QAAQ,kBAAkB;AAIhD,OAAO,MAAMC,gBAAgB,CAAC;EAG1BC,WAAWA,CAACC,eAAiC,EAAE;IAC3C,IAAI,CAACC,OAAO,GAAGD,eAAe;EAClC;EAEAE,cAAc,GAAIC,QAAqB,IAAK;IACxC,IAAIC,gBAAoC,GAAGD,QAAQ;IAEnD,KAAK,MAAME,MAAM,IAAI,IAAI,CAACJ,OAAO,EAAE;MAC/BG,gBAAgB,GAAGC,MAAM,CAACF,QAAQ,CAAC;MACnC,IAAIC,gBAAgB,KAAK,IAAI,EAAE;QAC3B;MACJ;IACJ;IAEAF,cAAc,CAACE,gBAAgB,CAAC;EACpC,CAAC;AACL;AAEA,MAAME,0BAA0B,GAC5BC,iBAAmD,IACjB;EAClC,MAAMC,UAA2C,GAAG,CAAC,CAAC;EACtD,IAAID,iBAAiB,CAACE,sBAAsB,KAAK,GAAG,EAAE;IAClDD,UAAU,CAAC,aAAa,CAAC,GAAGD,iBAAiB,CAACG,MAAM,CAACC,QAAQ,CAC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ACZxB,QAAQ,CAAC6B,QAAQ,CAACC,UAAU,EAC5B9B,QAAQ,CAACyB,OAAO,CAACM,IAAI,EACrB/B,QAAQ,CAAC6B,QAAQ,CAACG,IAAI,EACtBnB,yBAAyB,CAACb,QAAQ,CAACc,OAAO,EAAEd,QAAQ,CAACe,iBAAiB,CAAC,EACvEf,QAAQ,CAACc,OAAO,CAACK,QAAQ,EACzBnB,QAAQ,CAACiC,eACb,CAAC;AACL,CAAC","ignoreList":[]}
@@ -14,17 +14,17 @@
14
14
  * An example URL is http://192.168.1.20:8081/logs or http://10.46.29.155:19000/logs
15
15
  */
16
16
  const EXPO_DEV_LOGS_REGEX = new RegExp('^http://((10|172|192).[0-9]+.[0-9]+.[0-9]+|localhost|127.0.0.1):808[0-9]/logs$');
17
+
17
18
  /**
18
19
  * This call is made every time the RN packager reloads the js in dev mode.
19
20
  */
20
-
21
21
  const RN_PACKAGER_SYMBOLICATE_REGEX = new RegExp('^http://localhost:808[0-9]/symbolicate$');
22
22
  const internalDevResourceBlocklist = [EXPO_DEV_LOGS_REGEX, RN_PACKAGER_SYMBOLICATE_REGEX];
23
+
23
24
  /**
24
25
  * Filters RN symbolicate calls and Expo logs calls that happen only in dev.
25
26
  * @param resource RUMResource
26
27
  */
27
-
28
28
  export const filterDevResource = resource => {
29
29
  if (__DEV__) {
30
30
  for (const resourceRegex of internalDevResourceBlocklist) {
@@ -33,7 +33,6 @@ export const filterDevResource = resource => {
33
33
  }
34
34
  }
35
35
  }
36
-
37
36
  return resource;
38
37
  };
39
38
  //# sourceMappingURL=internalDevResourceBlocklist.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["internalDevResourceBlocklist.ts"],"names":["EXPO_DEV_LOGS_REGEX","RegExp","RN_PACKAGER_SYMBOLICATE_REGEX","internalDevResourceBlocklist","filterDevResource","resource","__DEV__","resourceRegex","test","request","url"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,IAAIC,MAAJ,CACxB,gFADwB,CAA5B;AAIA;AACA;AACA;;AACA,MAAMC,6BAA6B,GAAG,IAAID,MAAJ,CAClC,yCADkC,CAAtC;AAIA,MAAME,4BAAsC,GAAG,CAC3CH,mBAD2C,EAE3CE,6BAF2C,CAA/C;AAKA;AACA;AACA;AACA;;AACA,OAAO,MAAME,iBAAiB,GAC1BC,QAD6B,IAER;AACrB,MAAIC,OAAJ,EAAa;AACT,SAAK,MAAMC,aAAX,IAA4BJ,4BAA5B,EAA0D;AACtD,UAAII,aAAa,CAACC,IAAd,CAAmBH,QAAQ,CAACI,OAAT,CAAiBC,GAApC,CAAJ,EAA8C;AAC1C,eAAO,IAAP;AACH;AACJ;AACJ;;AACD,SAAOL,QAAP;AACH,CAXM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { RUMResource } from '../../interfaces/RumResource';\n\n/**\n * Expo sends all console.* calls to the packager. As we log all API calls\n * when the SDKVerbosity is DEBUG, this would result in an infinite loop of\n * `console.log` and API calls, creating 250 RUM resources per second.\n *\n * The hostname is always going to be localhost or a local IP.\n *\n * An example URL is http://192.168.1.20:8081/logs or http://10.46.29.155:19000/logs\n */\nconst EXPO_DEV_LOGS_REGEX = new RegExp(\n '^http://((10|172|192).[0-9]+.[0-9]+.[0-9]+|localhost|127.0.0.1):808[0-9]/logs$'\n);\n\n/**\n * This call is made every time the RN packager reloads the js in dev mode.\n */\nconst RN_PACKAGER_SYMBOLICATE_REGEX = new RegExp(\n '^http://localhost:808[0-9]/symbolicate$'\n);\n\nconst internalDevResourceBlocklist: RegExp[] = [\n EXPO_DEV_LOGS_REGEX,\n RN_PACKAGER_SYMBOLICATE_REGEX\n];\n\n/**\n * Filters RN symbolicate calls and Expo logs calls that happen only in dev.\n * @param resource RUMResource\n */\nexport const filterDevResource = (\n resource: RUMResource\n): RUMResource | null => {\n if (__DEV__) {\n for (const resourceRegex of internalDevResourceBlocklist) {\n if (resourceRegex.test(resource.request.url)) {\n return null;\n }\n }\n }\n return resource;\n};\n"]}
1
+ {"version":3,"names":["EXPO_DEV_LOGS_REGEX","RegExp","RN_PACKAGER_SYMBOLICATE_REGEX","internalDevResourceBlocklist","filterDevResource","resource","__DEV__","resourceRegex","test","request","url"],"sourceRoot":"../../../../../../../../src","sources":["rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,IAAIC,MAAM,CAClC,gFACJ,CAAC;;AAED;AACA;AACA;AACA,MAAMC,6BAA6B,GAAG,IAAID,MAAM,CAC5C,yCACJ,CAAC;AAED,MAAME,4BAAsC,GAAG,CAC3CH,mBAAmB,EACnBE,6BAA6B,CAChC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAME,iBAAiB,GAC1BC,QAAqB,IACA;EACrB,IAAIC,OAAO,EAAE;IACT,KAAK,MAAMC,aAAa,IAAIJ,4BAA4B,EAAE;MACtD,IAAII,aAAa,CAACC,IAAI,CAACH,QAAQ,CAACI,OAAO,CAACC,GAAG,CAAC,EAAE;QAC1C,OAAO,IAAI;MACf;IACJ;EACJ;EACA,OAAOL,QAAQ;AACnB,CAAC","ignoreList":[]}
@@ -3,11 +3,12 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
+
6
7
  import { Platform } from 'react-native';
7
8
  export function createTimings(startTime, responseStartTime, responseEndTime) {
8
9
  const firstByte = formatTiming(startTime, startTime, responseStartTime);
9
- const download = formatTiming(startTime, responseStartTime, responseEndTime); // needed for iOS, simply total duration from start to end
10
-
10
+ const download = formatTiming(startTime, responseStartTime, responseEndTime);
11
+ // needed for iOS, simply total duration from start to end
11
12
  const fetch = formatTiming(startTime, startTime, responseEndTime);
12
13
  return {
13
14
  firstByte,
@@ -15,12 +16,12 @@ export function createTimings(startTime, responseStartTime, responseEndTime) {
15
16
  fetch
16
17
  };
17
18
  }
19
+
18
20
  /**
19
21
  * @param origin Start time (absolute) of the request
20
22
  * @param start Start time (absolute) of the timing
21
23
  * @param end End time (absolute) of the timing
22
24
  */
23
-
24
25
  function formatTiming(origin, start, end) {
25
26
  return {
26
27
  duration: timeToNanos(end - start),
@@ -29,7 +30,6 @@ function formatTiming(origin, start, end) {
29
30
  startTime: Platform.OS === 'ios' ? timeToNanos(start) : timeToNanos(start - origin)
30
31
  };
31
32
  }
32
-
33
33
  function timeToNanos(durationMs) {
34
34
  return +(durationMs * 1e6).toFixed(0);
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["resourceTiming.ts"],"names":["Platform","createTimings","startTime","responseStartTime","responseEndTime","firstByte","formatTiming","download","fetch","origin","start","end","duration","timeToNanos","OS","durationMs","toFixed"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,QAAT,QAAyB,cAAzB;AAuBA,OAAO,SAASC,aAAT,CACHC,SADG,EAEHC,iBAFG,EAGHC,eAHG,EAIY;AACf,QAAMC,SAAS,GAAGC,YAAY,CAACJ,SAAD,EAAYA,SAAZ,EAAuBC,iBAAvB,CAA9B;AACA,QAAMI,QAAQ,GAAGD,YAAY,CACzBJ,SADyB,EAEzBC,iBAFyB,EAGzBC,eAHyB,CAA7B,CAFe,CAOf;;AACA,QAAMI,KAAK,GAAGF,YAAY,CAACJ,SAAD,EAAYA,SAAZ,EAAuBE,eAAvB,CAA1B;AAEA,SAAO;AACHC,IAAAA,SADG;AAEHE,IAAAA,QAFG;AAGHC,IAAAA;AAHG,GAAP;AAKH;AAED;AACA;AACA;AACA;AACA;;AACA,SAASF,YAAT,CAAsBG,MAAtB,EAAsCC,KAAtC,EAAqDC,GAArD,EAA0E;AACtE,SAAO;AACHC,IAAAA,QAAQ,EAAEC,WAAW,CAACF,GAAG,GAAGD,KAAP,CADlB;AAEH;AACA;AACAR,IAAAA,SAAS,EACLF,QAAQ,CAACc,EAAT,KAAgB,KAAhB,GACMD,WAAW,CAACH,KAAD,CADjB,GAEMG,WAAW,CAACH,KAAK,GAAGD,MAAT;AAPlB,GAAP;AASH;;AAED,SAASI,WAAT,CAAqBE,UAArB,EAAiD;AAC7C,SAAO,CAAC,CAACA,UAAU,GAAG,GAAd,EAAmBC,OAAnB,CAA2B,CAA3B,CAAR;AACH","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { Platform } from 'react-native';\n\ninterface Timing {\n /**\n * Time relative (absolute in case of iOS) to some point, in ns.\n */\n startTime: number;\n /**\n * Duration in ns.\n */\n duration: number;\n}\n\ninterface ResourceTimings {\n // unlike in Performance API it is not the time until request\n // starts (requestStart, before it can be connect, SSL, DNS),\n // but the time until the response is first seen\n firstByte: Timing;\n download: Timing;\n // required by iOS, total timing from the beginning to the end\n fetch: Timing;\n}\n\nexport function createTimings(\n startTime: number,\n responseStartTime: number,\n responseEndTime: number\n): ResourceTimings {\n const firstByte = formatTiming(startTime, startTime, responseStartTime);\n const download = formatTiming(\n startTime,\n responseStartTime,\n responseEndTime\n );\n // needed for iOS, simply total duration from start to end\n const fetch = formatTiming(startTime, startTime, responseEndTime);\n\n return {\n firstByte,\n download,\n fetch\n };\n}\n\n/**\n * @param origin Start time (absolute) of the request\n * @param start Start time (absolute) of the timing\n * @param end End time (absolute) of the timing\n */\nfunction formatTiming(origin: number, start: number, end: number): Timing {\n return {\n duration: timeToNanos(end - start),\n // if it is Android, startTime should be relative to the origin,\n // if it is iOS - absolute (unix timestamp)\n startTime:\n Platform.OS === 'ios'\n ? timeToNanos(start)\n : timeToNanos(start - origin)\n };\n}\n\nfunction timeToNanos(durationMs: number): number {\n return +(durationMs * 1e6).toFixed(0);\n}\n"]}
1
+ {"version":3,"names":["Platform","createTimings","startTime","responseStartTime","responseEndTime","firstByte","formatTiming","download","fetch","origin","start","end","duration","timeToNanos","OS","durationMs","toFixed"],"sourceRoot":"../../../../../../../../src","sources":["rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AAuBvC,OAAO,SAASC,aAAaA,CACzBC,SAAiB,EACjBC,iBAAyB,EACzBC,eAAuB,EACR;EACf,MAAMC,SAAS,GAAGC,YAAY,CAACJ,SAAS,EAAEA,SAAS,EAAEC,iBAAiB,CAAC;EACvE,MAAMI,QAAQ,GAAGD,YAAY,CACzBJ,SAAS,EACTC,iBAAiB,EACjBC,eACJ,CAAC;EACD;EACA,MAAMI,KAAK,GAAGF,YAAY,CAACJ,SAAS,EAAEA,SAAS,EAAEE,eAAe,CAAC;EAEjE,OAAO;IACHC,SAAS;IACTE,QAAQ;IACRC;EACJ,CAAC;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASF,YAAYA,CAACG,MAAc,EAAEC,KAAa,EAAEC,GAAW,EAAU;EACtE,OAAO;IACHC,QAAQ,EAAEC,WAAW,CAACF,GAAG,GAAGD,KAAK,CAAC;IAClC;IACA;IACAR,SAAS,EACLF,QAAQ,CAACc,EAAE,KAAK,KAAK,GACfD,WAAW,CAACH,KAAK,CAAC,GAClBG,WAAW,CAACH,KAAK,GAAGD,MAAM;EACxC,CAAC;AACL;AAEA,SAASI,WAAWA,CAACE,UAAkB,EAAU;EAC7C,OAAO,CAAC,CAACA,UAAU,GAAG,GAAG,EAAEC,OAAO,CAAC,CAAC,CAAC;AACzC","ignoreList":[]}
@@ -3,24 +3,23 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
+
6
7
  import { InternalLog } from '../../../../../InternalLog';
7
8
  import { SdkVerbosity } from '../../../../../SdkVerbosity';
8
9
  // matches what is between the first "://" and the next "/", ":" or whitespace
9
10
  const hostRegex = '^.+://([^:/\\s]+)';
11
+
10
12
  /**
11
13
  * Returns the host from an URL.
12
14
  * @returns the host (without the port) or null if could not cast the URL as host
13
15
  */
14
-
15
16
  export const URLHostParser = url => {
16
17
  try {
17
18
  const matchedHost = url.match(hostRegex);
18
-
19
19
  if (matchedHost === null) {
20
20
  return null;
21
- } // [0] is the input, [1] is the captured group
22
-
23
-
21
+ }
22
+ // [0] is the input, [1] is the captured group
24
23
  return matchedHost[1];
25
24
  } catch (e) {
26
25
  InternalLog.log(`Impossible to cast ${url} as URL`, SdkVerbosity.WARN);
@@ -1 +1 @@
1
- {"version":3,"sources":["URLHostParser.ts"],"names":["InternalLog","SdkVerbosity","hostRegex","URLHostParser","url","matchedHost","match","e","log","WARN"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,4BAA5B;AACA,SAASC,YAAT,QAA6B,6BAA7B;AAGA;AACA,MAAMC,SAAS,GAAG,mBAAlB;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAIC,GAAD,IAAkC;AAC3D,MAAI;AACA,UAAMC,WAAW,GAAGD,GAAG,CAACE,KAAJ,CAAUJ,SAAV,CAApB;;AACA,QAAIG,WAAW,KAAK,IAApB,EAA0B;AACtB,aAAO,IAAP;AACH,KAJD,CAKA;;;AACA,WAAOA,WAAW,CAAC,CAAD,CAAlB;AACH,GAPD,CAOE,OAAOE,CAAP,EAAU;AACRP,IAAAA,WAAW,CAACQ,GAAZ,CAAiB,sBAAqBJ,GAAI,SAA1C,EAAoDH,YAAY,CAACQ,IAAjE;AACA,WAAO,IAAP;AACH;AACJ,CAZM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../../SdkVerbosity';\nimport type { Hostname } from '../../distributedTracing/firstPartyHosts';\n\n// matches what is between the first \"://\" and the next \"/\", \":\" or whitespace\nconst hostRegex = '^.+://([^:/\\\\s]+)';\n\n/**\n * Returns the host from an URL.\n * @returns the host (without the port) or null if could not cast the URL as host\n */\nexport const URLHostParser = (url: string): Hostname | null => {\n try {\n const matchedHost = url.match(hostRegex);\n if (matchedHost === null) {\n return null;\n }\n // [0] is the input, [1] is the captured group\n return matchedHost[1] as Hostname;\n } catch (e) {\n InternalLog.log(`Impossible to cast ${url} as URL`, SdkVerbosity.WARN);\n return null;\n }\n};\n"]}
1
+ {"version":3,"names":["InternalLog","SdkVerbosity","hostRegex","URLHostParser","url","matchedHost","match","e","log","WARN"],"sourceRoot":"../../../../../../../src","sources":["rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,4BAA4B;AACxD,SAASC,YAAY,QAAQ,6BAA6B;AAG1D;AACA,MAAMC,SAAS,GAAG,mBAAmB;;AAErC;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAIC,GAAW,IAAsB;EAC3D,IAAI;IACA,MAAMC,WAAW,GAAGD,GAAG,CAACE,KAAK,CAACJ,SAAS,CAAC;IACxC,IAAIG,WAAW,KAAK,IAAI,EAAE;MACtB,OAAO,IAAI;IACf;IACA;IACA,OAAOA,WAAW,CAAC,CAAC,CAAC;EACzB,CAAC,CAAC,OAAOE,CAAC,EAAE;IACRP,WAAW,CAACQ,GAAG,CAAC,sBAAsBJ,GAAG,SAAS,EAAEH,YAAY,CAACQ,IAAI,CAAC;IACtE,OAAO,IAAI;EACf;AACJ,CAAC","ignoreList":[]}
@@ -1,10 +1,9 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
1
  /*
4
2
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
5
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
6
4
  * Copyright 2016-Present Datadog, Inc.
7
5
  */
6
+
8
7
  import Timer from '../../../../../utils/Timer';
9
8
  import { getTracingHeaders } from '../../distributedTracing/distributedTracingHeaders';
10
9
  import { getTracingAttributes } from '../../distributedTracing/distributedTracing';
@@ -13,57 +12,41 @@ import { RequestProxy } from '../interfaces/RequestProxy';
13
12
  import { URLHostParser } from './URLHostParser';
14
13
  import { calculateResponseSize } from './responseSize';
15
14
  const RESPONSE_START_LABEL = 'response_start';
16
-
17
15
  /**
18
16
  * Proxies XMLHttpRequest to track resources.
19
17
  */
20
18
  export class XHRProxy extends RequestProxy {
21
19
  constructor(providers) {
22
20
  super();
23
-
24
- _defineProperty(this, "providers", void 0);
25
-
26
- _defineProperty(this, "onTrackingStart", context => {
27
- XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;
28
- XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;
29
- XHRProxy.originalXhrSetRequestHeader = this.providers.xhrType.prototype.setRequestHeader;
30
- proxyRequests(this.providers, context);
31
- });
32
-
33
- _defineProperty(this, "onTrackingStop", () => {
34
- this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;
35
- this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;
36
- this.providers.xhrType.prototype.setRequestHeader = XHRProxy.originalXhrSetRequestHeader;
37
- });
38
-
39
21
  this.providers = providers;
40
22
  }
41
-
23
+ onTrackingStart = context => {
24
+ XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;
25
+ XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;
26
+ XHRProxy.originalXhrSetRequestHeader = this.providers.xhrType.prototype.setRequestHeader;
27
+ proxyRequests(this.providers, context);
28
+ };
29
+ onTrackingStop = () => {
30
+ this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;
31
+ this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;
32
+ this.providers.xhrType.prototype.setRequestHeader = XHRProxy.originalXhrSetRequestHeader;
33
+ };
42
34
  }
43
-
44
- _defineProperty(XHRProxy, "originalXhrOpen", void 0);
45
-
46
- _defineProperty(XHRProxy, "originalXhrSend", void 0);
47
-
48
- _defineProperty(XHRProxy, "originalXhrSetRequestHeader", void 0);
49
-
50
35
  const proxyRequests = (providers, context) => {
51
36
  proxyOpen(providers, context);
52
37
  proxySend(providers);
53
38
  proxySetRequestHeader(providers);
54
39
  };
55
-
56
40
  const proxyOpen = ({
57
41
  xhrType
58
42
  }, context) => {
59
43
  const originalXhrOpen = xhrType.prototype.open;
60
44
  const firstPartyHostsRegexMap = context.firstPartyHostsRegexMap;
61
45
  const tracingSamplingRate = context.tracingSamplingRate;
62
-
63
46
  xhrType.prototype.open = function (method, url) {
64
- const hostname = URLHostParser(url); // Keep track of the method and url
47
+ const hostname = URLHostParser(url);
48
+ // Keep track of the method and url
65
49
  // start time is tracked by the `send` method
66
-
67
50
  this._datadog_xhr = {
68
51
  method,
69
52
  url,
@@ -75,21 +58,18 @@ const proxyOpen = ({
75
58
  firstPartyHostsRegexMap,
76
59
  tracingSamplingRate
77
60
  })
78
- }; // eslint-disable-next-line prefer-rest-params
79
-
61
+ };
62
+ // eslint-disable-next-line prefer-rest-params
80
63
  return originalXhrOpen.apply(this, arguments);
81
64
  };
82
65
  };
83
-
84
66
  const proxySend = providers => {
85
67
  const xhrType = providers.xhrType;
86
68
  const originalXhrSend = xhrType.prototype.send;
87
-
88
69
  xhrType.prototype.send = function () {
89
70
  if (this._datadog_xhr) {
90
71
  // keep track of start time
91
72
  this._datadog_xhr.timer.start();
92
-
93
73
  const tracingHeaders = getTracingHeaders(this._datadog_xhr.tracingAttributes);
94
74
  tracingHeaders.forEach(({
95
75
  header,
@@ -98,17 +78,15 @@ const proxySend = providers => {
98
78
  this.setRequestHeader(header, value);
99
79
  });
100
80
  }
81
+ proxyOnReadyStateChange(this, providers);
101
82
 
102
- proxyOnReadyStateChange(this, providers); // eslint-disable-next-line prefer-rest-params
103
-
83
+ // eslint-disable-next-line prefer-rest-params
104
84
  return originalXhrSend.apply(this, arguments);
105
85
  };
106
86
  };
107
-
108
87
  const proxyOnReadyStateChange = (xhrProxy, providers) => {
109
88
  const xhrType = providers.xhrType;
110
89
  const originalOnreadystatechange = xhrProxy.onreadystatechange;
111
-
112
90
  xhrProxy.onreadystatechange = function () {
113
91
  if (xhrProxy.readyState === xhrType.DONE) {
114
92
  if (!xhrProxy._datadog_xhr.reported) {
@@ -118,14 +96,12 @@ const proxyOnReadyStateChange = (xhrProxy, providers) => {
118
96
  } else if (xhrProxy.readyState === xhrType.HEADERS_RECEIVED) {
119
97
  xhrProxy._datadog_xhr.timer.recordTick(RESPONSE_START_LABEL);
120
98
  }
121
-
122
99
  if (originalOnreadystatechange) {
123
100
  // eslint-disable-next-line prefer-rest-params
124
101
  originalOnreadystatechange.apply(xhrProxy, arguments);
125
102
  }
126
103
  };
127
104
  };
128
-
129
105
  const reportXhr = async (xhrProxy, resourceReporter) => {
130
106
  const responseSize = calculateResponseSize(xhrProxy);
131
107
  const context = xhrProxy._datadog_xhr;
@@ -152,30 +128,26 @@ const reportXhr = async (xhrProxy, resourceReporter) => {
152
128
  resourceContext: xhrProxy
153
129
  });
154
130
  };
155
-
156
131
  const proxySetRequestHeader = providers => {
157
132
  const xhrType = providers.xhrType;
158
133
  const originalXhrSetRequestHeader = xhrType.prototype.setRequestHeader;
159
-
160
134
  xhrType.prototype.setRequestHeader = function (header, value) {
161
135
  if (isDatadogCustomHeader(header)) {
162
136
  if (header === DATADOG_GRAPH_QL_OPERATION_NAME_HEADER) {
163
137
  this._datadog_xhr.graphql.operationName = value;
164
138
  return;
165
139
  }
166
-
167
140
  if (header === DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER) {
168
141
  this._datadog_xhr.graphql.operationType = value;
169
142
  return;
170
143
  }
171
-
172
144
  if (header === DATADOG_GRAPH_QL_VARIABLES_HEADER) {
173
145
  this._datadog_xhr.graphql.variables = value;
174
146
  return;
175
147
  }
176
- } // eslint-disable-next-line prefer-rest-params
177
-
148
+ }
178
149
 
150
+ // eslint-disable-next-line prefer-rest-params
179
151
  return originalXhrSetRequestHeader.apply(this, arguments);
180
152
  };
181
153
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["XHRProxy.ts"],"names":["Timer","getTracingHeaders","getTracingAttributes","DATADOG_GRAPH_QL_OPERATION_NAME_HEADER","DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER","DATADOG_GRAPH_QL_VARIABLES_HEADER","isDatadogCustomHeader","RequestProxy","URLHostParser","calculateResponseSize","RESPONSE_START_LABEL","XHRProxy","constructor","providers","context","originalXhrOpen","xhrType","prototype","open","originalXhrSend","send","originalXhrSetRequestHeader","setRequestHeader","proxyRequests","proxyOpen","proxySend","proxySetRequestHeader","firstPartyHostsRegexMap","tracingSamplingRate","method","url","hostname","_datadog_xhr","reported","timer","graphql","tracingAttributes","apply","arguments","start","tracingHeaders","forEach","header","value","proxyOnReadyStateChange","xhrProxy","originalOnreadystatechange","onreadystatechange","readyState","DONE","reportXhr","resourceReporter","HEADERS_RECEIVED","recordTick","responseSize","key","startTime","stop","reportResource","request","kind","graphqlAttributes","response","statusCode","status","size","timings","stopTime","responseStartTime","hasTickFor","timeAt","undefined","resourceContext","operationName","operationType","variables"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,4BAAlB;AACA,SAASC,iBAAT,QAAkC,oDAAlC;AAEA,SAASC,oBAAT,QAAqC,6CAArC;AACA,SACIC,sCADJ,EAEIC,sCAFJ,EAGIC,iCAHJ,EAIIC,qBAJJ,QAKO,8BALP;AAOA,SAASC,YAAT,QAA6B,4BAA7B;AAGA,SAASC,aAAT,QAA8B,iBAA9B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B,CAACoC,MAAD,CAAzB,EAAmC;AAC/B,UAAIA,MAAM,KAAKvC,sCAAf,EAAuD;AACnD,aAAK6B,YAAL,CAAkBG,OAAlB,CAA0BsC,aAA1B,GAA0C9B,KAA1C;AACA;AACH;;AACD,UAAID,MAAM,KAAKtC,sCAAf,EAAuD;AACnD,aAAK4B,YAAL,CAAkBG,OAAlB,CAA0BuC,aAA1B,GAA0C/B,KAA1C;AACA;AACH;;AACD,UAAID,MAAM,KAAKrC,iCAAf,EAAkD;AAC9C,aAAK2B,YAAL,CAAkBG,OAAlB,CAA0BwC,SAA1B,GAAsChC,KAAtC;AACA;AACH;AACJ,KAdH,CAgBE;;;AACA,WAAOtB,2BAA2B,CAACgB,KAA5B,CAAkC,IAAlC,EAAwCC,SAAxC,CAAP;AACH,GAtBD;AAuBH,CA3BD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport Timer from '../../../../../utils/Timer';\nimport { getTracingHeaders } from '../../distributedTracing/distributedTracingHeaders';\nimport type { DdRumResourceTracingAttributes } from '../../distributedTracing/distributedTracing';\nimport { getTracingAttributes } from '../../distributedTracing/distributedTracing';\nimport {\n DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,\n DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,\n DATADOG_GRAPH_QL_VARIABLES_HEADER,\n isDatadogCustomHeader\n} from '../../graphql/graphqlHeaders';\nimport type { RequestProxyOptions } from '../interfaces/RequestProxy';\nimport { RequestProxy } from '../interfaces/RequestProxy';\n\nimport type { ResourceReporter } from './DatadogRumResource/ResourceReporter';\nimport { URLHostParser } from './URLHostParser';\nimport { calculateResponseSize } from './responseSize';\n\nconst RESPONSE_START_LABEL = 'response_start';\n\ninterface DdRumXhr extends XMLHttpRequest {\n _datadog_xhr: DdRumXhrContext;\n}\n\ninterface DdRumXhrContext {\n graphql: {\n operationType?: string;\n operationName?: string;\n variables?: string;\n };\n method: string;\n url: string;\n reported: boolean;\n timer: Timer;\n tracingAttributes: DdRumResourceTracingAttributes;\n}\n\ninterface XHRProxyProviders {\n xhrType: typeof XMLHttpRequest;\n resourceReporter: ResourceReporter;\n}\n\n/**\n * Proxies XMLHttpRequest to track resources.\n */\nexport class XHRProxy extends RequestProxy {\n private providers: XHRProxyProviders;\n private static originalXhrOpen: typeof XMLHttpRequest.prototype.open;\n private static originalXhrSend: typeof XMLHttpRequest.prototype.send;\n private static originalXhrSetRequestHeader: typeof XMLHttpRequest.prototype.setRequestHeader;\n\n constructor(providers: XHRProxyProviders) {\n super();\n this.providers = providers;\n }\n\n onTrackingStart = (context: RequestProxyOptions) => {\n XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;\n XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;\n XHRProxy.originalXhrSetRequestHeader = this.providers.xhrType.prototype.setRequestHeader;\n proxyRequests(this.providers, context);\n };\n\n onTrackingStop = () => {\n this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;\n this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;\n this.providers.xhrType.prototype.setRequestHeader =\n XHRProxy.originalXhrSetRequestHeader;\n };\n}\n\nconst proxyRequests = (\n providers: XHRProxyProviders,\n context: RequestProxyOptions\n): void => {\n proxyOpen(providers, context);\n proxySend(providers);\n proxySetRequestHeader(providers);\n};\n\nconst proxyOpen = (\n { xhrType }: XHRProxyProviders,\n context: RequestProxyOptions\n): void => {\n const originalXhrOpen = xhrType.prototype.open;\n const firstPartyHostsRegexMap = context.firstPartyHostsRegexMap;\n const tracingSamplingRate = context.tracingSamplingRate;\n\n xhrType.prototype.open = function (\n this: DdRumXhr,\n method: string,\n url: string\n ) {\n const hostname = URLHostParser(url);\n // Keep track of the method and url\n // start time is tracked by the `send` method\n this._datadog_xhr = {\n method,\n url,\n reported: false,\n timer: new Timer(),\n graphql: {},\n tracingAttributes: getTracingAttributes({\n hostname,\n firstPartyHostsRegexMap,\n tracingSamplingRate\n })\n };\n // eslint-disable-next-line prefer-rest-params\n return originalXhrOpen.apply(this, arguments as any);\n };\n};\n\nconst proxySend = (providers: XHRProxyProviders): void => {\n const xhrType = providers.xhrType;\n const originalXhrSend = xhrType.prototype.send;\n\n xhrType.prototype.send = function (this: DdRumXhr) {\n if (this._datadog_xhr) {\n // keep track of start time\n this._datadog_xhr.timer.start();\n\n const tracingHeaders = getTracingHeaders(\n this._datadog_xhr.tracingAttributes\n );\n tracingHeaders.forEach(({ header, value }) => {\n this.setRequestHeader(header, value);\n });\n }\n\n proxyOnReadyStateChange(this, providers);\n\n // eslint-disable-next-line prefer-rest-params\n return originalXhrSend.apply(this, arguments as any);\n };\n};\n\nconst proxyOnReadyStateChange = (\n xhrProxy: DdRumXhr,\n providers: XHRProxyProviders\n): void => {\n const xhrType = providers.xhrType;\n const originalOnreadystatechange = xhrProxy.onreadystatechange;\n\n xhrProxy.onreadystatechange = function () {\n if (xhrProxy.readyState === xhrType.DONE) {\n if (!xhrProxy._datadog_xhr.reported) {\n reportXhr(xhrProxy, providers.resourceReporter);\n xhrProxy._datadog_xhr.reported = true;\n }\n } else if (xhrProxy.readyState === xhrType.HEADERS_RECEIVED) {\n xhrProxy._datadog_xhr.timer.recordTick(RESPONSE_START_LABEL);\n }\n\n if (originalOnreadystatechange) {\n // eslint-disable-next-line prefer-rest-params\n originalOnreadystatechange.apply(xhrProxy, arguments as any);\n }\n };\n};\n\nconst reportXhr = async (\n xhrProxy: DdRumXhr,\n resourceReporter: ResourceReporter\n): Promise<void> => {\n const responseSize = calculateResponseSize(xhrProxy);\n\n const context = xhrProxy._datadog_xhr;\n\n const key = `${context.timer.startTime}/${context.method}`;\n\n context.timer.stop();\n\n resourceReporter.reportResource({\n key,\n request: {\n method: context.method,\n url: context.url,\n kind: 'xhr'\n },\n graphqlAttributes: context.graphql,\n tracingAttributes: context.tracingAttributes,\n response: {\n statusCode: xhrProxy.status,\n size: responseSize\n },\n timings: {\n startTime: context.timer.startTime,\n stopTime: context.timer.stopTime,\n responseStartTime: context.timer.hasTickFor(RESPONSE_START_LABEL)\n ? context.timer.timeAt(RESPONSE_START_LABEL)\n : undefined\n },\n resourceContext: xhrProxy\n });\n};\n\nconst proxySetRequestHeader = (providers: XHRProxyProviders): void => {\n const xhrType = providers.xhrType;\n const originalXhrSetRequestHeader = xhrType.prototype.setRequestHeader;\n\n xhrType.prototype.setRequestHeader = function (\n this: DdRumXhr,\n header: string,\n value: string\n ) {\n if (isDatadogCustomHeader(header)) {\n if (header === DATADOG_GRAPH_QL_OPERATION_NAME_HEADER) {\n this._datadog_xhr.graphql.operationName = value;\n return;\n }\n if (header === DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER) {\n this._datadog_xhr.graphql.operationType = value;\n return;\n }\n if (header === DATADOG_GRAPH_QL_VARIABLES_HEADER) {\n this._datadog_xhr.graphql.variables = value;\n return;\n }\n }\n\n // eslint-disable-next-line prefer-rest-params\n return originalXhrSetRequestHeader.apply(this, arguments as any);\n };\n};\n"]}
1
+ {"version":3,"names":["Timer","getTracingHeaders","getTracingAttributes","DATADOG_GRAPH_QL_OPERATION_NAME_HEADER","DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER","DATADOG_GRAPH_QL_VARIABLES_HEADER","isDatadogCustomHeader","RequestProxy","URLHostParser","calculateResponseSize","RESPONSE_START_LABEL","XHRProxy","constructor","providers","onTrackingStart","context","originalXhrOpen","xhrType","prototype","open","originalXhrSend","send","originalXhrSetRequestHeader","setRequestHeader","proxyRequests","onTrackingStop","proxyOpen","proxySend","proxySetRequestHeader","firstPartyHostsRegexMap","tracingSamplingRate","method","url","hostname","_datadog_xhr","reported","timer","graphql","tracingAttributes","apply","arguments","start","tracingHeaders","forEach","header","value","proxyOnReadyStateChange","xhrProxy","originalOnreadystatechange","onreadystatechange","readyState","DONE","reportXhr","resourceReporter","HEADERS_RECEIVED","recordTick","responseSize","key","startTime","stop","reportResource","request","kind","graphqlAttributes","response","statusCode","status","size","timings","stopTime","responseStartTime","hasTickFor","timeAt","undefined","resourceContext","operationName","operationType","variables"],"sourceRoot":"../../../../../../../src","sources":["rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,4BAA4B;AAC9C,SAASC,iBAAiB,QAAQ,oDAAoD;AAEtF,SAASC,oBAAoB,QAAQ,6CAA6C;AAClF,SACIC,sCAAsC,EACtCC,sCAAsC,EACtCC,iCAAiC,EACjCC,qBAAqB,QAClB,8BAA8B;AAErC,SAASC,YAAY,QAAQ,4BAA4B;AAGzD,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,qBAAqB,QAAQ,gBAAgB;AAEtD,MAAMC,oBAAoB,GAAG,gBAAgB;AAwB7C;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,SAASJ,YAAY,CAAC;EAMvCK,WAAWA,CAACC,SAA4B,EAAE;IACtC,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC9B;EAEAC,eAAe,GAAIC,OAA4B,IAAK;IAChDJ,QAAQ,CAACK,eAAe,GAAG,IAAI,CAACH,SAAS,CAACI,OAAO,CAACC,SAAS,CAACC,IAAI;IAChER,QAAQ,CAACS,eAAe,GAAG,IAAI,CAACP,SAAS,CAACI,OAAO,CAACC,SAAS,CAACG,IAAI;IAChEV,QAAQ,CAACW,2BAA2B,GAAG,IAAI,CAACT,SAAS,CAACI,OAAO,CAACC,SAAS,CAACK,gBAAgB;IACxFC,aAAa,CAAC,IAAI,CAACX,SAAS,EAAEE,OAAO,CAAC;EAC1C,CAAC;EAEDU,cAAc,GAAGA,CAAA,KAAM;IACnB,IAAI,CAACZ,SAAS,CAACI,OAAO,CAACC,SAAS,CAACC,IAAI,GAAGR,QAAQ,CAACK,eAAe;IAChE,IAAI,CAACH,SAAS,CAACI,OAAO,CAACC,SAAS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