@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,10 +3,11 @@
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
  export default class NoOpEventsInterceptor {
7
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
- interceptOnPress(..._args) {// NoOp
9
+ interceptOnPress(..._args) {
10
+ // NoOp
9
11
  }
10
-
11
12
  }
12
13
  //# sourceMappingURL=NoOpEventsInterceptor.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["NoOpEventsInterceptor.tsx"],"names":["NoOpEventsInterceptor","interceptOnPress","_args"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAIA,eAAe,MAAMA,qBAAN,CAAyD;AACpE;AACAC,EAAAA,gBAAgB,CAAC,GAAGC,KAAJ,EAAwB,CACpC;AACH;;AAJmE","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 EventsInterceptor from './EventsInterceptor';\n\nexport default class NoOpEventsInterceptor implements EventsInterceptor {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interceptOnPress(..._args: any[]): void {\n // NoOp\n }\n}\n"]}
1
+ {"version":3,"names":["NoOpEventsInterceptor","interceptOnPress","_args"],"sourceRoot":"../../../../../src","sources":["rum/instrumentation/interactionTracking/NoOpEventsInterceptor.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAIA,eAAe,MAAMA,qBAAqB,CAA8B;EACpE;EACAC,gBAAgBA,CAAC,GAAGC,KAAY,EAAQ;IACpC;EAAA;AAER","ignoreList":[]}
@@ -15,19 +15,15 @@ export const areObjectShallowEqual = (objectA, objectB) => {
15
15
  if (!objectA || !objectB) {
16
16
  return objectA === objectB;
17
17
  }
18
-
19
18
  const keys = Object.keys(objectA);
20
-
21
19
  if (keys.length !== Object.keys(objectB).length) {
22
20
  return false;
23
21
  }
24
-
25
22
  for (const key of keys) {
26
23
  if (objectA[key] !== objectB[key]) {
27
24
  return false;
28
25
  }
29
26
  }
30
-
31
27
  return true;
32
28
  };
33
29
  //# sourceMappingURL=ShallowObjectEqualityChecker.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["ShallowObjectEqualityChecker.ts"],"names":["areObjectShallowEqual","objectA","objectB","keys","Object","length","key"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,qBAAqB,GAAG,CACjCC,OADiC,EAEjCC,OAFiC,KAGvB;AACV;AACA,MAAI,CAACD,OAAD,IAAY,CAACC,OAAjB,EAA0B;AACtB,WAAOD,OAAO,KAAKC,OAAnB;AACH;;AAED,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAYF,OAAZ,CAAb;;AACA,MAAIE,IAAI,CAACE,MAAL,KAAgBD,MAAM,CAACD,IAAP,CAAYD,OAAZ,EAAqBG,MAAzC,EAAiD;AAC7C,WAAO,KAAP;AACH;;AACD,OAAK,MAAMC,GAAX,IAAkBH,IAAlB,EAAwB;AACpB,QAAIF,OAAO,CAACK,GAAD,CAAP,KAAiBJ,OAAO,CAACI,GAAD,CAA5B,EAAmC;AAC/B,aAAO,KAAP;AACH;AACJ;;AACD,SAAO,IAAP;AACH,CAnBM","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\n/**\n * Does a shallow comparison between 2 objects.\n *\n * In some rare cases, one of the objects can be `undefined` or `null`.\n * This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.\n */\nexport const areObjectShallowEqual = (\n objectA: Record<string, unknown> | undefined | null,\n objectB: Record<string, unknown> | undefined | null\n): boolean => {\n // Handle edge case when one object is `undefined` or `null`\n if (!objectA || !objectB) {\n return objectA === objectB;\n }\n\n const keys = Object.keys(objectA);\n if (keys.length !== Object.keys(objectB).length) {\n return false;\n }\n for (const key of keys) {\n if (objectA[key] !== objectB[key]) {\n return false;\n }\n }\n return true;\n};\n"]}
1
+ {"version":3,"names":["areObjectShallowEqual","objectA","objectB","keys","Object","length","key"],"sourceRoot":"../../../../../src","sources":["rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,qBAAqB,GAAGA,CACjCC,OAAmD,EACnDC,OAAmD,KACzC;EACV;EACA,IAAI,CAACD,OAAO,IAAI,CAACC,OAAO,EAAE;IACtB,OAAOD,OAAO,KAAKC,OAAO;EAC9B;EAEA,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACF,OAAO,CAAC;EACjC,IAAIE,IAAI,CAACE,MAAM,KAAKD,MAAM,CAACD,IAAI,CAACD,OAAO,CAAC,CAACG,MAAM,EAAE;IAC7C,OAAO,KAAK;EAChB;EACA,KAAK,MAAMC,GAAG,IAAIH,IAAI,EAAE;IACpB,IAAIF,OAAO,CAACK,GAAG,CAAC,KAAKJ,OAAO,CAACI,GAAG,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;EACJ;EACA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
@@ -3,46 +3,48 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
- export const getJsxRuntime = () => {
6
+
7
+ export const getJsxRuntimes = () => {
7
8
  // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
8
- const [major, minor] = require('react/package.json').version.split('.'); // We need to check on the version of React before requiring 'react/jsx-runtime') as
9
+ const [major, minor] = require('react/package.json').version.split('.');
10
+ // We need to check on the version of React before requiring 'react/jsx-runtime') as
9
11
  // it might crash other exports if the export does not exist (even if there is a try/catch).
10
12
  // See: https://github.com/facebook/metro/issues/836
11
-
12
-
13
13
  if (!isJsxExportedInReactVersion(major, minor)) {
14
14
  throw new Error('React version does not support new jsx transform');
15
- } // /!\/!\/!\/!\/!\/!\
15
+ }
16
+
17
+ // /!\/!\/!\/!\/!\/!\
16
18
  // We have to use inline require here because older React versions (below 16.14) don't have jsx-runtime.
17
19
  // metro does not support dynamic require, so 'react/jsx-runtime' is replaced by 'react' on postinstall
18
20
  // when react is equal or above 16.14 to avoid this require call to fail during the import phase and then
19
21
  // disable all further imports.
20
22
  // /!\/!\/!\/!\/!\/!\
21
23
  //
22
- // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
23
-
24
+ let jsxDevRuntime;
25
+ if (__DEV__) {
26
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
27
+ jsxDevRuntime = require('react/jsx-dev-runtime');
28
+ }
24
29
 
30
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
25
31
  const jsxRuntime = require('react/jsx-runtime');
26
-
27
- if (!jsxRuntime.jsx) {
32
+ if (!jsxRuntime.jsx && !__DEV__) {
28
33
  throw new Error('React jsx runtime does not export new jsx transform');
29
34
  }
30
-
31
- return jsxRuntime;
35
+ return [jsxRuntime, jsxDevRuntime];
32
36
  };
37
+
33
38
  /**
34
39
  * JSX Transform is available for React 16.14.0 (last React 16 version) and above
35
40
  */
36
-
37
41
  const isJsxExportedInReactVersion = (major, minor) => {
38
42
  if (Number(major) > 16) {
39
43
  return true;
40
44
  }
41
-
42
45
  if (Number(major) === 16 && Number(minor) > 13) {
43
46
  return true;
44
47
  }
45
-
46
48
  return false;
47
49
  };
48
50
  //# sourceMappingURL=getJsxRuntime.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["getJsxRuntime.ts"],"names":["getJsxRuntime","major","minor","require","version","split","isJsxExportedInReactVersion","Error","jsxRuntime","jsx","Number"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,MAAM;AAC/B;AACA,QAAM,CAACC,KAAD,EAAQC,KAAR,IAAiBC,OAAO,CAAC,oBAAD,CAAP,CAA8BC,OAA9B,CAAsCC,KAAtC,CAA4C,GAA5C,CAAvB,CAF+B,CAG/B;AACA;AACA;;;AACA,MAAI,CAACC,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAAhC,EAAgD;AAC5C,UAAM,IAAIK,KAAJ,CAAU,kDAAV,CAAN;AACH,GAR8B,CAU/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAMC,UAAU,GAAGL,OAAO,CAAC,mBAAD,CAA1B;;AACA,MAAI,CAACK,UAAU,CAACC,GAAhB,EAAqB;AACjB,UAAM,IAAIF,KAAJ,CAAU,qDAAV,CAAN;AACH;;AACD,SAAOC,UAAP;AACH,CAvBM;AAyBP;AACA;AACA;;AACA,MAAMF,2BAA2B,GAAG,CAACL,KAAD,EAAgBC,KAAhB,KAA2C;AAC3E,MAAIQ,MAAM,CAACT,KAAD,CAAN,GAAgB,EAApB,EAAwB;AACpB,WAAO,IAAP;AACH;;AACD,MAAIS,MAAM,CAACT,KAAD,CAAN,KAAkB,EAAlB,IAAwBS,MAAM,CAACR,KAAD,CAAN,GAAgB,EAA5C,EAAgD;AAC5C,WAAO,IAAP;AACH;;AACD,SAAO,KAAP;AACH,CARD","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\nexport const getJsxRuntime = () => {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const [major, minor] = require('react/package.json').version.split('.');\n // We need to check on the version of React before requiring 'react/jsx-runtime') as\n // it might crash other exports if the export does not exist (even if there is a try/catch).\n // See: https://github.com/facebook/metro/issues/836\n if (!isJsxExportedInReactVersion(major, minor)) {\n throw new Error('React version does not support new jsx transform');\n }\n\n // /!\\/!\\/!\\/!\\/!\\/!\\\n // We have to use inline require here because older React versions (below 16.14) don't have jsx-runtime.\n // metro does not support dynamic require, so 'react/jsx-runtime' is replaced by 'react' on postinstall\n // when react is equal or above 16.14 to avoid this require call to fail during the import phase and then\n // disable all further imports.\n // /!\\/!\\/!\\/!\\/!\\/!\\\n //\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const jsxRuntime = require('react/jsx-runtime');\n if (!jsxRuntime.jsx) {\n throw new Error('React jsx runtime does not export new jsx transform');\n }\n return jsxRuntime;\n};\n\n/**\n * JSX Transform is available for React 16.14.0 (last React 16 version) and above\n */\nconst isJsxExportedInReactVersion = (major: string, minor: string): boolean => {\n if (Number(major) > 16) {\n return true;\n }\n if (Number(major) === 16 && Number(minor) > 13) {\n return true;\n }\n return false;\n};\n"]}
1
+ {"version":3,"names":["getJsxRuntimes","major","minor","require","version","split","isJsxExportedInReactVersion","Error","jsxDevRuntime","__DEV__","jsxRuntime","jsx","Number"],"sourceRoot":"../../../../../src","sources":["rum/instrumentation/interactionTracking/getJsxRuntime.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,cAAc,GAAGA,CAAA,KAAM;EAChC;EACA,MAAM,CAACC,KAAK,EAAEC,KAAK,CAAC,GAAGC,OAAO,CAAC,oBAAoB,CAAC,CAACC,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC;EACvE;EACA;EACA;EACA,IAAI,CAACC,2BAA2B,CAACL,KAAK,EAAEC,KAAK,CAAC,EAAE;IAC5C,MAAM,IAAIK,KAAK,CAAC,kDAAkD,CAAC;EACvE;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAIC,aAAa;EACjB,IAAIC,OAAO,EAAE;IACT;IACAD,aAAa,GAAGL,OAAO,CAAC,uBAAuB,CAAC;EACpD;;EAEA;EACA,MAAMO,UAAU,GAAGP,OAAO,CAAC,mBAAmB,CAAC;EAC/C,IAAI,CAACO,UAAU,CAACC,GAAG,IAAI,CAACF,OAAO,EAAE;IAC7B,MAAM,IAAIF,KAAK,CAAC,qDAAqD,CAAC;EAC1E;EAEA,OAAO,CAACG,UAAU,EAAEF,aAAa,CAAC;AACtC,CAAC;;AAED;AACA;AACA;AACA,MAAMF,2BAA2B,GAAGA,CAACL,KAAa,EAAEC,KAAa,KAAc;EAC3E,IAAIU,MAAM,CAACX,KAAK,CAAC,GAAG,EAAE,EAAE;IACpB,OAAO,IAAI;EACf;EACA,IAAIW,MAAM,CAACX,KAAK,CAAC,KAAK,EAAE,IAAIW,MAAM,CAACV,KAAK,CAAC,GAAG,EAAE,EAAE;IAC5C,OAAO,IAAI;EACf;EACA,OAAO,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -1,21 +1,20 @@
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 { InternalLog } from '../../../InternalLog';
9
8
  import { SdkVerbosity } from '../../../SdkVerbosity';
10
9
  import { firstPartyHostsRegexMapBuilder } from './distributedTracing/firstPartyHosts';
11
10
  import { ResourceReporter } from './requestProxy/XHRProxy/DatadogRumResource/ResourceReporter';
12
11
  import { filterDevResource } from './requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist';
13
12
  import { XHRProxy } from './requestProxy/XHRProxy/XHRProxy';
14
-
15
13
  /**
16
14
  * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
17
15
  */
18
16
  export class DdRumResourceTracking {
17
+ static isTracking = false;
19
18
  /**
20
19
  * Starts tracking resources and sends a RUM Resource event every time a network request is detected.
21
20
  */
@@ -28,7 +27,6 @@ export class DdRumResourceTracking {
28
27
  InternalLog.log('Datadog SDK is already tracking XHR resources', SdkVerbosity.WARN);
29
28
  return;
30
29
  }
31
-
32
30
  this.requestProxy = new XHRProxy({
33
31
  xhrType: XMLHttpRequest,
34
32
  resourceReporter: new ResourceReporter([filterDevResource])
@@ -40,22 +38,14 @@ export class DdRumResourceTracking {
40
38
  InternalLog.log('Datadog SDK is tracking XHR resources', SdkVerbosity.INFO);
41
39
  DdRumResourceTracking.isTracking = true;
42
40
  }
43
-
44
41
  static stopTracking() {
45
42
  if (DdRumResourceTracking.isTracking) {
46
43
  DdRumResourceTracking.isTracking = false;
47
-
48
44
  if (this.requestProxy) {
49
45
  this.requestProxy.onTrackingStop();
50
46
  }
51
-
52
47
  this.requestProxy = null;
53
48
  }
54
49
  }
55
-
56
50
  }
57
-
58
- _defineProperty(DdRumResourceTracking, "isTracking", false);
59
-
60
- _defineProperty(DdRumResourceTracking, "requestProxy", void 0);
61
51
  //# sourceMappingURL=DdRumResourceTracking.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumResourceTracking.tsx"],"names":["InternalLog","SdkVerbosity","firstPartyHostsRegexMapBuilder","ResourceReporter","filterDevResource","XHRProxy","DdRumResourceTracking","startTracking","tracingSamplingRate","firstPartyHosts","isTracking","log","WARN","requestProxy","xhrType","XMLHttpRequest","resourceReporter","onTrackingStart","firstPartyHostsRegexMap","INFO","stopTracking","onTrackingStop"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,sBAA5B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AAGA,SAASC,8BAAT,QAA+C,sCAA/C;AACA,SAASC,gBAAT,QAAiC,6DAAjC;AACA,SAASC,iBAAT,QAAkC,yEAAlC;AACA,SAASC,QAAT,QAAyB,kCAAzB;;AAGA;AACA;AACA;AACA,OAAO,MAAMC,qBAAN,CAA4B;AAI/B;AACJ;AACA;AACwB,SAAbC,aAAa,CAAC;AACjBC,IAAAA,mBADiB;AAEjBC,IAAAA;AAFiB,GAAD,EAMX;AACL;AACA,QAAIH,qBAAqB,CAACI,UAA1B,EAAsC;AAClCV,MAAAA,WAAW,CAACW,GAAZ,CACI,+CADJ,EAEIV,YAAY,CAACW,IAFjB;AAIA;AACH;;AAED,SAAKC,YAAL,GAAoB,IAAIR,QAAJ,CAAa;AAC7BS,MAAAA,OAAO,EAAEC,cADoB;AAE7BC,MAAAA,gBAAgB,EAAE,IAAIb,gBAAJ,CAAqB,CAACC,iBAAD,CAArB;AAFW,KAAb,CAApB;AAIA,SAAKS,YAAL,CAAkBI,eAAlB,CAAkC;AAC9BT,MAAAA,mBAD8B;AAE9BU,MAAAA,uBAAuB,EAAEhB,8BAA8B,CACnDO,eADmD;AAFzB,KAAlC;AAOAT,IAAAA,WAAW,CAACW,GAAZ,CACI,uCADJ,EAEIV,YAAY,CAACkB,IAFjB;AAIAb,IAAAA,qBAAqB,CAACI,UAAtB,GAAmC,IAAnC;AACH;;AAEkB,SAAZU,YAAY,GAAS;AACxB,QAAId,qBAAqB,CAACI,UAA1B,EAAsC;AAClCJ,MAAAA,qBAAqB,CAACI,UAAtB,GAAmC,KAAnC;;AACA,UAAI,KAAKG,YAAT,EAAuB;AACnB,aAAKA,YAAL,CAAkBQ,cAAlB;AACH;;AACD,WAAKR,YAAL,GAAoB,IAApB;AACH;AACJ;;AAjD8B;;gBAAtBP,qB,gBACmB,K;;gBADnBA,qB","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 } from '../../types';\n\nimport { firstPartyHostsRegexMapBuilder } from './distributedTracing/firstPartyHosts';\nimport { ResourceReporter } from './requestProxy/XHRProxy/DatadogRumResource/ResourceReporter';\nimport { filterDevResource } from './requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist';\nimport { XHRProxy } from './requestProxy/XHRProxy/XHRProxy';\nimport type { RequestProxy } from './requestProxy/interfaces/RequestProxy';\n\n/**\n * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.\n */\nexport class DdRumResourceTracking {\n private static isTracking = false;\n private static requestProxy: RequestProxy | null;\n\n /**\n * Starts tracking resources and sends a RUM Resource event every time a network request is detected.\n */\n static startTracking({\n tracingSamplingRate,\n firstPartyHosts\n }: {\n tracingSamplingRate: number;\n firstPartyHosts: FirstPartyHost[];\n }): void {\n // extra safety to avoid proxying the XHR class twice\n if (DdRumResourceTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking XHR resources',\n SdkVerbosity.WARN\n );\n return;\n }\n\n this.requestProxy = new XHRProxy({\n xhrType: XMLHttpRequest,\n resourceReporter: new ResourceReporter([filterDevResource])\n });\n this.requestProxy.onTrackingStart({\n tracingSamplingRate,\n firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder(\n firstPartyHosts\n )\n });\n\n InternalLog.log(\n 'Datadog SDK is tracking XHR resources',\n SdkVerbosity.INFO\n );\n DdRumResourceTracking.isTracking = true;\n }\n\n static stopTracking(): void {\n if (DdRumResourceTracking.isTracking) {\n DdRumResourceTracking.isTracking = false;\n if (this.requestProxy) {\n this.requestProxy.onTrackingStop();\n }\n this.requestProxy = null;\n }\n }\n}\n"]}
1
+ {"version":3,"names":["InternalLog","SdkVerbosity","firstPartyHostsRegexMapBuilder","ResourceReporter","filterDevResource","XHRProxy","DdRumResourceTracking","isTracking","startTracking","tracingSamplingRate","firstPartyHosts","log","WARN","requestProxy","xhrType","XMLHttpRequest","resourceReporter","onTrackingStart","firstPartyHostsRegexMap","INFO","stopTracking","onTrackingStop"],"sourceRoot":"../../../../../src","sources":["rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,sBAAsB;AAClD,SAASC,YAAY,QAAQ,uBAAuB;AAGpD,SAASC,8BAA8B,QAAQ,sCAAsC;AACrF,SAASC,gBAAgB,QAAQ,6DAA6D;AAC9F,SAASC,iBAAiB,QAAQ,yEAAyE;AAC3G,SAASC,QAAQ,QAAQ,kCAAkC;AAG3D;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,CAAC;EAC/B,OAAeC,UAAU,GAAG,KAAK;EAGjC;AACJ;AACA;EACI,OAAOC,aAAaA,CAAC;IACjBC,mBAAmB;IACnBC;EAIJ,CAAC,EAAQ;IACL;IACA,IAAIJ,qBAAqB,CAACC,UAAU,EAAE;MAClCP,WAAW,CAACW,GAAG,CACX,+CAA+C,EAC/CV,YAAY,CAACW,IACjB,CAAC;MACD;IACJ;IAEA,IAAI,CAACC,YAAY,GAAG,IAAIR,QAAQ,CAAC;MAC7BS,OAAO,EAAEC,cAAc;MACvBC,gBAAgB,EAAE,IAAIb,gBAAgB,CAAC,CAACC,iBAAiB,CAAC;IAC9D,CAAC,CAAC;IACF,IAAI,CAACS,YAAY,CAACI,eAAe,CAAC;MAC9BR,mBAAmB;MACnBS,uBAAuB,EAAEhB,8BAA8B,CACnDQ,eACJ;IACJ,CAAC,CAAC;IAEFV,WAAW,CAACW,GAAG,CACX,uCAAuC,EACvCV,YAAY,CAACkB,IACjB,CAAC;IACDb,qBAAqB,CAACC,UAAU,GAAG,IAAI;EAC3C;EAEA,OAAOa,YAAYA,CAAA,EAAS;IACxB,IAAId,qBAAqB,CAACC,UAAU,EAAE;MAClCD,qBAAqB,CAACC,UAAU,GAAG,KAAK;MACxC,IAAI,IAAI,CAACM,YAAY,EAAE;QACnB,IAAI,CAACA,YAAY,CAACQ,cAAc,CAAC,CAAC;MACtC;MACA,IAAI,CAACR,YAAY,GAAG,IAAI;IAC5B;EACJ;AACJ","ignoreList":[]}
@@ -1,5 +1,3 @@
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/).
@@ -9,12 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
9
7
  /**
10
8
  * Available formats for representing the {@link TracingIdentifier} as a string.
11
9
  */
12
- export let TracingIdFormat;
13
- /**
14
- * A {@link TracingIdentifier} used for Traces (128 bit).
15
- */
16
-
17
- (function (TracingIdFormat) {
10
+ export let TracingIdFormat = /*#__PURE__*/function (TracingIdFormat) {
18
11
  TracingIdFormat[TracingIdFormat["decimal"] = 0] = "decimal";
19
12
  TracingIdFormat[TracingIdFormat["lowDecimal"] = 1] = "lowDecimal";
20
13
  TracingIdFormat[TracingIdFormat["highDecimal"] = 2] = "highDecimal";
@@ -24,27 +17,36 @@ export let TracingIdFormat;
24
17
  TracingIdFormat[TracingIdFormat["paddedHex"] = 6] = "paddedHex";
25
18
  TracingIdFormat[TracingIdFormat["paddedLowHex"] = 7] = "paddedLowHex";
26
19
  TracingIdFormat[TracingIdFormat["paddedHighHex"] = 8] = "paddedHighHex";
27
- })(TracingIdFormat || (TracingIdFormat = {}));
20
+ return TracingIdFormat;
21
+ }({});
28
22
 
29
23
  /**
30
- * The tracing identifier type.
24
+ * A {@link TracingIdentifier} used for Traces (128 bit).
31
25
  */
32
- export let TracingIdType;
26
+
33
27
  /**
34
- * Value used to mask the low 64 bits of the trace identifier.
28
+ * A {@link TracingIdentifier} used for Spans (64 bit).
35
29
  */
36
30
 
37
- (function (TracingIdType) {
31
+ /**
32
+ * The tracing identifier type.
33
+ */
34
+ export let TracingIdType = /*#__PURE__*/function (TracingIdType) {
38
35
  TracingIdType[TracingIdType["trace"] = 0] = "trace";
39
36
  TracingIdType[TracingIdType["span"] = 1] = "span";
40
- })(TracingIdType || (TracingIdType = {}));
37
+ return TracingIdType;
38
+ }({});
41
39
 
40
+ /**
41
+ * Value used to mask the low 64 bits of the trace identifier.
42
+ */
42
43
  const LOW_64BIT_MASK = (BigInt('0xffffffff') << BigInt(32)) + BigInt('0xffffffff');
44
+
43
45
  /**
44
46
  * Value used to mask the low 32 bits of the trace identifier.
45
47
  */
46
-
47
48
  const LOW_32BIT_MASK = (BigInt('0xffff') << BigInt(16)) + BigInt('0xffff');
49
+
48
50
  /**
49
51
  * A {@link TracingIdentifier} is a unique UUID that can be 64bit or 128bit, and provides
50
52
  * convenient methods to represent it as a HEX or DECIMAL string, and it allows the masking
@@ -53,7 +55,6 @@ const LOW_32BIT_MASK = (BigInt('0xffff') << BigInt(16)) + BigInt('0xffff');
53
55
  * Create a new identifier by calling {@link TracingIdentifier.createTraceId()} or
54
56
  * {@link TracingIdentifier.createSpanId()}.
55
57
  */
56
-
57
58
  export class TracingIdentifier {
58
59
  /**
59
60
  * Read-only generated ID as a {@link bigint}.
@@ -70,100 +71,87 @@ export class TracingIdentifier {
70
71
  static createTraceId() {
71
72
  return new TracingIdentifier(TracingIdType.trace);
72
73
  }
74
+
73
75
  /**
74
76
  * Creates a new unique Span ID.
75
77
  * @returns the generated {@link SpanId}.
76
78
  */
77
-
78
-
79
79
  static createSpanId() {
80
80
  return new TracingIdentifier(TracingIdType.span);
81
81
  }
82
+
82
83
  /**
83
84
  * Private constructor to initialize the {@link TracingIdentifier} based on the given
84
85
  * {@link TracingIdType}.
85
86
  */
86
-
87
-
88
87
  constructor(type) {
89
- _defineProperty(this, "id", void 0);
90
-
91
- _defineProperty(this, "type", void 0);
92
-
93
88
  this.id = this.generateUUID(type);
94
89
  this.type = type;
95
90
  }
91
+
96
92
  /**
97
93
  * Generates a unique ID with the given format.
98
94
  * @param format - the desired format (64bit or 128bit).
99
95
  * @returns the generated UUID as a {@link bigint}.
100
96
  */
101
-
102
-
103
97
  generateUUID(type) {
104
98
  // Get the current Unix timestamp in seconds
105
- const unixSeconds = Math.floor(Date.now() / 1000); // Ensure the Unix timestamp is 32 bits
99
+ const unixSeconds = Math.floor(Date.now() / 1000);
106
100
 
107
- const unixSeconds32 = unixSeconds & 0xffffffff; // 32 bits of zero
101
+ // Ensure the Unix timestamp is 32 bits
102
+ const unixSeconds32 = unixSeconds & 0xffffffff;
108
103
 
109
- const zeros32 = 0; // Generate 64 random bits using Math.random()
104
+ // 32 bits of zero
105
+ const zeros32 = 0;
110
106
 
107
+ // Generate 64 random bits using Math.random()
111
108
  const random32Bit1 = Math.floor(Math.random() * 0xffffffff);
112
109
  const random32Bit2 = Math.floor(Math.random() * 0xffffffff);
113
- const random64Hex = random32Bit1.toString(16).padStart(8, '0') + random32Bit2.toString(16).padStart(8, '0'); // If type is 'span' we return the generated 64 bit ID
110
+ const random64Hex = random32Bit1.toString(16).padStart(8, '0') + random32Bit2.toString(16).padStart(8, '0');
114
111
 
112
+ // If type is 'span' we return the generated 64 bit ID
115
113
  if (type === TracingIdType.span) {
116
114
  return BigInt(`0x${random64Hex}`);
117
- } // Convert parts to hexadecimal strings
118
-
115
+ }
119
116
 
117
+ // Convert parts to hexadecimal strings
120
118
  const unixSecondsHex = unixSeconds32.toString(16).padStart(8, '0');
121
- const zerosHex = zeros32.toString(16).padStart(8, '0'); // Combine parts to form the 128-bit ID
119
+ const zerosHex = zeros32.toString(16).padStart(8, '0');
122
120
 
121
+ // Combine parts to form the 128-bit ID
123
122
  const hex128BitID = unixSecondsHex + zerosHex + random64Hex;
124
123
  return BigInt(`0x${hex128BitID}`);
125
124
  }
125
+
126
126
  /**
127
127
  * Returns a string representation of the Tracing ID.
128
128
  * @param format - The type of representation to use.
129
129
  * @returns The ID as a string in the specified representation type.
130
130
  */
131
-
132
-
133
131
  toString(format) {
134
132
  const lowTraceMask = this.type === TracingIdType.trace ? LOW_64BIT_MASK : LOW_32BIT_MASK;
135
133
  const highTraceMask = this.type === TracingIdType.trace ? BigInt(64) : BigInt(32);
136
134
  const padding = this.type === TracingIdType.trace ? 32 : 16;
137
-
138
135
  switch (format) {
139
136
  case TracingIdFormat.decimal:
140
137
  return this.id.toString(10);
141
-
142
138
  case TracingIdFormat.lowDecimal:
143
139
  return (this.id & lowTraceMask).toString(10);
144
-
145
140
  case TracingIdFormat.highDecimal:
146
141
  return (this.id >> highTraceMask).toString(10);
147
-
148
142
  case TracingIdFormat.hex:
149
143
  return this.id.toString(16);
150
-
151
144
  case TracingIdFormat.lowHex:
152
145
  return (this.id & lowTraceMask).toString(16);
153
-
154
146
  case TracingIdFormat.highHex:
155
147
  return (this.id >> highTraceMask).toString(16);
156
-
157
148
  case TracingIdFormat.paddedHex:
158
149
  return this.toString(TracingIdFormat.hex).padStart(padding, '0');
159
-
160
150
  case TracingIdFormat.paddedLowHex:
161
151
  return this.toString(TracingIdFormat.lowHex).padStart(padding / 2, '0');
162
-
163
152
  case TracingIdFormat.paddedHighHex:
164
153
  return this.toString(TracingIdFormat.highHex).padStart(padding / 2, '0');
165
154
  }
166
155
  }
167
-
168
156
  }
169
157
  //# sourceMappingURL=TracingIdentifier.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["TracingIdentifier.tsx"],"names":["TracingIdFormat","TracingIdType","LOW_64BIT_MASK","BigInt","LOW_32BIT_MASK","TracingIdentifier","createTraceId","trace","createSpanId","span","constructor","type","id","generateUUID","unixSeconds","Math","floor","Date","now","unixSeconds32","zeros32","random32Bit1","random","random32Bit2","random64Hex","toString","padStart","unixSecondsHex","zerosHex","hex128BitID","format","lowTraceMask","highTraceMask","padding","decimal","lowDecimal","highDecimal","hex","lowHex","highHex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eAAO,KAAKhB,QAAL,CAAczB,eAAe,CAACsC,MAA9B,EAAsCZ,QAAtC,CACHO,OAAO,GAAG,CADP,EAEH,GAFG,CAAP;;AAKJ,WAAKjC,eAAe,CAAC0C,aAArB;AACI,eAAO,KAAKjB,QAAL,CAAczB,eAAe,CAACuC,OAA9B,EAAuCb,QAAvC,CACHO,OAAO,GAAG,CADP,EAEH,GAFG,CAAP;AAhCR;AAqCH;;AA1H0B","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\n/**\n * Available formats for representing the {@link TracingIdentifier} as a string.\n */\nexport enum TracingIdFormat {\n /**\n * Decimal string representation of the full tracing id.\n */\n decimal,\n\n /**\n * The low bits of the tracing id as a decimal.\n */\n lowDecimal,\n\n /**\n * The high bits of the tracing id as a decimal.\n */\n highDecimal,\n\n /**\n * Hexadecimal string representation of the full tracing id.\n */\n hex,\n\n /**\n * Hexadecimal string representation of the low bits of the tracing id.\n */\n lowHex,\n\n /**\n * Hexadecimal string representation of the high bits of the tracing id.\n */\n highHex,\n\n /**\n * Padded hexadecimal string representation of the full tracing id.\n */\n paddedHex,\n\n /**\n * Padded hexadecimal string representation of the low bits of the tracing id.\n */\n paddedLowHex,\n\n /**\n * Padded hexadecimal string representation of the high bits of the tracing id.\n */\n paddedHighHex\n}\n\n/**\n * A {@link TracingIdentifier} used for Traces (128 bit).\n */\nexport type TraceId = TracingIdentifier & {\n _brand: 'traceId';\n};\n\n/**\n * A {@link TracingIdentifier} used for Spans (64 bit).\n */\nexport type SpanId = TracingIdentifier & {\n _brand: 'spanId';\n};\n\n/**\n * The tracing identifier type.\n */\nexport enum TracingIdType {\n /**\n * 128-bit UUID.\n */\n trace,\n /**\n * 64-bit UUID.\n */\n span\n}\n\n/**\n * Value used to mask the low 64 bits of the trace identifier.\n */\nconst LOW_64BIT_MASK =\n (BigInt('0xffffffff') << BigInt(32)) + BigInt('0xffffffff');\n\n/**\n * Value used to mask the low 32 bits of the trace identifier.\n */\nconst LOW_32BIT_MASK = (BigInt('0xffff') << BigInt(16)) + BigInt('0xffff');\n\n/**\n * A {@link TracingIdentifier} is a unique UUID that can be 64bit or 128bit, and provides\n * convenient methods to represent it as a HEX or DECIMAL string, and it allows the masking\n * of its low or high bits.\n *\n * Create a new identifier by calling {@link TracingIdentifier.createTraceId()} or\n * {@link TracingIdentifier.createSpanId()}.\n */\nexport class TracingIdentifier {\n /**\n * Read-only generated ID as a {@link bigint}.\n */\n readonly id: bigint;\n\n /**\n * Read-only type to determine whether the identifier is a {@link TraceId} or a {@link SpanId}.\n */\n readonly type: TracingIdType;\n\n /**\n * Creates a new unique Trace ID.\n * @returns the generated {@link TraceId}.\n */\n public static createTraceId(): TraceId {\n return new TracingIdentifier(TracingIdType.trace) as TraceId;\n }\n\n /**\n * Creates a new unique Span ID.\n * @returns the generated {@link SpanId}.\n */\n public static createSpanId(): SpanId {\n return new TracingIdentifier(TracingIdType.span) as SpanId;\n }\n\n /**\n * Private constructor to initialize the {@link TracingIdentifier} based on the given\n * {@link TracingIdType}.\n */\n private constructor(type: TracingIdType) {\n this.id = this.generateUUID(type);\n this.type = type;\n }\n\n /**\n * Generates a unique ID with the given format.\n * @param format - the desired format (64bit or 128bit).\n * @returns the generated UUID as a {@link bigint}.\n */\n private generateUUID(type: TracingIdType): bigint {\n // Get the current Unix timestamp in seconds\n const unixSeconds = Math.floor(Date.now() / 1000);\n\n // Ensure the Unix timestamp is 32 bits\n const unixSeconds32 = unixSeconds & 0xffffffff;\n\n // 32 bits of zero\n const zeros32 = 0;\n\n // Generate 64 random bits using Math.random()\n const random32Bit1 = Math.floor(Math.random() * 0xffffffff);\n const random32Bit2 = Math.floor(Math.random() * 0xffffffff);\n const random64Hex =\n random32Bit1.toString(16).padStart(8, '0') +\n random32Bit2.toString(16).padStart(8, '0');\n\n // If type is 'span' we return the generated 64 bit ID\n if (type === TracingIdType.span) {\n return BigInt(`0x${random64Hex}`);\n }\n\n // Convert parts to hexadecimal strings\n const unixSecondsHex = unixSeconds32.toString(16).padStart(8, '0');\n const zerosHex = zeros32.toString(16).padStart(8, '0');\n\n // Combine parts to form the 128-bit ID\n const hex128BitID = unixSecondsHex + zerosHex + random64Hex;\n\n return BigInt(`0x${hex128BitID}`);\n }\n\n /**\n * Returns a string representation of the Tracing ID.\n * @param format - The type of representation to use.\n * @returns The ID as a string in the specified representation type.\n */\n public toString(format: TracingIdFormat): string {\n const lowTraceMask =\n this.type === TracingIdType.trace ? LOW_64BIT_MASK : LOW_32BIT_MASK;\n const highTraceMask =\n this.type === TracingIdType.trace ? BigInt(64) : BigInt(32);\n const padding = this.type === TracingIdType.trace ? 32 : 16;\n\n switch (format) {\n case TracingIdFormat.decimal:\n return this.id.toString(10);\n\n case TracingIdFormat.lowDecimal:\n return (this.id & lowTraceMask).toString(10);\n\n case TracingIdFormat.highDecimal:\n return (this.id >> highTraceMask).toString(10);\n\n case TracingIdFormat.hex:\n return this.id.toString(16);\n\n case TracingIdFormat.lowHex:\n return (this.id & lowTraceMask).toString(16);\n\n case TracingIdFormat.highHex:\n return (this.id >> highTraceMask).toString(16);\n\n case TracingIdFormat.paddedHex:\n return this.toString(TracingIdFormat.hex).padStart(\n padding,\n '0'\n );\n\n case TracingIdFormat.paddedLowHex:\n return this.toString(TracingIdFormat.lowHex).padStart(\n padding / 2,\n '0'\n );\n\n case TracingIdFormat.paddedHighHex:\n return this.toString(TracingIdFormat.highHex).padStart(\n padding / 2,\n '0'\n );\n }\n }\n}\n"]}
1
+ {"version":3,"names":["TracingIdFormat","TracingIdType","LOW_64BIT_MASK","BigInt","LOW_32BIT_MASK","TracingIdentifier","createTraceId","trace","createSpanId","span","constructor","type","id","generateUUID","unixSeconds","Math","floor","Date","now","unixSeconds32","zeros32","random32Bit1","random","random32Bit2","random64Hex","toString","padStart","unixSecondsHex","zerosHex","hex128BitID","format","lowTraceMask","highTraceMask","padding","decimal","lowDecimal","highDecimal","hex","lowHex","highHex","paddedHex","paddedLowHex","paddedHighHex"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAYA,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;;AA+C3B;AACA;AACA;;AAKA;AACA;AACA;;AAKA;AACA;AACA;AACA,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;;AAWzB;AACA;AACA;AACA,MAAMC,cAAc,GAChB,CAACC,MAAM,CAAC,YAAY,CAAC,IAAIA,MAAM,CAAC,EAAE,CAAC,IAAIA,MAAM,CAAC,YAAY,CAAC;;AAE/D;AACA;AACA;AACA,MAAMC,cAAc,GAAG,CAACD,MAAM,CAAC,QAAQ,CAAC,IAAIA,MAAM,CAAC,EAAE,CAAC,IAAIA,MAAM,CAAC,QAAQ,CAAC;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,iBAAiB,CAAC;EAC3B;AACJ;AACA;;EAGI;AACJ;AACA;;EAGI;AACJ;AACA;AACA;EACI,OAAcC,aAAaA,CAAA,EAAY;IACnC,OAAO,IAAID,iBAAiB,CAACJ,aAAa,CAACM,KAAK,CAAC;EACrD;;EAEA;AACJ;AACA;AACA;EACI,OAAcC,YAAYA,CAAA,EAAW;IACjC,OAAO,IAAIH,iBAAiB,CAAC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AQ,CAACzB,eAAe,CAACqC,GAAG,CAAC,CAACX,QAAQ,CAC9CO,OAAO,EACP,GACJ,CAAC;MAEL,KAAKjC,eAAe,CAACyC,YAAY;QAC7B,OAAO,IAAI,CAAChB,QAAQ,CAACzB,eAAe,CAACsC,MAAM,CAAC,CAACZ,QAAQ,CACjDO,OAAO,GAAG,CAAC,EACX,GACJ,CAAC;MAEL,KAAKjC,eAAe,CAAC0C,aAAa;QAC9B,OAAO,IAAI,CAACjB,QAAQ,CAACzB,eAAe,CAACuC,OAAO,CAAC,CAACb,QAAQ,CAClDO,OAAO,GAAG,CAAC,EACX,GACJ,CAAC;IACT;EACJ;AACJ","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
  import { TracingIdentifier } from './TracingIdentifier';
7
8
  import { getPropagatorsForHost } from './firstPartyHosts';
8
9
  const DISCARDED_TRACE_ATTRIBUTES = {
@@ -17,16 +18,12 @@ export const getTracingAttributes = ({
17
18
  if (hostname === null) {
18
19
  return DISCARDED_TRACE_ATTRIBUTES;
19
20
  }
20
-
21
21
  const propagatorsForHost = getPropagatorsForHost(hostname, firstPartyHostsRegexMap);
22
-
23
22
  if (propagatorsForHost) {
24
23
  return generateTracingAttributesWithSampling(tracingSamplingRate, propagatorsForHost);
25
24
  }
26
-
27
25
  return DISCARDED_TRACE_ATTRIBUTES;
28
26
  };
29
-
30
27
  const generateTracingAttributesWithSampling = (tracingSamplingRate, propagatorTypes) => {
31
28
  const isSampled = Math.random() * 100 <= tracingSamplingRate;
32
29
  const tracingAttributes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["distributedTracing.tsx"],"names":["TracingIdentifier","getPropagatorsForHost","DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegexMap","tracingSamplingRate","propagatorsForHost","generateTracingAttributesWithSampling","propagatorTypes","isSampled","Math","random","tracingAttributes","traceId","createTraceId","spanId","createSpanId","rulePsr"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAKA,SAASA,iBAAT,QAAkC,qBAAlC;AAGA,SAASC,qBAAT,QAAsC,mBAAtC;AAkBA,MAAMC,0BAA0D,GAAG;AAC/DC,EAAAA,sBAAsB,EAAE,GADuC;AAE/DC,EAAAA,eAAe,EAAE;AAF8C,CAAnE;AAKA,OAAO,MAAMC,oBAAoB,GAAG,CAAC;AACjCC,EAAAA,QADiC;AAEjCC,EAAAA,uBAFiC;AAGjCC,EAAAA;AAHiC,CAAD,KAQE;AAClC,MAAIF,QAAQ,KAAK,IAAjB,EAAuB;AACnB,WAAOJ,0BAAP;AACH;;AACD,QAAMO,kBAAkB,GAAGR,qBAAqB,CAC5CK,QAD4C,EAE5CC,uBAF4C,CAAhD;;AAIA,MAAIE,kBAAJ,EAAwB;AACpB,WAAOC,qCAAqC,CACxCF,mBADwC,EAExCC,kBAFwC,CAA5C;AAIH;;AACD,SAAOP,0BAAP;AACH,CAvBM;;AAyBP,MAAMQ,qCAAqC,GAAG,CAC1CF,mBAD0C,EAE1CG,eAF0C,KAGT;AACjC,QAAMC,SAAS,GAAGC,IAAI,CAACC,MAAL,KAAgB,GAAhB,IAAuBN,mBAAzC;AACA,QAAMO,iBAAiD,GAAG;AACtDC,IAAAA,OAAO,EAAEhB,iBAAiB,CAACiB,aAAlB,EAD6C;AAEtDC,IAAAA,MAAM,EAAElB,iBAAiB,CAACmB,YAAlB,EAF8C;AAGtDhB,IAAAA,sBAAsB,EAAES,SAAS,GAAG,GAAH,GAAS,GAHY;AAItDR,IAAAA,eAAe,EAAE,MAJqC;AAKtDgB,IAAAA,OAAO,EAAEZ,mBAAmB,GAAG,GALuB;AAMtDG,IAAAA;AANsD,GAA1D;AASA,SAAOI,iBAAP;AACH,CAfD","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 { PropagatorType } from '../../../types';\nimport type { RegexMap } from '../requestProxy/interfaces/RequestProxy';\n\nimport { TracingIdentifier } from './TracingIdentifier';\nimport type { SpanId, TraceId } from './TracingIdentifier';\nimport type { Hostname } from './firstPartyHosts';\nimport { getPropagatorsForHost } from './firstPartyHosts';\n\nexport type DdRumResourceTracingAttributes =\n | {\n tracingStrategy: 'KEEP';\n traceId: TraceId;\n spanId: SpanId;\n samplingPriorityHeader: '1' | '0';\n rulePsr: number;\n propagatorTypes: PropagatorType[];\n }\n | {\n tracingStrategy: 'DISCARD';\n traceId?: void;\n spanId?: void;\n samplingPriorityHeader: '0';\n };\n\nconst DISCARDED_TRACE_ATTRIBUTES: DdRumResourceTracingAttributes = {\n samplingPriorityHeader: '0',\n tracingStrategy: 'DISCARD'\n};\n\nexport const getTracingAttributes = ({\n hostname,\n firstPartyHostsRegexMap,\n tracingSamplingRate\n}: {\n hostname: Hostname | null;\n firstPartyHostsRegexMap: RegexMap;\n tracingSamplingRate: number;\n}): DdRumResourceTracingAttributes => {\n if (hostname === null) {\n return DISCARDED_TRACE_ATTRIBUTES;\n }\n const propagatorsForHost = getPropagatorsForHost(\n hostname,\n firstPartyHostsRegexMap\n );\n if (propagatorsForHost) {\n return generateTracingAttributesWithSampling(\n tracingSamplingRate,\n propagatorsForHost\n );\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\nconst generateTracingAttributesWithSampling = (\n tracingSamplingRate: number,\n propagatorTypes: PropagatorType[]\n): DdRumResourceTracingAttributes => {\n const isSampled = Math.random() * 100 <= tracingSamplingRate;\n const tracingAttributes: DdRumResourceTracingAttributes = {\n traceId: TracingIdentifier.createTraceId(),\n spanId: TracingIdentifier.createSpanId(),\n samplingPriorityHeader: isSampled ? '1' : '0',\n tracingStrategy: 'KEEP',\n rulePsr: tracingSamplingRate / 100,\n propagatorTypes\n };\n\n return tracingAttributes;\n};\n"]}
1
+ {"version":3,"names":["TracingIdentifier","getPropagatorsForHost","DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegexMap","tracingSamplingRate","propagatorsForHost","generateTracingAttributesWithSampling","propagatorTypes","isSampled","Math","random","tracingAttributes","traceId","createTraceId","spanId","createSpanId","rulePsr"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAKA,SAASA,iBAAiB,QAAQ,qBAAqB;AAGvD,SAASC,qBAAqB,QAAQ,mBAAmB;AAkBzD,MAAMC,0BAA0D,GAAG;EAC/DC,sBAAsB,EAAE,GAAG;EAC3BC,eAAe,EAAE;AACrB,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAGA,CAAC;EACjCC,QAAQ;EACRC,uBAAuB;EACvBC;AAKJ,CAAC,KAAqC;EAClC,IAAIF,QAAQ,KAAK,IAAI,EAAE;IACnB,OAAOJ,0BAA0B;EACrC;EACA,MAAMO,kBAAkB,GAAGR,qBAAqB,CAC5CK,QAAQ,EACRC,uBACJ,CAAC;EACD,IAAIE,kBAAkB,EAAE;IACpB,OAAOC,qCAAqC,CACxCF,mBAAmB,EACnBC,kBACJ,CAAC;EACL;EACA,OAAOP,0BAA0B;AACrC,CAAC;AAED,MAAMQ,qCAAqC,GAAGA,CAC1CF,mBAA2B,EAC3BG,eAAiC,KACA;EACjC,MAAMC,SAAS,GAAGC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,GAAG,IAAIN,mBAAmB;EAC5D,MAAMO,iBAAiD,GAAG;IACtDC,OAAO,EAAEhB,iBAAiB,CAACiB,aAAa,CAAC,CAAC;IAC1CC,MAAM,EAAElB,iBAAiB,CAACmB,YAAY,CAAC,CAAC;IACxChB,sBAAsB,EAAES,SAAS,GAAG,GAAG,GAAG,GAAG;IAC7CR,eAAe,EAAE,MAAM;IACvBgB,OAAO,EAAEZ,mBAAmB,GAAG,GAAG;IAClCG;EACJ,CAAC;EAED,OAAOI,iBAAiB;AAC5B,CAAC","ignoreList":[]}
@@ -3,23 +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 { PropagatorType } from '../../../types';
7
8
  import { TracingIdFormat } from './TracingIdentifier';
8
9
  export const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
9
10
  /**
10
11
  * Datadog headers
11
12
  */
12
-
13
13
  export const ORIGIN_HEADER_KEY = 'x-datadog-origin';
14
14
  export const ORIGIN_RUM = 'rum';
15
15
  export const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
16
16
  export const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
17
17
  export const TAGS_HEADER_KEY = 'x-datadog-tags';
18
18
  export const DD_TRACE_ID_TAG = '_dd.p.tid';
19
+
19
20
  /**
20
21
  * OTel headers
21
22
  */
22
-
23
23
  export const TRACECONTEXT_HEADER_KEY = 'traceparent';
24
24
  export const TRACESTATE_HEADER_KEY = 'tracestate';
25
25
  export const B3_HEADER_KEY = 'b3';
@@ -28,11 +28,9 @@ export const B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';
28
28
  export const B3_MULTI_SAMPLED_HEADER_KEY = 'X-B3-Sampled';
29
29
  export const getTracingHeaders = tracingAttributes => {
30
30
  const headers = [];
31
-
32
31
  if (tracingAttributes.tracingStrategy === 'DISCARD') {
33
32
  return headers;
34
33
  }
35
-
36
34
  tracingAttributes.propagatorTypes.forEach(propagator => {
37
35
  switch (propagator) {
38
36
  case PropagatorType.DATADOG:
@@ -55,7 +53,6 @@ export const getTracingHeaders = tracingAttributes => {
55
53
  });
56
54
  break;
57
55
  }
58
-
59
56
  case PropagatorType.TRACECONTEXT:
60
57
  {
61
58
  headers.push({
@@ -75,7 +72,6 @@ export const getTracingHeaders = tracingAttributes => {
75
72
  });
76
73
  break;
77
74
  }
78
-
79
75
  case PropagatorType.B3:
80
76
  {
81
77
  headers.push({
@@ -88,7 +84,6 @@ export const getTracingHeaders = tracingAttributes => {
88
84
  });
89
85
  break;
90
86
  }
91
-
92
87
  case PropagatorType.B3MULTI:
93
88
  {
94
89
  headers.push({
@@ -106,7 +101,6 @@ export const getTracingHeaders = tracingAttributes => {
106
101
  });
107
102
  return headers;
108
103
  };
109
-
110
104
  const generateTraceContextHeader = ({
111
105
  version,
112
106
  traceId,
@@ -116,7 +110,6 @@ const generateTraceContextHeader = ({
116
110
  const flags = isSampled ? '01' : '00';
117
111
  return `${version}-${traceId.toString(TracingIdFormat.paddedHex)}-${parentId.toString(TracingIdFormat.paddedHex)}-${flags}`;
118
112
  };
119
-
120
113
  const generateTraceStateHeader = ({
121
114
  parentId,
122
115
  isSampled
@@ -126,7 +119,6 @@ const generateTraceStateHeader = ({
126
119
  const parent = `p:${parentId.toString(TracingIdFormat.paddedHex)}`;
127
120
  return `dd=${sampled};${origin};${parent}`;
128
121
  };
129
-
130
122
  const generateB3Header = ({
131
123
  traceId,
132
124
  spanId,
@@ -1 +1 @@
1
- {"version":3,"sources":["distributedTracingHeaders.ts"],"names":["PropagatorType","TracingIdFormat","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_HEADER_KEY","ORIGIN_RUM","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","TAGS_HEADER_KEY","DD_TRACE_ID_TAG","TRACECONTEXT_HEADER_KEY","TRACESTATE_HEADER_KEY","B3_HEADER_KEY","B3_MULTI_TRACE_ID_HEADER_KEY","B3_MULTI_SPAN_ID_HEADER_KEY","B3_MULTI_SAMPLED_HEADER_KEY","getTracingHeaders","tracingAttributes","headers","tracingStrategy","propagatorTypes","forEach","propagator","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","lowDecimal","spanId","decimal","paddedHighHex","TRACECONTEXT","generateTraceContextHeader","version","parentId","isSampled","generateTraceStateHeader","B3","generateB3Header","B3MULTI","paddedHex","flags","sampled","origin","parent","join"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,cAAT,QAA+B,gBAA/B;AAEA,SAASC,eAAT,QAAgC,qBAAhC;AAIA,OAAO,MAAMC,4BAA4B,GAAG,6BAArC;AACP;AACA;AACA;;AACA,OAAO,MAAMC,iBAAiB,GAAG,kBAA1B;AACP,OAAO,MAAMC,UAAU,GAAG,KAAnB;AACP,OAAO,MAAMC,mBAAmB,GAAG,oBAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,qBAA7B;AACP,OAAO,MAAMC,eAAe,GAAG,gBAAxB;AACP,OAAO,MAAMC,eAAe,GAAG,WAAxB;AAEP;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAG,aAAhC;AACP,OAAO,MAAMC,qBAAqB,GAAG,YAA9B;AACP,OAAO,MAAMC,aAAa,GAAG,IAAtB;AACP,OAAO,MAAMC,4BAA4B,GAAG,cAArC;AACP,OAAO,MAAMC,2BAA2B,GAAG,aAApC;AACP,OAAO,MAAMC,2BAA2B,GAAG,cAApC;AAEP,OAAO,MAAMC,iBAAiB,GAC1BC,iBAD6B,IAES;AACtC,QAAMC,OAA4C,GAAG,EAArD;;AACA,MAAID,iBAAiB,CAACE,eAAlB,KAAsC,SAA1C,EAAqD;AACjD,WAAOD,OAAP;AACH;;AACDD,EAAAA,iBAAiB,CAACG,eAAlB,CAAkCC,OAAlC,CAA0CC,UAAU,IAAI;AACpD,YAAQA,UAAR;AACI,WAAKrB,cAAc,CAACsB,OAApB;AAA6B;AACzBL,UAAAA,OAAO,CAACM,IAAR,CACI;AACIC,YAAAA,MAAM,EAAErB,iBADZ;AAEIsB,YAAAA,KAAK,EAAErB;AAFX,WADJ,EAKI;AACIoB,YAAAA,MAAM,EAAEtB,4BADZ;AAEIuB,YAAAA,KAAK,EAAET,iBAAiB,CAACU;AAF7B,WALJ,EASI;AACIF,YAAAA,MAAM,EAAEnB,mBADZ;AAEIo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AAf;AACA,QAAMC,MAAM,GAAI,KAAIV,QAAQ,CAACR,QAAT,CAAkB3B,eAAe,CAACyC,SAAlC,CAA6C,EAAjE;AAEA,SAAQ,MAAKE,OAAQ,IAAGC,MAAO,IAAGC,MAAO,EAAzC;AACH,CAZD;;AAcA,MAAMN,gBAAgB,GAAG,CAAC;AACtBb,EAAAA,OADsB;AAEtBG,EAAAA,MAFsB;AAGtBO,EAAAA;AAHsB,CAAD,KAQnB;AACF,SAAO,CACHV,OAAO,CAACC,QAAR,CAAiB3B,eAAe,CAACyC,SAAjC,CADG,EAEHZ,MAAM,CAACF,QAAP,CAAgB3B,eAAe,CAACyC,SAAhC,CAFG,EAGHL,SAAS,GAAG,GAAH,GAAS,GAHf,EAILU,IAJK,CAIA,GAJA,CAAP;AAKH,CAdD","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 { PropagatorType } from '../../../types';\n\nimport { TracingIdFormat } from './TracingIdentifier';\nimport type { TraceId, SpanId } from './TracingIdentifier';\nimport type { DdRumResourceTracingAttributes } from './distributedTracing';\n\nexport const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';\n/**\n * Datadog headers\n */\nexport const ORIGIN_HEADER_KEY = 'x-datadog-origin';\nexport const ORIGIN_RUM = 'rum';\nexport const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';\nexport const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';\nexport const TAGS_HEADER_KEY = 'x-datadog-tags';\nexport const DD_TRACE_ID_TAG = '_dd.p.tid';\n\n/**\n * OTel headers\n */\nexport const TRACECONTEXT_HEADER_KEY = 'traceparent';\nexport const TRACESTATE_HEADER_KEY = 'tracestate';\nexport const B3_HEADER_KEY = 'b3';\nexport const B3_MULTI_TRACE_ID_HEADER_KEY = 'X-B3-TraceId';\nexport const B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';\nexport const B3_MULTI_SAMPLED_HEADER_KEY = 'X-B3-Sampled';\n\nexport const getTracingHeaders = (\n tracingAttributes: DdRumResourceTracingAttributes\n): { header: string; value: string }[] => {\n const headers: { header: string; value: string }[] = [];\n if (tracingAttributes.tracingStrategy === 'DISCARD') {\n return headers;\n }\n tracingAttributes.propagatorTypes.forEach(propagator => {\n switch (propagator) {\n case PropagatorType.DATADOG: {\n headers.push(\n {\n header: ORIGIN_HEADER_KEY,\n value: ORIGIN_RUM\n },\n {\n header: SAMPLING_PRIORITY_HEADER_KEY,\n value: tracingAttributes.samplingPriorityHeader\n },\n {\n header: TRACE_ID_HEADER_KEY,\n value: tracingAttributes.traceId.toString(\n TracingIdFormat.lowDecimal\n )\n },\n {\n header: PARENT_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toString(\n TracingIdFormat.decimal\n )\n },\n {\n header: TAGS_HEADER_KEY,\n value: `${DD_TRACE_ID_TAG}=${tracingAttributes.traceId.toString(\n TracingIdFormat.paddedHighHex\n )}`\n }\n );\n break;\n }\n case PropagatorType.TRACECONTEXT: {\n headers.push(\n {\n header: TRACECONTEXT_HEADER_KEY,\n value: generateTraceContextHeader({\n version: '00',\n traceId: tracingAttributes.traceId,\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n },\n {\n header: TRACESTATE_HEADER_KEY,\n value: generateTraceStateHeader({\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n }\n );\n break;\n }\n case PropagatorType.B3: {\n headers.push({\n header: B3_HEADER_KEY,\n value: generateB3Header({\n traceId: tracingAttributes.traceId,\n spanId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n });\n break;\n }\n case PropagatorType.B3MULTI: {\n headers.push(\n {\n header: B3_MULTI_TRACE_ID_HEADER_KEY,\n value: tracingAttributes.traceId.toString(\n TracingIdFormat.paddedHex\n )\n },\n {\n header: B3_MULTI_SPAN_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toString(\n TracingIdFormat.paddedHex\n )\n },\n {\n header: B3_MULTI_SAMPLED_HEADER_KEY,\n value: tracingAttributes.samplingPriorityHeader\n }\n );\n }\n }\n });\n\n return headers;\n};\n\nconst generateTraceContextHeader = ({\n version,\n traceId,\n parentId,\n isSampled\n}: {\n version: string;\n traceId: TraceId;\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const flags = isSampled ? '01' : '00';\n return `${version}-${traceId.toString(\n TracingIdFormat.paddedHex\n )}-${parentId.toString(TracingIdFormat.paddedHex)}-${flags}`;\n};\n\nconst generateTraceStateHeader = ({\n parentId,\n isSampled\n}: {\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const sampled = `s:${isSampled ? '1' : '0'}`;\n const origin = 'o:rum';\n const parent = `p:${parentId.toString(TracingIdFormat.paddedHex)}`;\n\n return `dd=${sampled};${origin};${parent}`;\n};\n\nconst generateB3Header = ({\n traceId,\n spanId,\n isSampled\n}: {\n traceId: TraceId;\n spanId: SpanId;\n isSampled: boolean;\n}) => {\n return [\n traceId.toString(TracingIdFormat.paddedHex),\n spanId.toString(TracingIdFormat.paddedHex),\n isSampled ? '1' : '0'\n ].join('-');\n};\n"]}
1
+ {"version":3,"names":["PropagatorType","TracingIdFormat","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_HEADER_KEY","ORIGIN_RUM","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","TAGS_HEADER_KEY","DD_TRACE_ID_TAG","TRACECONTEXT_HEADER_KEY","TRACESTATE_HEADER_KEY","B3_HEADER_KEY","B3_MULTI_TRACE_ID_HEADER_KEY","B3_MULTI_SPAN_ID_HEADER_KEY","B3_MULTI_SAMPLED_HEADER_KEY","getTracingHeaders","tracingAttributes","headers","tracingStrategy","propagatorTypes","forEach","propagator","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","lowDecimal","spanId","decimal","paddedHighHex","TRACECONTEXT","generateTraceContextHeader","version","parentId","isSampled","generateTraceStateHeader","B3","generateB3Header","B3MULTI","paddedHex","flags","sampled","origin","parent","join"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,gBAAgB;AAE/C,SAASC,eAAe,QAAQ,qBAAqB;AAIrD,OAAO,MAAMC,4BAA4B,GAAG,6BAA6B;AACzE;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,kBAAkB;AACnD,OAAO,MAAMC,UAAU,GAAG,KAAK;AAC/B,OAAO,MAAMC,mBAAmB,GAAG,oBAAoB;AACvD,OAAO,MAAMC,oBAAoB,GAAG,qBAAqB;AACzD,OAAO,MAAMC,eAAe,GAAG,gBAAgB;AAC/C,OAAO,MAAMC,eAAe,GAAG,WAAW;;AAE1C;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAG,aAAa;AACpD,OAAO,MAAMC,qBAAqB,GAAG,YAAY;AACjD,OAAO,MAAMC,aAAa,GAAG,IAAI;AACjC,OAAO,MAAMC,4BAA4B,GAAG,cAAc;AAC1D,OAAO,MAAMC,2BAA2B,GAAG,aAAa;AACxD,OAAO,MAAMC,2BAA2B,GAAG,cAAc;AAEzD,OAAO,MAAMC,iBAAiB,GAC1BC,iBAAiD,IACX;EACtC,MAAMC,OAA4C,GAAG,EAAE;EACvD,IAAID,iBAAiB,CAACE,eAAe,KAAK,SAAS,EAAE;IACjD,OAAOD,OAAO;EAClB;EACAD,iBAAiB,CAACG,eAAe,CAACC,OAAO,CAACC,UAAU,IAAI;IACpD,QAAQA,UAAU;MACd,KAAKrB,cAAc,CAACsB,OAAO;QAAE;UACzBL,OAAO,CAACM,IAAI,CACR;YACIC,MAAM,EAAErB,iBAAiB;YACzBsB,KAAK,EAAErB;UACX,CAAC,EACD;YACIoB,MAAM,EAAEtB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