@datadog/mobile-react-native 2.4.1 → 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 (434) hide show
  1. package/DatadogSDKReactNative.podspec +6 -6
  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 +107 -145
  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 +50 -66
  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 +1 -4
  40. package/lib/commonjs/polyfills.js.map +1 -1
  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 +143 -208
  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 +6 -11
  118. package/lib/commonjs/sdk/GlobalState/GlobalState.js.map +1 -1
  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 +4 -6
  123. package/lib/commonjs/specs/NativeDdLogs.js.map +1 -1
  124. package/lib/commonjs/specs/NativeDdRum.js +4 -6
  125. package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
  126. package/lib/commonjs/specs/NativeDdSdk.js +4 -6
  127. package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
  128. package/lib/commonjs/specs/NativeDdTrace.js +4 -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 +104 -116
  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 +2 -2
  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 +1 -3
  173. package/lib/module/polyfills.js.map +1 -1
  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 +138 -185
  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 +6 -9
  251. package/lib/module/sdk/GlobalState/GlobalState.js.map +1 -1
  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 +2 -0
  256. package/lib/module/specs/NativeDdLogs.js.map +1 -1
  257. package/lib/module/specs/NativeDdRum.js +2 -0
  258. package/lib/module/specs/NativeDdRum.js.map +1 -1
  259. package/lib/module/specs/NativeDdSdk.js +2 -0
  260. package/lib/module/specs/NativeDdSdk.js.map +1 -1
  261. package/lib/module/specs/NativeDdTrace.js +2 -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 -0
  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 +1 -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 +1 -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/__tests__/DdSdkReactNative.test.tsx +2 -1
  419. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +32 -16
  420. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +17 -15
  421. package/src/logs/DdLogs.ts +25 -8
  422. package/src/logs/__tests__/DdLogs.test.ts +122 -0
  423. package/src/logs/types.ts +5 -1
  424. package/src/nativeModulesTypes.ts +3 -1
  425. package/src/rum/DdAttributes.ts +20 -0
  426. package/src/rum/DdRum.ts +11 -6
  427. package/src/rum/__tests__/DdRum.test.ts +40 -4
  428. package/src/rum/eventMappers/errorEventMapper.ts +2 -0
  429. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +33 -10
  430. package/src/rum/instrumentation/interactionTracking/getJsxRuntime.ts +10 -3
  431. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -1
  432. package/src/specs/NativeDdRum.ts +3 -1
  433. package/src/version.ts +1 -1
  434. package/android/src/main/kotlin/com/datadog/reactnative/VitalFrameCallback.kt +0 -41
@@ -4,26 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.TracingIdentifier = exports.TracingIdType = exports.TracingIdFormat = void 0;
7
-
8
- 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; }
9
-
10
7
  /*
11
8
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
12
9
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
13
10
  * Copyright 2016-Present Datadog, Inc.
14
11
  */
15
-
16
12
  /**
17
13
  * Available formats for representing the {@link TracingIdentifier} as a string.
18
14
  */
19
- let TracingIdFormat;
20
- /**
21
- * A {@link TracingIdentifier} used for Traces (128 bit).
22
- */
23
-
24
- exports.TracingIdFormat = TracingIdFormat;
25
-
26
- (function (TracingIdFormat) {
15
+ let TracingIdFormat = exports.TracingIdFormat = /*#__PURE__*/function (TracingIdFormat) {
27
16
  TracingIdFormat[TracingIdFormat["decimal"] = 0] = "decimal";
28
17
  TracingIdFormat[TracingIdFormat["lowDecimal"] = 1] = "lowDecimal";
29
18
  TracingIdFormat[TracingIdFormat["highDecimal"] = 2] = "highDecimal";
@@ -33,29 +22,32 @@ exports.TracingIdFormat = TracingIdFormat;
33
22
  TracingIdFormat[TracingIdFormat["paddedHex"] = 6] = "paddedHex";
34
23
  TracingIdFormat[TracingIdFormat["paddedLowHex"] = 7] = "paddedLowHex";
35
24
  TracingIdFormat[TracingIdFormat["paddedHighHex"] = 8] = "paddedHighHex";
36
- })(TracingIdFormat || (exports.TracingIdFormat = TracingIdFormat = {}));
37
-
25
+ return TracingIdFormat;
26
+ }({});
38
27
  /**
39
- * The tracing identifier type.
28
+ * A {@link TracingIdentifier} used for Traces (128 bit).
40
29
  */
41
- let TracingIdType;
42
30
  /**
43
- * Value used to mask the low 64 bits of the trace identifier.
31
+ * A {@link TracingIdentifier} used for Spans (64 bit).
44
32
  */
45
-
46
- exports.TracingIdType = TracingIdType;
47
-
48
- (function (TracingIdType) {
33
+ /**
34
+ * The tracing identifier type.
35
+ */
36
+ let TracingIdType = exports.TracingIdType = /*#__PURE__*/function (TracingIdType) {
49
37
  TracingIdType[TracingIdType["trace"] = 0] = "trace";
50
38
  TracingIdType[TracingIdType["span"] = 1] = "span";
51
- })(TracingIdType || (exports.TracingIdType = TracingIdType = {}));
52
-
39
+ return TracingIdType;
40
+ }({});
41
+ /**
42
+ * Value used to mask the low 64 bits of the trace identifier.
43
+ */
53
44
  const LOW_64BIT_MASK = (BigInt('0xffffffff') << BigInt(32)) + BigInt('0xffffffff');
45
+
54
46
  /**
55
47
  * Value used to mask the low 32 bits of the trace identifier.
56
48
  */
57
-
58
49
  const LOW_32BIT_MASK = (BigInt('0xffff') << BigInt(16)) + BigInt('0xffff');
50
+
59
51
  /**
60
52
  * A {@link TracingIdentifier} is a unique UUID that can be 64bit or 128bit, and provides
61
53
  * convenient methods to represent it as a HEX or DECIMAL string, and it allows the masking
@@ -64,7 +56,6 @@ const LOW_32BIT_MASK = (BigInt('0xffff') << BigInt(16)) + BigInt('0xffff');
64
56
  * Create a new identifier by calling {@link TracingIdentifier.createTraceId()} or
65
57
  * {@link TracingIdentifier.createSpanId()}.
66
58
  */
67
-
68
59
  class TracingIdentifier {
69
60
  /**
70
61
  * Read-only generated ID as a {@link bigint}.
@@ -81,102 +72,88 @@ class TracingIdentifier {
81
72
  static createTraceId() {
82
73
  return new TracingIdentifier(TracingIdType.trace);
83
74
  }
75
+
84
76
  /**
85
77
  * Creates a new unique Span ID.
86
78
  * @returns the generated {@link SpanId}.
87
79
  */
88
-
89
-
90
80
  static createSpanId() {
91
81
  return new TracingIdentifier(TracingIdType.span);
92
82
  }
83
+
93
84
  /**
94
85
  * Private constructor to initialize the {@link TracingIdentifier} based on the given
95
86
  * {@link TracingIdType}.
96
87
  */
97
-
98
-
99
88
  constructor(type) {
100
- _defineProperty(this, "id", void 0);
101
-
102
- _defineProperty(this, "type", void 0);
103
-
104
89
  this.id = this.generateUUID(type);
105
90
  this.type = type;
106
91
  }
92
+
107
93
  /**
108
94
  * Generates a unique ID with the given format.
109
95
  * @param format - the desired format (64bit or 128bit).
110
96
  * @returns the generated UUID as a {@link bigint}.
111
97
  */
112
-
113
-
114
98
  generateUUID(type) {
115
99
  // Get the current Unix timestamp in seconds
116
- const unixSeconds = Math.floor(Date.now() / 1000); // Ensure the Unix timestamp is 32 bits
100
+ const unixSeconds = Math.floor(Date.now() / 1000);
117
101
 
118
- const unixSeconds32 = unixSeconds & 0xffffffff; // 32 bits of zero
102
+ // Ensure the Unix timestamp is 32 bits
103
+ const unixSeconds32 = unixSeconds & 0xffffffff;
119
104
 
120
- const zeros32 = 0; // Generate 64 random bits using Math.random()
105
+ // 32 bits of zero
106
+ const zeros32 = 0;
121
107
 
108
+ // Generate 64 random bits using Math.random()
122
109
  const random32Bit1 = Math.floor(Math.random() * 0xffffffff);
123
110
  const random32Bit2 = Math.floor(Math.random() * 0xffffffff);
124
- 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
111
+ const random64Hex = random32Bit1.toString(16).padStart(8, '0') + random32Bit2.toString(16).padStart(8, '0');
125
112
 
113
+ // If type is 'span' we return the generated 64 bit ID
126
114
  if (type === TracingIdType.span) {
127
115
  return BigInt(`0x${random64Hex}`);
128
- } // Convert parts to hexadecimal strings
129
-
116
+ }
130
117
 
118
+ // Convert parts to hexadecimal strings
131
119
  const unixSecondsHex = unixSeconds32.toString(16).padStart(8, '0');
132
- const zerosHex = zeros32.toString(16).padStart(8, '0'); // Combine parts to form the 128-bit ID
120
+ const zerosHex = zeros32.toString(16).padStart(8, '0');
133
121
 
122
+ // Combine parts to form the 128-bit ID
134
123
  const hex128BitID = unixSecondsHex + zerosHex + random64Hex;
135
124
  return BigInt(`0x${hex128BitID}`);
136
125
  }
126
+
137
127
  /**
138
128
  * Returns a string representation of the Tracing ID.
139
129
  * @param format - The type of representation to use.
140
130
  * @returns The ID as a string in the specified representation type.
141
131
  */
142
-
143
-
144
132
  toString(format) {
145
133
  const lowTraceMask = this.type === TracingIdType.trace ? LOW_64BIT_MASK : LOW_32BIT_MASK;
146
134
  const highTraceMask = this.type === TracingIdType.trace ? BigInt(64) : BigInt(32);
147
135
  const padding = this.type === TracingIdType.trace ? 32 : 16;
148
-
149
136
  switch (format) {
150
137
  case TracingIdFormat.decimal:
151
138
  return this.id.toString(10);
152
-
153
139
  case TracingIdFormat.lowDecimal:
154
140
  return (this.id & lowTraceMask).toString(10);
155
-
156
141
  case TracingIdFormat.highDecimal:
157
142
  return (this.id >> highTraceMask).toString(10);
158
-
159
143
  case TracingIdFormat.hex:
160
144
  return this.id.toString(16);
161
-
162
145
  case TracingIdFormat.lowHex:
163
146
  return (this.id & lowTraceMask).toString(16);
164
-
165
147
  case TracingIdFormat.highHex:
166
148
  return (this.id >> highTraceMask).toString(16);
167
-
168
149
  case TracingIdFormat.paddedHex:
169
150
  return this.toString(TracingIdFormat.hex).padStart(padding, '0');
170
-
171
151
  case TracingIdFormat.paddedLowHex:
172
152
  return this.toString(TracingIdFormat.lowHex).padStart(padding / 2, '0');
173
-
174
153
  case TracingIdFormat.paddedHighHex:
175
154
  return this.toString(TracingIdFormat.highHex).padStart(padding / 2, '0');
176
155
  }
177
156
  }
178
-
179
157
  }
180
-
181
158
  exports.TracingIdentifier = TracingIdentifier;
182
159
  //# 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","paddedHex","paddedLowHex","paddedHighHex"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;IACYA,e;AA+CZ;AACA;AACA;;;;WAjDYA,e;AAAAA,EAAAA,e,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AAKjB,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","exports","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":";;;;;;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,CAAC0C,YAAY;QAC7B,OAAO,IAAI,CAAChB,QAAQ,CAAC1B,eAAe,CAACuC,MAAM,CAAC,CAACZ,QAAQ,CACjDO,OAAO,GAAG,CAAC,EACX,GACJ,CAAC;MAEL,KAAKlC,eAAe,CAAC2C,aAAa;QAC9B,OAAO,IAAI,CAACjB,QAAQ,CAAC1B,eAAe,CAACwC,OAAO,CAAC,CAACb,QAAQ,CAClDO,OAAO,GAAG,CAAC,EACX,GACJ,CAAC;IACT;EACJ;AACJ;AAACjC,OAAA,CAAAK,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -4,21 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getTracingAttributes = void 0;
7
-
8
7
  var _TracingIdentifier = require("./TracingIdentifier");
9
-
10
8
  var _firstPartyHosts = require("./firstPartyHosts");
11
-
12
9
  /*
13
10
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
14
11
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
15
12
  * Copyright 2016-Present Datadog, Inc.
16
13
  */
14
+
17
15
  const DISCARDED_TRACE_ATTRIBUTES = {
18
16
  samplingPriorityHeader: '0',
19
17
  tracingStrategy: 'DISCARD'
20
18
  };
21
-
22
19
  const getTracingAttributes = ({
23
20
  hostname,
24
21
  firstPartyHostsRegexMap,
@@ -27,18 +24,13 @@ const getTracingAttributes = ({
27
24
  if (hostname === null) {
28
25
  return DISCARDED_TRACE_ATTRIBUTES;
29
26
  }
30
-
31
27
  const propagatorsForHost = (0, _firstPartyHosts.getPropagatorsForHost)(hostname, firstPartyHostsRegexMap);
32
-
33
28
  if (propagatorsForHost) {
34
29
  return generateTracingAttributesWithSampling(tracingSamplingRate, propagatorsForHost);
35
30
  }
36
-
37
31
  return DISCARDED_TRACE_ATTRIBUTES;
38
32
  };
39
-
40
33
  exports.getTracingAttributes = getTracingAttributes;
41
-
42
34
  const generateTracingAttributesWithSampling = (tracingSamplingRate, propagatorTypes) => {
43
35
  const isSampled = Math.random() * 100 <= tracingSamplingRate;
44
36
  const tracingAttributes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["distributedTracing.tsx"],"names":["DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegexMap","tracingSamplingRate","propagatorsForHost","generateTracingAttributesWithSampling","propagatorTypes","isSampled","Math","random","tracingAttributes","traceId","TracingIdentifier","createTraceId","spanId","createSpanId","rulePsr"],"mappings":";;;;;;;AASA;;AAGA;;AAZA;AACA;AACA;AACA;AACA;AA0BA,MAAMA,0BAA0D,GAAG;AAC/DC,EAAAA,sBAAsB,EAAE,GADuC;AAE/DC,EAAAA,eAAe,EAAE;AAF8C,CAAnE;;AAKO,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,GAAG,4CACvBH,QADuB,EAEvBC,uBAFuB,CAA3B;;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,EAAEC,qCAAkBC,aAAlB,EAD6C;AAEtDC,IAAAA,MAAM,EAAEF,qCAAkBG,YAAlB,EAF8C;AAGtDjB,IAAAA,sBAAsB,EAAES,SAAS,GAAG,GAAH,GAAS,GAHY;AAItDR,IAAAA,eAAe,EAAE,MAJqC;AAKtDiB,IAAAA,OAAO,EAAEb,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","require","_firstPartyHosts","DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegexMap","tracingSamplingRate","propagatorsForHost","getPropagatorsForHost","generateTracingAttributesWithSampling","exports","propagatorTypes","isSampled","Math","random","tracingAttributes","traceId","TracingIdentifier","createTraceId","spanId","createSpanId","rulePsr"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx"],"mappings":";;;;;;AASA,IAAAA,kBAAA,GAAAC,OAAA;AAGA,IAAAC,gBAAA,GAAAD,OAAA;AAZA;AACA;AACA;AACA;AACA;;AA0BA,MAAME,0BAA0D,GAAG;EAC/DC,sBAAsB,EAAE,GAAG;EAC3BC,eAAe,EAAE;AACrB,CAAC;AAEM,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,GAAG,IAAAC,sCAAqB,EAC5CJ,QAAQ,EACRC,uBACJ,CAAC;EACD,IAAIE,kBAAkB,EAAE;IACpB,OAAOE,qCAAqC,CACxCH,mBAAmB,EACnBC,kBACJ,CAAC;EACL;EACA,OAAOP,0BAA0B;AACrC,CAAC;AAACU,OAAA,CAAAP,oBAAA,GAAAA,oBAAA;AAEF,MAAMM,qCAAqC,GAAGA,CAC1CH,mBAA2B,EAC3BK,eAAiC,KACA;EACjC,MAAMC,SAAS,GAAGC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,GAAG,IAAIR,mBAAmB;EAC5D,MAAMS,iBAAiD,GAAG;IACtDC,OAAO,EAAEC,oCAAiB,CAACC,aAAa,CAAC,CAAC;IAC1CC,MAAM,EAAEF,oCAAiB,CAACG,YAAY,CAAC,CAAC;IACxCnB,sBAAsB,EAAEW,SAAS,GAAG,GAAG,GAAG,GAAG;IAC7CV,eAAe,EAAE,MAAM;IACvBmB,OAAO,EAAEf,mBAAmB,GAAG,GAAG;IAClCK;EACJ,CAAC;EAED,OAAOI,iBAAiB;AAC5B,CAAC","ignoreList":[]}
@@ -3,59 +3,40 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getTracingHeaders = exports.B3_MULTI_SAMPLED_HEADER_KEY = exports.B3_MULTI_SPAN_ID_HEADER_KEY = exports.B3_MULTI_TRACE_ID_HEADER_KEY = exports.B3_HEADER_KEY = exports.TRACESTATE_HEADER_KEY = exports.TRACECONTEXT_HEADER_KEY = exports.DD_TRACE_ID_TAG = exports.TAGS_HEADER_KEY = exports.PARENT_ID_HEADER_KEY = exports.TRACE_ID_HEADER_KEY = exports.ORIGIN_RUM = exports.ORIGIN_HEADER_KEY = exports.SAMPLING_PRIORITY_HEADER_KEY = void 0;
7
-
6
+ exports.getTracingHeaders = exports.TRACE_ID_HEADER_KEY = exports.TRACESTATE_HEADER_KEY = exports.TRACECONTEXT_HEADER_KEY = exports.TAGS_HEADER_KEY = exports.SAMPLING_PRIORITY_HEADER_KEY = exports.PARENT_ID_HEADER_KEY = exports.ORIGIN_RUM = exports.ORIGIN_HEADER_KEY = exports.DD_TRACE_ID_TAG = exports.B3_MULTI_TRACE_ID_HEADER_KEY = exports.B3_MULTI_SPAN_ID_HEADER_KEY = exports.B3_MULTI_SAMPLED_HEADER_KEY = exports.B3_HEADER_KEY = void 0;
8
7
  var _types = require("../../../types");
9
-
10
8
  var _TracingIdentifier = require("./TracingIdentifier");
11
-
12
9
  /*
13
10
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
14
11
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
15
12
  * Copyright 2016-Present Datadog, Inc.
16
13
  */
17
- const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
14
+
15
+ const SAMPLING_PRIORITY_HEADER_KEY = exports.SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
18
16
  /**
19
17
  * Datadog headers
20
18
  */
19
+ const ORIGIN_HEADER_KEY = exports.ORIGIN_HEADER_KEY = 'x-datadog-origin';
20
+ const ORIGIN_RUM = exports.ORIGIN_RUM = 'rum';
21
+ const TRACE_ID_HEADER_KEY = exports.TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
22
+ const PARENT_ID_HEADER_KEY = exports.PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
23
+ const TAGS_HEADER_KEY = exports.TAGS_HEADER_KEY = 'x-datadog-tags';
24
+ const DD_TRACE_ID_TAG = exports.DD_TRACE_ID_TAG = '_dd.p.tid';
21
25
 
22
- exports.SAMPLING_PRIORITY_HEADER_KEY = SAMPLING_PRIORITY_HEADER_KEY;
23
- const ORIGIN_HEADER_KEY = 'x-datadog-origin';
24
- exports.ORIGIN_HEADER_KEY = ORIGIN_HEADER_KEY;
25
- const ORIGIN_RUM = 'rum';
26
- exports.ORIGIN_RUM = ORIGIN_RUM;
27
- const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
28
- exports.TRACE_ID_HEADER_KEY = TRACE_ID_HEADER_KEY;
29
- const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
30
- exports.PARENT_ID_HEADER_KEY = PARENT_ID_HEADER_KEY;
31
- const TAGS_HEADER_KEY = 'x-datadog-tags';
32
- exports.TAGS_HEADER_KEY = TAGS_HEADER_KEY;
33
- const DD_TRACE_ID_TAG = '_dd.p.tid';
34
26
  /**
35
27
  * OTel headers
36
28
  */
37
-
38
- exports.DD_TRACE_ID_TAG = DD_TRACE_ID_TAG;
39
- const TRACECONTEXT_HEADER_KEY = 'traceparent';
40
- exports.TRACECONTEXT_HEADER_KEY = TRACECONTEXT_HEADER_KEY;
41
- const TRACESTATE_HEADER_KEY = 'tracestate';
42
- exports.TRACESTATE_HEADER_KEY = TRACESTATE_HEADER_KEY;
43
- const B3_HEADER_KEY = 'b3';
44
- exports.B3_HEADER_KEY = B3_HEADER_KEY;
45
- const B3_MULTI_TRACE_ID_HEADER_KEY = 'X-B3-TraceId';
46
- exports.B3_MULTI_TRACE_ID_HEADER_KEY = B3_MULTI_TRACE_ID_HEADER_KEY;
47
- const B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';
48
- exports.B3_MULTI_SPAN_ID_HEADER_KEY = B3_MULTI_SPAN_ID_HEADER_KEY;
49
- const B3_MULTI_SAMPLED_HEADER_KEY = 'X-B3-Sampled';
50
- exports.B3_MULTI_SAMPLED_HEADER_KEY = B3_MULTI_SAMPLED_HEADER_KEY;
51
-
29
+ const TRACECONTEXT_HEADER_KEY = exports.TRACECONTEXT_HEADER_KEY = 'traceparent';
30
+ const TRACESTATE_HEADER_KEY = exports.TRACESTATE_HEADER_KEY = 'tracestate';
31
+ const B3_HEADER_KEY = exports.B3_HEADER_KEY = 'b3';
32
+ const B3_MULTI_TRACE_ID_HEADER_KEY = exports.B3_MULTI_TRACE_ID_HEADER_KEY = 'X-B3-TraceId';
33
+ const B3_MULTI_SPAN_ID_HEADER_KEY = exports.B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';
34
+ const B3_MULTI_SAMPLED_HEADER_KEY = exports.B3_MULTI_SAMPLED_HEADER_KEY = 'X-B3-Sampled';
52
35
  const getTracingHeaders = tracingAttributes => {
53
36
  const headers = [];
54
-
55
37
  if (tracingAttributes.tracingStrategy === 'DISCARD') {
56
38
  return headers;
57
39
  }
58
-
59
40
  tracingAttributes.propagatorTypes.forEach(propagator => {
60
41
  switch (propagator) {
61
42
  case _types.PropagatorType.DATADOG:
@@ -78,7 +59,6 @@ const getTracingHeaders = tracingAttributes => {
78
59
  });
79
60
  break;
80
61
  }
81
-
82
62
  case _types.PropagatorType.TRACECONTEXT:
83
63
  {
84
64
  headers.push({
@@ -98,7 +78,6 @@ const getTracingHeaders = tracingAttributes => {
98
78
  });
99
79
  break;
100
80
  }
101
-
102
81
  case _types.PropagatorType.B3:
103
82
  {
104
83
  headers.push({
@@ -111,7 +90,6 @@ const getTracingHeaders = tracingAttributes => {
111
90
  });
112
91
  break;
113
92
  }
114
-
115
93
  case _types.PropagatorType.B3MULTI:
116
94
  {
117
95
  headers.push({
@@ -129,9 +107,7 @@ const getTracingHeaders = tracingAttributes => {
129
107
  });
130
108
  return headers;
131
109
  };
132
-
133
110
  exports.getTracingHeaders = getTracingHeaders;
134
-
135
111
  const generateTraceContextHeader = ({
136
112
  version,
137
113
  traceId,
@@ -141,7 +117,6 @@ const generateTraceContextHeader = ({
141
117
  const flags = isSampled ? '01' : '00';
142
118
  return `${version}-${traceId.toString(_TracingIdentifier.TracingIdFormat.paddedHex)}-${parentId.toString(_TracingIdentifier.TracingIdFormat.paddedHex)}-${flags}`;
143
119
  };
144
-
145
120
  const generateTraceStateHeader = ({
146
121
  parentId,
147
122
  isSampled
@@ -151,7 +126,6 @@ const generateTraceStateHeader = ({
151
126
  const parent = `p:${parentId.toString(_TracingIdentifier.TracingIdFormat.paddedHex)}`;
152
127
  return `dd=${sampled};${origin};${parent}`;
153
128
  };
154
-
155
129
  const generateB3Header = ({
156
130
  traceId,
157
131
  spanId,
@@ -1 +1 @@
1
- {"version":3,"sources":["distributedTracingHeaders.ts"],"names":["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","PropagatorType","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","TracingIdFormat","lowDecimal","spanId","decimal","paddedHighHex","TRACECONTEXT","generateTraceContextHeader","version","parentId","isSampled","generateTraceStateHeader","B3","generateB3Header","B3MULTI","paddedHex","flags","sampled","origin","parent","join"],"mappings":";;;;;;;AAMA;;AAEA;;AARA;AACA;AACA;AACA;AACA;AAQO,MAAMA,4BAA4B,GAAG,6BAArC;AACP;AACA;AACA;;;AACO,MAAMC,iBAAiB,GAAG,kBAA1B;;AACA,MAAMC,UAAU,GAAG,KAAnB;;AACA,MAAMC,mBAAmB,GAAG,oBAA5B;;AACA,MAAMC,oBAAoB,GAAG,qBAA7B;;AACA,MAAMC,eAAe,GAAG,gBAAxB;;AACA,MAAMC,eAAe,GAAG,WAAxB;AAEP;AACA;AACA;;;AACO,MAAMC,uBAAuB,GAAG,aAAhC;;AACA,MAAMC,qBAAqB,GAAG,YAA9B;;AACA,MAAMC,aAAa,GAAG,IAAtB;;AACA,MAAMC,4BAA4B,GAAG,cAArC;;AACA,MAAMC,2BAA2B,GAAG,aAApC;;AACA,MAAMC,2BAA2B,GAAG,cAApC;;;AAEA,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,WAAKC,sBAAeC,OAApB;AAA6B;AACzBN,UAAAA,OAAO,CAACO,IAAR,CACI;AACIC,YAAAA,MAAM,EAAEtB,iBADZ;AAEIuB,YAAAA,KAAK,EAAEtB;AAFX,WADJ,EAKI;AACIqB,YAAAA,MAAM,EAAEvB,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AI,KAAIP,SAAS,GAAG,GAAH,GAAS,GAAI,EAA3C;AACA,QAAMQ,MAAM,GAAG,OAAf;AACA,QAAMC,MAAM,GAAI,KAAIV,QAAQ,CAACT,QAAT,CAAkBC,mCAAgBc,SAAlC,CAA6C,EAAjE;AAEA,SAAQ,MAAKE,OAAQ,IAAGC,MAAO,IAAGC,MAAO,EAAzC;AACH,CAZD;;AAcA,MAAMN,gBAAgB,GAAG,CAAC;AACtBd,EAAAA,OADsB;AAEtBI,EAAAA,MAFsB;AAGtBO,EAAAA;AAHsB,CAAD,KAQnB;AACF,SAAO,CACHX,OAAO,CAACC,QAAR,CAAiBC,mCAAgBc,SAAjC,CADG,EAEHZ,MAAM,CAACH,QAAP,CAAgBC,mCAAgBc,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":["_types","require","_TracingIdentifier","SAMPLING_PRIORITY_HEADER_KEY","exports","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","PropagatorType","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","TracingIdFormat","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":";;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAD,OAAA;AARA;AACA;AACA;AACA;AACA;;AAQO,MAAME,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,GAAG,6BAA6B;AACzE;AACA;AACA;AACO,MAAME,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAG,kBAAkB;AAC5C,MAAMC,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG,KAAK;AACxB,MAAMC,mBAAmB,GAAAH,OAAA,CAAAG,mBAAA,GAAG,oBAAoB;AAChD,MAAMC,oBAAoB,GAAAJ,OAAA,CAAAI,oBAAA,GAAG,qBAAqB;AAClD,MAAMC,eAAe,GAAAL,OAAA,CAAAK,eAAA,GAAG,gBAAgB;AACxC,MAAMC,eAAe,GAAAN,OAAA,CAAAM,eAAA,GAAG,WAAW;;AAE1C;AACA;AACA;AACO,MAAMC,uBAAuB,GAAAP,OAAA,CAAAO,uBAAA,GAAG,aAAa;AAC7C,MAAMC,qBAAqB,GAAAR,OAAA,CAAAQ,qBAAA,GAAG,YAAY;AAC1C,MAAMC,aAAa,GAAAT,OAAA,CAAAS,aAAA,GAAG,IAAI;AAC1B,MAAMC,4BAA4B,GAAAV,OAAA,CAAAU,4BAAA,GAAG,cAAc;AACnD,MAAMC,2BAA2B,GAAAX,OAAA,CAAAW,2BAAA,GAAG,aAAa;AACjD,MAAMC,2BAA2B,GAAAZ,OAAA,CAAAY,2BAAA,GAAG,cAAc;AAElD,MAAMC,iBAAiB,GAC1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,SAAS,CAAC,IAAIC,KAAK,EAAE;AAChE,CAAC;AAED,MAAML,wBAAwB,GAAGA,CAAC;EAC9BF,QAAQ;EACRC;AAIJ,CAAC,KAAK;EACF,MAAMO,OAAO,GAAG,KAAKP,SAAS,GAAG,GAAG,GAAG,GAAG,EAAE;EAC5C,MAAMQ,MAAM,GAAG,OAAO;EACtB,MAAMC,MAAM,GAAG,KAAKV,QAAQ,CAACT,QAAQ,CAACC,kCAAe,CAACc,SAAS,CAAC,EAAE;EAElE,OAAO,MAAME,OAAO,IAAIC,MAAM,IAAIC,MAAM,EAAE;AAC9C,CAAC;AAED,MAAMN,gBAAgB,GAAGA,CAAC;EACtBd,OAAO;EACPI,MAAM;EACNO;AAKJ,CAAC,KAAK;EACF,OAAO,CACHX,OAAO,CAACC,QAAQ,CAACC,kCAAe,CAACc,SAAS,CAAC,EAC3CZ,MAAM,CAACH,QAAQ,CAACC,kCAAe,CAACc,SAAS,CAAC,EAC1CL,SAAS,GAAG,GAAG,GAAG,GAAG,CACxB,CAACU,IAAI,CAAC,GAAG,CAAC;AACf,CAAC","ignoreList":[]}
@@ -4,25 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getPropagatorsForHost = exports.firstPartyHostsRegexMapBuilder = exports.NO_MATCH_REGEX = void 0;
7
-
8
7
  var _InternalLog = require("../../../../InternalLog");
9
-
10
8
  var _SdkVerbosity = require("../../../../SdkVerbosity");
11
-
12
9
  /*
13
10
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
14
11
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
15
12
  * Copyright 2016-Present Datadog, Inc.
16
13
  */
17
- // This regex does not match anything
18
- const NO_MATCH_REGEX = new RegExp('a^'); // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
19
14
 
20
- exports.NO_MATCH_REGEX = NO_MATCH_REGEX;
15
+ // This regex does not match anything
16
+ const NO_MATCH_REGEX = exports.NO_MATCH_REGEX = new RegExp('a^');
21
17
 
18
+ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
22
19
  const escapeRegExp = string => {
23
20
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
24
21
  };
25
-
26
22
  const firstPartyHostsRegexMapBuilder = firstPartyHosts => {
27
23
  const hostsMap = {
28
24
  datadog: [],
@@ -46,14 +42,11 @@ const firstPartyHostsRegexMapBuilder = firstPartyHosts => {
46
42
  });
47
43
  return regexMap;
48
44
  };
49
-
50
45
  exports.firstPartyHostsRegexMapBuilder = firstPartyHostsRegexMapBuilder;
51
-
52
46
  const firstPartyHostsRegexBuilder = firstPartyHosts => {
53
47
  if (firstPartyHosts.length === 0) {
54
48
  return NO_MATCH_REGEX;
55
49
  }
56
-
57
50
  try {
58
51
  // A regexp for matching hosts, e.g. when `hosts` is "example.com", it will match
59
52
  // "example.com", "api.example.com", but not "foo.com".
@@ -62,11 +55,9 @@ const firstPartyHostsRegexBuilder = firstPartyHosts => {
62
55
  return firstPartyHostsRegex;
63
56
  } catch (e) {
64
57
  _InternalLog.InternalLog.log(`Invalid first party hosts list ${JSON.stringify(firstPartyHosts)}. Regular expressions are not allowed.`, _SdkVerbosity.SdkVerbosity.WARN);
65
-
66
58
  return NO_MATCH_REGEX;
67
59
  }
68
60
  };
69
-
70
61
  const getPropagatorsForHost = (hostname, firstPartyHostsRegexMap) => {
71
62
  const matchedPropagatorTypes = [];
72
63
  firstPartyHostsRegexMap.forEach(({
@@ -79,6 +70,5 @@ const getPropagatorsForHost = (hostname, firstPartyHostsRegexMap) => {
79
70
  });
80
71
  return matchedPropagatorTypes.length > 0 ? matchedPropagatorTypes : null;
81
72
  };
82
-
83
73
  exports.getPropagatorsForHost = getPropagatorsForHost;
84
74
  //# sourceMappingURL=firstPartyHosts.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["firstPartyHosts.ts"],"names":["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","InternalLog","log","JSON","stringify","SdkVerbosity","WARN","getPropagatorsForHost","hostname","firstPartyHostsRegexMap","matchedPropagatorTypes"],"mappings":";;;;;;;AAMA;;AACA;;AAPA;AACA;AACA;AACA;AACA;AASA;AACO,MAAMA,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;;AAIO,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,IAAzB,CAA8BH,IAAI,CAACI,KAAnC;AACH,KAFD;AAGH,GAJD;AAMA,QAAMC,QAA6D,GAAG,EAAtE;AACAC,EAAAA,MAAM,CAACC,OAAP,CAAeb,QAAf,EAAyBK,OAAzB,CAAiC,CAAC,CAACG,cAAD,EAAiBM,KAAjB,CAAD,KAA6B;AAC1D,QAAIA,KAAK,CAACC,MAAN,GAAe,CAAnB,EAAsB;AAClBJ,MAAAA,QAAQ,CAACF,IAAT,CAAc;AACVD,QAAAA,cAAc,EAAEA,cADN;AAEVQ,QAAAA,KAAK,EAAEC,2BAA2B,CAACH,KAAD;AAFxB,OAAd;AAIH;AACJ,GAPD;AASA,SAAOH,QAAP;AACH,CA3BM;;;;AA6BP,MAAMM,2BAA2B,GAAIlB,eAAD,IAAuC;AACvE,MAAIA,eAAe,CAACgB,MAAhB,KAA2B,CAA/B,EAAkC;AAC9B,WAAOtB,cAAP;AACH;;AACD,MAAI;AACA;AACA;AACA,UAAMyB,oBAAoB,GAAG,IAAIxB,MAAJ,CACxB,aAAYK,eAAe,CACvBoB,GADQ,CACJb,IAAI,IAAK,GAAEX,YAAY,CAACW,IAAD,CAAO,GAD1B,EAERc,IAFQ,CAEH,GAFG,CAEE,GAHU,CAA7B;AAKAF,IAAAA,oBAAoB,CAACG,IAArB,CAA0B,yBAA1B;AACA,WAAOH,oBAAP;AACH,GAVD,CAUE,OAAOI,CAAP,EAAU;AACRC,6BAAYC,GAAZ,CACK,kCAAiCC,IAAI,CAACC,SAAL,CAC9B3B,eAD8B,CAEhC,wCAHN,EAII4B,2BAAaC,IAJjB;;AAMA,WAAOnC,cAAP;AACH;AACJ,CAvBD;;AAyBO,MAAMoC,qBAAqB,GAAG,CACjCC,QADiC,EAEjCC,uBAFiC,KAGP;AAC1B,QAAMC,sBAAwC,GAAG,EAAjD;AACAD,EAAAA,uBAAuB,CAAC1B,OAAxB,CAAgC,CAAC;AAAEW,IAAAA,KAAF;AAASR,IAAAA;AAAT,GAAD,KAA+B;AAC3D,QAAIQ,KAAK,CAACK,IAAN,CAAWS,QAAX,CAAJ,EAA0B;AACtBE,MAAAA,sBAAsB,CAACvB,IAAvB,CAA4BD,cAA5B;AACH;AACJ,GAJD;AAKA,SAAOwB,sBAAsB,CAACjB,MAAvB,GAAgC,CAAhC,GAAoCiB,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","require","_SdkVerbosity","NO_MATCH_REGEX","exports","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","InternalLog","log","JSON","stringify","SdkVerbosity","WARN","getPropagatorsForHost","hostname","firstPartyHostsRegexMap","matchedPropagatorTypes"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAPA;AACA;AACA;AACA;AACA;;AASA;AACO,MAAME,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,IAAIE,MAAM,CAAC,IAAI,CAAC;;AAE9C;AACA,MAAMC,YAAY,GAAIC,MAAc,IAAK;EACrC,OAAOA,MAAM,CAACC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1D,CAAC;AAEM,MAAMC,8BAA8B,GACvCC,eAAiC,IACtB;EACX,MAAMC,QAA0C,GAAG;IAC/CC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE,EAAE;IAChBC,EAAE,EAAE,EAAE;IACNC,OAAO,EAAE;EACb,CAAC;EAEDL,eAAe,CAACM,OAAO,CAACC,IAAI,IAAI;IAC5BA,IAAI,CA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AAwC,GAAG,EAAE;EACnDD,uBAAuB,CAAC1B,OAAO,CAAC,CAAC;IAAEW,KAAK;IAAER;EAAe,CAAC,KAAK;IAC3D,IAAIQ,KAAK,CAACK,IAAI,CAACS,QAAQ,CAAC,EAAE;MACtBE,sBAAsB,CAACvB,IAAI,CAACD,cAAc,CAAC;IAC/C;EACJ,CAAC,CAAC;EACF,OAAOwB,sBAAsB,CAACjB,MAAM,GAAG,CAAC,GAAGiB,sBAAsB,GAAG,IAAI;AAC5E,CAAC;AAACvC,OAAA,CAAAoC,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -3,24 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isDatadogCustomHeader = exports.DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = exports.DATADOG_GRAPH_QL_VARIABLES_HEADER = exports.DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = void 0;
7
-
6
+ exports.isDatadogCustomHeader = exports.DATADOG_GRAPH_QL_VARIABLES_HEADER = exports.DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = exports.DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = void 0;
8
7
  /*
9
8
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
10
9
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
11
10
  * Copyright 2016-Present Datadog, Inc.
12
11
  */
13
- const DATADOG_CUSTOM_HEADER_PREFIX = '_dd-custom-header';
14
- const DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-name`;
15
- exports.DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = DATADOG_GRAPH_QL_OPERATION_NAME_HEADER;
16
- const DATADOG_GRAPH_QL_VARIABLES_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-variables`;
17
- exports.DATADOG_GRAPH_QL_VARIABLES_HEADER = DATADOG_GRAPH_QL_VARIABLES_HEADER;
18
- const DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-type`;
19
- exports.DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER;
20
12
 
13
+ const DATADOG_CUSTOM_HEADER_PREFIX = '_dd-custom-header';
14
+ const DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = exports.DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-name`;
15
+ const DATADOG_GRAPH_QL_VARIABLES_HEADER = exports.DATADOG_GRAPH_QL_VARIABLES_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-variables`;
16
+ const DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = exports.DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-type`;
21
17
  const isDatadogCustomHeader = header => {
22
18
  return header.match(new RegExp(`^${DATADOG_CUSTOM_HEADER_PREFIX}`));
23
19
  };
24
-
25
20
  exports.isDatadogCustomHeader = isDatadogCustomHeader;
26
21
  //# sourceMappingURL=graphqlHeaders.js.map
@@ -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;AAEO,MAAMC,sCAAsC,GAAI,GAAED,4BAA6B,0BAA/E;;AACA,MAAME,iCAAiC,GAAI,GAAEF,4BAA6B,qBAA1E;;AACA,MAAMG,sCAAsC,GAAI,GAAEH,4BAA6B,0BAA/E;;;AAEA,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","exports","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;AAEjD,MAAMC,sCAAsC,GAAAC,OAAA,CAAAD,sCAAA,GAAG,GAAGD,4BAA4B,0BAA0B;AACxG,MAAMG,iCAAiC,GAAAD,OAAA,CAAAC,iCAAA,GAAG,GAAGH,4BAA4B,qBAAqB;AAC9F,MAAMI,sCAAsC,GAAAF,OAAA,CAAAE,sCAAA,GAAG,GAAGJ,4BAA4B,0BAA0B;AAExG,MAAMK,qBAAqB,GAAIC,MAAc,IAAK;EACrD,OAAOA,MAAM,CAACC,KAAK,CAAC,IAAIC,MAAM,CAAC,IAAIR,4BAA4B,EAAE,CAAC,CAAC;AACvE,CAAC;AAACE,OAAA,CAAAG,qBAAA,GAAAA,qBAAA","ignoreList":[]}