@datadog/mobile-react-native 3.11.0 → 3.13.0

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 (342) hide show
  1. package/DatadogSDKReactNative.podspec +357 -14
  2. package/README.md +5 -3
  3. package/android/build.gradle +23 -14
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +27 -2
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +27 -2
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +25 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  8. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +4 -0
  9. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +104 -0
  10. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +8 -0
  11. package/android/src/test/resources/input/complete-configuration.json +5 -0
  12. package/datadog-configuration.gradle +59 -18
  13. package/datadog-configuration.schema.json +140 -0
  14. package/ios/Sources/DdFlagsImplementation.swift +3 -0
  15. package/ios/Sources/DdSdkConfiguration.swift +11 -1
  16. package/ios/Sources/DdSdkNativeInitialization.swift +24 -2
  17. package/ios/Sources/RNDdSdkConfiguration.swift +14 -2
  18. package/ios/Sources/SdkVersion.swift +1 -1
  19. package/lib/commonjs/DdSdkReactNative.js +6 -1
  20. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  21. package/lib/commonjs/config/FileBasedConfiguration.js +4 -1
  22. package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
  23. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +3 -1
  24. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  25. package/lib/commonjs/config/features/RumConfiguration.js +8 -0
  26. package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
  27. package/lib/commonjs/config/features/RumConfigurationNative.js +4 -0
  28. package/lib/commonjs/config/types/TimeseriesConfiguration.js +25 -0
  29. package/lib/commonjs/config/types/TimeseriesConfiguration.js.map +1 -0
  30. package/lib/commonjs/config/types/index.js +7 -0
  31. package/lib/commonjs/config/types/index.js.map +1 -1
  32. package/lib/commonjs/flags/DdFlags.js +4 -2
  33. package/lib/commonjs/flags/DdFlags.js.map +1 -1
  34. package/lib/commonjs/flags/FlagsClient.js +4 -2
  35. package/lib/commonjs/flags/FlagsClient.js.map +1 -1
  36. package/lib/commonjs/index.js +7 -0
  37. package/lib/commonjs/index.js.map +1 -1
  38. package/lib/commonjs/internal.js +97 -0
  39. package/lib/commonjs/internal.js.map +1 -0
  40. package/lib/commonjs/logs/DdLogs.js +4 -2
  41. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  42. package/lib/commonjs/rum/DdRum.js +4 -2
  43. package/lib/commonjs/rum/DdRum.js.map +1 -1
  44. package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +20 -15
  45. package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
  46. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -2
  47. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  48. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +2 -1
  49. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -1
  50. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
  51. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js +308 -0
  52. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js.map +1 -0
  53. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js +275 -0
  54. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js.map +1 -0
  55. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js +167 -0
  56. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js.map +1 -0
  57. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js +36 -0
  58. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js.map +1 -0
  59. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js +158 -0
  60. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js.map +1 -0
  61. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js +58 -0
  62. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js.map +1 -0
  63. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js +39 -0
  64. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js.map +1 -0
  65. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js +38 -0
  66. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js.map +1 -0
  67. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/types.js +2 -0
  68. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/types.js.map +1 -0
  69. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +17 -2
  70. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
  71. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +25 -3
  72. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
  73. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js +2 -35
  74. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js.map +1 -1
  75. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +3 -1
  76. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -1
  77. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js +8 -2
  78. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -1
  79. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js +88 -0
  80. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js.map +1 -0
  81. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
  82. package/lib/commonjs/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js +2 -3
  83. package/lib/commonjs/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js.map +1 -1
  84. package/lib/commonjs/sdk/DdSdkInternal.js +27 -22
  85. package/lib/commonjs/sdk/DdSdkInternal.js.map +1 -1
  86. package/lib/commonjs/specs/NativeDdFlags.js +19 -3
  87. package/lib/commonjs/specs/NativeDdFlags.js.map +1 -1
  88. package/lib/commonjs/specs/NativeDdLogs.js +19 -3
  89. package/lib/commonjs/specs/NativeDdLogs.js.map +1 -1
  90. package/lib/commonjs/specs/NativeDdRum.js +19 -3
  91. package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
  92. package/lib/commonjs/specs/NativeDdSdk.js +19 -3
  93. package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
  94. package/lib/commonjs/specs/NativeDdTrace.js +19 -3
  95. package/lib/commonjs/specs/NativeDdTrace.js.map +1 -1
  96. package/lib/commonjs/trace/DdTrace.js +4 -2
  97. package/lib/commonjs/trace/DdTrace.js.map +1 -1
  98. package/lib/commonjs/utils/stringUtils.js +48 -0
  99. package/lib/commonjs/utils/stringUtils.js.map +1 -0
  100. package/lib/commonjs/version.js +1 -1
  101. package/lib/module/DdSdkReactNative.js +6 -1
  102. package/lib/module/DdSdkReactNative.js.map +1 -1
  103. package/lib/module/config/FileBasedConfiguration.js +4 -1
  104. package/lib/module/config/FileBasedConfiguration.js.map +1 -1
  105. package/lib/module/config/async/AutoInstrumentationConfiguration.js +3 -1
  106. package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  107. package/lib/module/config/features/RumConfiguration.js +8 -0
  108. package/lib/module/config/features/RumConfiguration.js.map +1 -1
  109. package/lib/module/config/features/RumConfigurationNative.js +1 -1
  110. package/lib/module/config/types/TimeseriesConfiguration.js +19 -0
  111. package/lib/module/config/types/TimeseriesConfiguration.js.map +1 -0
  112. package/lib/module/config/types/index.js +1 -0
  113. package/lib/module/config/types/index.js.map +1 -1
  114. package/lib/module/flags/DdFlags.js +4 -2
  115. package/lib/module/flags/DdFlags.js.map +1 -1
  116. package/lib/module/flags/FlagsClient.js +5 -2
  117. package/lib/module/flags/FlagsClient.js.map +1 -1
  118. package/lib/module/index.js +2 -1
  119. package/lib/module/index.js.map +1 -1
  120. package/lib/module/internal.js +27 -0
  121. package/lib/module/internal.js.map +1 -0
  122. package/lib/module/logs/DdLogs.js +4 -2
  123. package/lib/module/logs/DdLogs.js.map +1 -1
  124. package/lib/module/rum/DdRum.js +4 -2
  125. package/lib/module/rum/DdRum.js.map +1 -1
  126. package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +20 -14
  127. package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
  128. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -2
  129. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  130. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +1 -1
  131. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -1
  132. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
  133. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js +298 -0
  134. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js.map +1 -0
  135. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js +268 -0
  136. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js.map +1 -0
  137. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js +160 -0
  138. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js.map +1 -0
  139. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js +30 -0
  140. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js.map +1 -0
  141. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js +150 -0
  142. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js.map +1 -0
  143. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js +51 -0
  144. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js.map +1 -0
  145. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js +32 -0
  146. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js.map +1 -0
  147. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js +32 -0
  148. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js.map +1 -0
  149. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/types.js +2 -0
  150. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/types.js.map +1 -0
  151. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +17 -2
  152. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
  153. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +25 -3
  154. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
  155. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js +1 -34
  156. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js.map +1 -1
  157. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +3 -1
  158. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -1
  159. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js +8 -2
  160. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -1
  161. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js +79 -0
  162. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js.map +1 -0
  163. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
  164. package/lib/module/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js +2 -3
  165. package/lib/module/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js.map +1 -1
  166. package/lib/module/sdk/DdSdkInternal.js +27 -22
  167. package/lib/module/sdk/DdSdkInternal.js.map +1 -1
  168. package/lib/module/specs/NativeDdFlags.js +14 -2
  169. package/lib/module/specs/NativeDdFlags.js.map +1 -1
  170. package/lib/module/specs/NativeDdLogs.js +14 -2
  171. package/lib/module/specs/NativeDdLogs.js.map +1 -1
  172. package/lib/module/specs/NativeDdRum.js +14 -2
  173. package/lib/module/specs/NativeDdRum.js.map +1 -1
  174. package/lib/module/specs/NativeDdSdk.js +14 -2
  175. package/lib/module/specs/NativeDdSdk.js.map +1 -1
  176. package/lib/module/specs/NativeDdTrace.js +14 -2
  177. package/lib/module/specs/NativeDdTrace.js.map +1 -1
  178. package/lib/module/trace/DdTrace.js +4 -2
  179. package/lib/module/trace/DdTrace.js.map +1 -1
  180. package/lib/module/utils/stringUtils.js +42 -0
  181. package/lib/module/utils/stringUtils.js.map +1 -0
  182. package/lib/module/version.js +1 -1
  183. package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
  184. package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
  185. package/lib/typescript/config/FileBasedConfiguration.type.d.ts +4 -1
  186. package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
  187. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +6 -0
  188. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
  189. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +2 -1
  190. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
  191. package/lib/typescript/config/features/RumConfiguration.d.ts +6 -1
  192. package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
  193. package/lib/typescript/config/features/RumConfiguration.type.d.ts +116 -1
  194. package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
  195. package/lib/typescript/config/features/RumConfigurationNative.d.ts +2 -0
  196. package/lib/typescript/config/features/RumConfigurationNative.d.ts.map +1 -1
  197. package/lib/typescript/config/types/TimeseriesConfiguration.d.ts +19 -0
  198. package/lib/typescript/config/types/TimeseriesConfiguration.d.ts.map +1 -0
  199. package/lib/typescript/config/types/index.d.ts +2 -0
  200. package/lib/typescript/config/types/index.d.ts.map +1 -1
  201. package/lib/typescript/flags/DdFlags.d.ts.map +1 -1
  202. package/lib/typescript/flags/FlagsClient.d.ts +1 -1
  203. package/lib/typescript/flags/FlagsClient.d.ts.map +1 -1
  204. package/lib/typescript/index.d.ts +5 -2
  205. package/lib/typescript/index.d.ts.map +1 -1
  206. package/lib/typescript/internal.d.ts +26 -0
  207. package/lib/typescript/internal.d.ts.map +1 -0
  208. package/lib/typescript/logs/DdLogs.d.ts +1 -1
  209. package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
  210. package/lib/typescript/rum/DdRum.d.ts +1 -1
  211. package/lib/typescript/rum/DdRum.d.ts.map +1 -1
  212. package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
  213. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +3 -1
  214. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
  215. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +1 -0
  216. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts.map +1 -1
  217. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.d.ts +85 -0
  218. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.d.ts.map +1 -0
  219. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.d.ts +18 -0
  220. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.d.ts.map +1 -0
  221. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.d.ts +24 -0
  222. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.d.ts.map +1 -0
  223. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.d.ts +12 -0
  224. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.d.ts.map +1 -0
  225. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.d.ts +28 -0
  226. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.d.ts.map +1 -0
  227. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.d.ts +16 -0
  228. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.d.ts.map +1 -0
  229. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.d.ts +13 -0
  230. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.d.ts.map +1 -0
  231. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.d.ts +13 -0
  232. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.d.ts.map +1 -0
  233. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/types.d.ts +27 -0
  234. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/types.d.ts.map +1 -0
  235. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.d.ts.map +1 -1
  236. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
  237. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.d.ts.map +1 -1
  238. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts +2 -0
  239. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts.map +1 -1
  240. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.d.ts +43 -0
  241. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.d.ts.map +1 -0
  242. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +2 -0
  243. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts.map +1 -1
  244. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +2 -0
  245. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts.map +1 -1
  246. package/lib/typescript/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.d.ts.map +1 -1
  247. package/lib/typescript/sdk/DdSdkInternal.d.ts +1 -0
  248. package/lib/typescript/sdk/DdSdkInternal.d.ts.map +1 -1
  249. package/lib/typescript/specs/NativeDdFlags.d.ts +7 -2
  250. package/lib/typescript/specs/NativeDdFlags.d.ts.map +1 -1
  251. package/lib/typescript/specs/NativeDdLogs.d.ts +7 -2
  252. package/lib/typescript/specs/NativeDdLogs.d.ts.map +1 -1
  253. package/lib/typescript/specs/NativeDdRum.d.ts +7 -2
  254. package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
  255. package/lib/typescript/specs/NativeDdSdk.d.ts +7 -2
  256. package/lib/typescript/specs/NativeDdSdk.d.ts.map +1 -1
  257. package/lib/typescript/specs/NativeDdTrace.d.ts +7 -2
  258. package/lib/typescript/specs/NativeDdTrace.d.ts.map +1 -1
  259. package/lib/typescript/trace/DdTrace.d.ts.map +1 -1
  260. package/lib/typescript/utils/stringUtils.d.ts +12 -0
  261. package/lib/typescript/utils/stringUtils.d.ts.map +1 -0
  262. package/lib/typescript/version.d.ts +1 -1
  263. package/package.json +8 -3
  264. package/src/DdSdkReactNative.tsx +11 -1
  265. package/src/__tests__/DdSdkReactNative.test.tsx +145 -20
  266. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +6 -0
  267. package/src/__tests__/internalEntry.test.ts +26 -0
  268. package/src/__tests__/mock.test.ts +1 -3
  269. package/src/__tests__/nativeSpecGetters.test.ts +102 -0
  270. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +3 -3
  271. package/src/__tests__/wrapperImportSafety.test.ts +129 -0
  272. package/src/config/FileBasedConfiguration.ts +6 -1
  273. package/src/config/FileBasedConfiguration.type.ts +4 -0
  274. package/src/config/__tests__/FileBasedConfiguration.test.ts +73 -0
  275. package/src/config/__tests__/__fixtures__/configuration-all-fields.json +14 -1
  276. package/src/config/async/AutoInstrumentationConfiguration.ts +9 -1
  277. package/src/config/async/PartialInitializationConfiguration.ts +2 -0
  278. package/src/config/features/RumConfiguration.ts +15 -0
  279. package/src/config/features/RumConfiguration.type.ts +128 -1
  280. package/src/config/features/RumConfigurationNative.ts +3 -0
  281. package/src/config/types/TimeseriesConfiguration.ts +26 -0
  282. package/src/config/types/index.ts +5 -0
  283. package/src/flags/DdFlags.ts +4 -3
  284. package/src/flags/FlagsClient.ts +4 -3
  285. package/src/index.tsx +15 -0
  286. package/src/internal.ts +32 -0
  287. package/src/logs/DdLogs.ts +4 -3
  288. package/src/rum/DdRum.ts +4 -3
  289. package/src/rum/__tests__/DdRum.test.ts +4 -4
  290. package/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts +33 -26
  291. package/src/rum/instrumentation/interactionTracking/__tests__/BabelOptionalHandlers.test.ts +120 -0
  292. package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts +82 -2
  293. package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +7 -2
  294. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +46 -0
  295. package/src/rum/instrumentation/resourceTracking/__tests__/__utils__/XMLHttpRequestMock.ts +1 -1
  296. package/src/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.ts +1 -1
  297. package/src/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
  298. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/captureHeaders.test.ts +853 -0
  299. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/compileHeaderConfig.test.ts +697 -0
  300. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/enforceSizeLimits.integration.test.ts +183 -0
  301. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/enforceSizeLimits.test.ts +337 -0
  302. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/isHeaderAllowed.test.ts +35 -0
  303. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/normalizeUrlForMatching.test.ts +176 -0
  304. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/parseResponseHeaders.test.ts +114 -0
  305. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/sensitiveHeaderBlocklist.test.ts +112 -0
  306. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/tracingHeaderExclusion.test.ts +59 -0
  307. package/src/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.ts +437 -0
  308. package/src/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.ts +339 -0
  309. package/src/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.ts +208 -0
  310. package/src/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.ts +29 -0
  311. package/src/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.ts +181 -0
  312. package/src/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.ts +59 -0
  313. package/src/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.ts +31 -0
  314. package/src/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.ts +61 -0
  315. package/src/rum/instrumentation/resourceTracking/headerCapture/types.ts +33 -0
  316. package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.ts +21 -2
  317. package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/__tests__/FetchProxy.test.ts +274 -0
  318. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/__tests__/ResourceReporter.test.ts +120 -0
  319. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +34 -3
  320. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +624 -2
  321. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.ts +1 -34
  322. package/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.ts +6 -1
  323. package/src/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.ts +16 -2
  324. package/src/rum/instrumentation/resourceTracking/requestProxy/common/__tests__/headerCapture.test.ts +164 -0
  325. package/src/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.ts +119 -0
  326. package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.ts +2 -0
  327. package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.ts +2 -0
  328. package/src/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.tsx +3 -4
  329. package/src/sdk/DatadogInternalBridge/__tests__/DdSdkNativeBridge.test.tsx +35 -2
  330. package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +5 -5
  331. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +54 -1
  332. package/src/sdk/DdSdkInternal.ts +27 -24
  333. package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +2 -2
  334. package/src/specs/NativeDdFlags.ts +14 -2
  335. package/src/specs/NativeDdLogs.ts +14 -2
  336. package/src/specs/NativeDdRum.ts +14 -2
  337. package/src/specs/NativeDdSdk.ts +14 -2
  338. package/src/specs/NativeDdTrace.ts +14 -2
  339. package/src/trace/DdTrace.ts +4 -3
  340. package/src/utils/__tests__/stringUtils.test.ts +90 -0
  341. package/src/utils/stringUtils.ts +41 -0
  342. package/src/version.ts +1 -1
@@ -0,0 +1,181 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ // URL parsers ignore leading/trailing C0 control characters and spaces, and
8
+ // remove ASCII tabs and newlines anywhere in the URL.
9
+ // eslint-disable-next-line no-control-regex
10
+ const LEADING_TRAILING_C0_OR_SPACE = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g;
11
+ const TAB_OR_NEWLINE = /[\t\n\r]/g;
12
+
13
+ // HTTP(S) URL parsers accept any number of slashes (or backslashes) after the scheme
14
+ const HTTP_SCHEME_AND_SLASHES = /^(https?):[/\\]*/i;
15
+
16
+ const ENCODED_HOST_CHARACTER = /%([0-9a-fA-F]{2})/g;
17
+ const HOST_CHARACTER = /^[A-Za-z0-9.-]$/;
18
+ // Label separators that IDNA maps to '.'
19
+ const ALTERNATIVE_DOTS = /[\u3002\uFF0E\uFF61]/g;
20
+ // Characters that cannot appear in a hostname: decoding must never produce them,
21
+ // otherwise an encoded character could move the host boundary
22
+ // eslint-disable-next-line no-control-regex
23
+ const FORBIDDEN_HOST_CHARACTER = /[\u0000-\u0020/\\?#@:%<>[\]^|]/;
24
+
25
+ const SINGLE_DOT_SEGMENTS = new Set(['.', '%2e']);
26
+ const DOUBLE_DOT_SEGMENTS = new Set(['..', '.%2e', '%2e.', '%2e%2e']);
27
+
28
+ /**
29
+ * Normalizes a URL for `forURLs` scope matching, following the URL parsing
30
+ * semantics of HTTP clients:
31
+ * - leading/trailing control characters and spaces are trimmed, and tabs,
32
+ * CRs and LFs are removed;
33
+ * - extra slashes after `http(s):` are collapsed (`https:///host` -> `https://host`);
34
+ * - the scheme and authority are lowercased, and the hostname is normalized
35
+ * with {@link normalizeHostname};
36
+ * - an omitted path is treated as `/`;
37
+ * - in the path, backslashes are treated as slashes and dot segments
38
+ * (`.`, `..`, and their `%2e` encodings) are resolved;
39
+ * - path case, query and fragment are left untouched.
40
+ *
41
+ * Example: `HTTPS://API.Example.com/Public/../Private?Q=1` -> `https://api.example.com/Private?Q=1`
42
+ */
43
+ export const normalizeUrlForMatching = (rawUrl: string): string => {
44
+ const url = rawUrl
45
+ .replace(LEADING_TRAILING_C0_OR_SPACE, '')
46
+ .replace(TAB_OR_NEWLINE, '')
47
+ .replace(HTTP_SCHEME_AND_SLASHES, '$1://');
48
+ const schemeEnd = url.indexOf('://');
49
+ if (schemeEnd === -1) {
50
+ return url;
51
+ }
52
+
53
+ const authorityEnd = findFirstOf(url, schemeEnd + 3, '/\\?#');
54
+ const pathEnd = findFirstOf(url, authorityEnd, '?#');
55
+
56
+ return (
57
+ normalizeAuthority(url.slice(0, authorityEnd)) +
58
+ normalizePath(url.slice(authorityEnd, pathEnd)) +
59
+ url.slice(pathEnd)
60
+ );
61
+ };
62
+
63
+ /**
64
+ * Normalizes a hostname the way HTTP clients resolve it before connecting:
65
+ * percent-encodings are decoded, Unicode compatibility characters are mapped
66
+ * (NFKC, e.g. fullwidth letters), IDNA label separators (`。`, `.`, `。`)
67
+ * become `.`, and the result is lowercased.
68
+ * Used for both request URLs and configured `forURLs` hostnames.
69
+ *
70
+ * If decoding would produce a character that is not allowed in a hostname,
71
+ * only ASCII hostname characters are decoded.
72
+ */
73
+ export const normalizeHostname = (hostname: string): string => {
74
+ if (/^[A-Za-z0-9.-]*$/.test(hostname)) {
75
+ return hostname.toLowerCase();
76
+ }
77
+
78
+ const normalized = mapUnicodeHostname(decodeUtf8(hostname));
79
+ if (!FORBIDDEN_HOST_CHARACTER.test(normalized)) {
80
+ return normalized;
81
+ }
82
+
83
+ return mapUnicodeHostname(
84
+ hostname.replace(ENCODED_HOST_CHARACTER, (encoded, hex: string) => {
85
+ const char = String.fromCharCode(parseInt(hex, 16));
86
+ return HOST_CHARACTER.test(char) ? char : encoded;
87
+ })
88
+ );
89
+ };
90
+
91
+ const decodeUtf8 = (value: string): string => {
92
+ try {
93
+ return decodeURIComponent(value);
94
+ } catch (_e) {
95
+ // Malformed percent-encoding: leave it to the ASCII-only fallback
96
+ return value;
97
+ }
98
+ };
99
+
100
+ const mapUnicodeHostname = (hostname: string): string => {
101
+ let mapped = hostname;
102
+ try {
103
+ // Not available on every JS engine configuration
104
+ if (typeof mapped.normalize === 'function') {
105
+ mapped = mapped.normalize('NFKC');
106
+ }
107
+ } catch (_e) {
108
+ // Keep the unmapped hostname
109
+ }
110
+ return mapped.replace(ALTERNATIVE_DOTS, '.').toLowerCase();
111
+ };
112
+
113
+ /**
114
+ * Lowercases the scheme and authority and normalizes the hostname.
115
+ * Userinfo (before the last `@`) is lowercased but not decoded, and the port
116
+ * is kept as-is, so encoded characters can never move the host boundaries.
117
+ * IPv6 literals (`[...]`) are only lowercased.
118
+ */
119
+ const normalizeAuthority = (schemeAndAuthority: string): string => {
120
+ const userinfoEnd = schemeAndAuthority.lastIndexOf('@');
121
+ const hostStart =
122
+ userinfoEnd === -1
123
+ ? schemeAndAuthority.indexOf('://') + 3
124
+ : userinfoEnd + 1;
125
+ const hostAndPort = schemeAndAuthority.slice(hostStart);
126
+ const portMatch = /:\d*$/.exec(hostAndPort);
127
+ const host = portMatch
128
+ ? hostAndPort.slice(0, portMatch.index)
129
+ : hostAndPort;
130
+ const port = portMatch ? portMatch[0] : '';
131
+ const normalizedHost = host.startsWith('[')
132
+ ? host.toLowerCase()
133
+ : normalizeHostname(host);
134
+
135
+ return `${schemeAndAuthority
136
+ .slice(0, hostStart)
137
+ .toLowerCase()}${normalizedHost}${port}`;
138
+ };
139
+
140
+ const findFirstOf = (url: string, from: number, chars: string): number => {
141
+ for (let i = from; i < url.length; i++) {
142
+ if (chars.includes(url[i])) {
143
+ return i;
144
+ }
145
+ }
146
+ return url.length;
147
+ };
148
+
149
+ const normalizePath = (path: string): string => {
150
+ // HTTP requests without a path are sent to `/`
151
+ if (path === '') {
152
+ return '/';
153
+ }
154
+
155
+ // Fast path: nothing to resolve
156
+ if (!/[.\\%]/.test(path)) {
157
+ return path;
158
+ }
159
+
160
+ const segments = path.replace(/\\/g, '/').slice(1).split('/');
161
+ const output: string[] = [];
162
+
163
+ segments.forEach((segment, index) => {
164
+ const isLast = index === segments.length - 1;
165
+ const lowered = segment.toLowerCase();
166
+ if (DOUBLE_DOT_SEGMENTS.has(lowered)) {
167
+ output.pop();
168
+ if (isLast) {
169
+ output.push('');
170
+ }
171
+ } else if (SINGLE_DOT_SEGMENTS.has(lowered)) {
172
+ if (isLast) {
173
+ output.push('');
174
+ }
175
+ } else {
176
+ output.push(segment);
177
+ }
178
+ });
179
+
180
+ return `/${output.join('/')}`;
181
+ };
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ /**
8
+ * Parses a CRLF-delimited `getAllResponseHeaders()` string into a
9
+ * `Record<string, string>` of lowercase header names to trimmed values.
10
+ *
11
+ * Handles all edge cases defensively — SDK stability takes priority over
12
+ * strict compliance. Never throws on any input.
13
+ *
14
+ * - Splits on `\r?\n` to handle both CRLF and bare LF
15
+ * - Uses `indexOf(':')` so values containing colons (e.g. URLs) are preserved
16
+ * - Header names are trimmed and lowercased; values are trimmed (HTTP OWS)
17
+ * - Duplicate names resolve to last-value-wins
18
+ * - Malformed lines (no colon, empty name) are silently skipped
19
+ * - Headers rejected by `isAllowed` (if provided) are never stored
20
+ */
21
+ export const parseResponseHeaders = (
22
+ rawHeaders: string | null | undefined,
23
+ isAllowed?: (headerName: string) => boolean
24
+ ): Record<string, string> => {
25
+ if (!rawHeaders) {
26
+ return {};
27
+ }
28
+
29
+ const result: Record<string, string> = {};
30
+ const lines = rawHeaders.split(/\r?\n/);
31
+
32
+ for (const line of lines) {
33
+ // Skip empty lines (trailing delimiter produces empty last element)
34
+ if (line === '') {
35
+ continue;
36
+ }
37
+
38
+ const colonIndex = line.indexOf(':');
39
+
40
+ // No colon found, or colon is first character (empty name) — skip
41
+ if (colonIndex <= 0) {
42
+ continue;
43
+ }
44
+
45
+ const name = line.slice(0, colonIndex).trim().toLowerCase();
46
+
47
+ // Name is empty after trimming, or the header is not allowed — skip
48
+ if (name === '' || (isAllowed !== undefined && !isAllowed(name))) {
49
+ continue;
50
+ }
51
+
52
+ const value = line.slice(colonIndex + 1).trim();
53
+
54
+ // Last value wins for duplicate header names
55
+ result[name] = value;
56
+ }
57
+
58
+ return result;
59
+ };
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ /**
8
+ * Compiled regex matching sensitive header name patterns.
9
+ *
10
+ * Matches headers containing: token, cookie, secret, authorization, password,
11
+ * credential, bearer, api/secret/access/app key variants, forwarding/IP headers.
12
+ *
13
+ * The `/i` flag ensures case-insensitive matching. Compiled once at module load
14
+ * time — no per-call allocation.
15
+ */
16
+ const SENSITIVE_HEADER_PATTERN = /(?:token|cookie|secret|authorization|password|credential|bearer|(?:api|secret|access|app|application).?key|forwarded|real.?ip|connecting.?ip|client.?ip)/i;
17
+
18
+ /**
19
+ * Checks whether a header name matches a known sensitive header pattern.
20
+ * Sensitive headers (authorization, cookies, tokens, API keys, etc.) must
21
+ * never be captured regardless of configuration mode.
22
+ *
23
+ * Blocked headers are expected behavior, so they never produce WARN or ERROR
24
+ * logs; the capture pipeline only reports them at DEBUG verbosity.
25
+ *
26
+ * @param headerName - The header name to check (case-insensitive via regex /i flag).
27
+ * @returns `true` if the header is sensitive and must be blocked.
28
+ */
29
+ export const isSensitiveHeader = (headerName: string): boolean => {
30
+ return SENSITIVE_HEADER_PATTERN.test(headerName);
31
+ };
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ import {
8
+ SAMPLING_PRIORITY_HEADER_KEY,
9
+ ORIGIN_HEADER_KEY,
10
+ TRACE_ID_HEADER_KEY,
11
+ PARENT_ID_HEADER_KEY,
12
+ TAGS_HEADER_KEY,
13
+ TRACECONTEXT_HEADER_KEY,
14
+ TRACESTATE_HEADER_KEY,
15
+ BAGGAGE_HEADER_KEY,
16
+ B3_HEADER_KEY,
17
+ B3_MULTI_TRACE_ID_HEADER_KEY,
18
+ B3_MULTI_SPAN_ID_HEADER_KEY,
19
+ B3_MULTI_SAMPLED_HEADER_KEY,
20
+ TRACKED_BY_HEADER_KEY
21
+ } from '../distributedTracing/headers';
22
+
23
+ /**
24
+ * Set of all SDK-injected distributed tracing (and tracking) header names, lowercased.
25
+ *
26
+ * Built once at module load time from the canonical header constants in
27
+ * `distributedTracing/headers.ts`. The B3 multi-headers have mixed case
28
+ * (e.g. `X-B3-TraceId`), so all values are lowercased for uniform lookup.
29
+ */
30
+ const TRACING_HEADERS: Set<string> = new Set(
31
+ [
32
+ SAMPLING_PRIORITY_HEADER_KEY,
33
+ ORIGIN_HEADER_KEY,
34
+ TRACE_ID_HEADER_KEY,
35
+ PARENT_ID_HEADER_KEY,
36
+ TAGS_HEADER_KEY,
37
+ TRACECONTEXT_HEADER_KEY,
38
+ TRACESTATE_HEADER_KEY,
39
+ BAGGAGE_HEADER_KEY,
40
+ B3_HEADER_KEY,
41
+ B3_MULTI_TRACE_ID_HEADER_KEY,
42
+ B3_MULTI_SPAN_ID_HEADER_KEY,
43
+ B3_MULTI_SAMPLED_HEADER_KEY,
44
+ TRACKED_BY_HEADER_KEY
45
+ ].map(h => h.toLowerCase())
46
+ );
47
+
48
+ /**
49
+ * Checks whether a header name is an SDK-injected distributed tracing header.
50
+ * Tracing headers must never be captured because they are SDK internals,
51
+ * not application-level headers.
52
+ *
53
+ * Uses an explicit list (not prefix matching) — `x-datadog-customer-id`
54
+ * would NOT be excluded.
55
+ *
56
+ * @param headerName - The header name to check (lowercased internally for lookup).
57
+ * @returns `true` if the header is a tracing header and must be excluded.
58
+ */
59
+ export const isTracingHeader = (headerName: string): boolean => {
60
+ return TRACING_HEADERS.has(headerName.toLowerCase());
61
+ };
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ /**
8
+ * Compiled runtime representation of the header capture configuration.
9
+ * Produced once at SDK initialization by `compileHeaderCaptureConfig`.
10
+ *
11
+ * - `null` means header capture is disabled (undefined input, empty array, or invalid value).
12
+ * - `CompiledHeaderCaptureRule[]` contains one or more compiled rules to evaluate per request.
13
+ */
14
+ export type CompiledHeaderCaptureConfig = CompiledHeaderCaptureRule[] | null;
15
+
16
+ /**
17
+ * A single compiled URL-scoped header capture rule.
18
+ * Pre-built for O(1) per-request matching — no config traversal at capture time.
19
+ */
20
+ export type CompiledHeaderCaptureRule = {
21
+ /** Pre-built RegExp for URL matching (full URL string). */
22
+ urlRegex: RegExp;
23
+ /** Lowercased request header names. Set for O(1) lookup. */
24
+ requestHeaderNames: Set<string>;
25
+ /** Lowercased response header names. Set for O(1) lookup. */
26
+ responseHeaderNames: Set<string>;
27
+ /** True if this rule was compiled from specific forURLs patterns (not catch-all). */
28
+ isScoped: boolean;
29
+ /** Map from lowercased header name to original/config-provided casing for request headers. */
30
+ requestHeaderCasing: Map<string, string>;
31
+ /** Map from lowercased header name to original/config-provided casing for response headers. */
32
+ responseHeaderCasing: Map<string, string>;
33
+ };
@@ -12,6 +12,11 @@ import { callOriginalFetch } from '../common/FetchProxyState';
12
12
  import type { RequestContext } from '../common/RequestContext';
13
13
  import { createRequestContext, getResourceKey } from '../common/RequestContext';
14
14
  import { ResourceReporter } from '../common/ResourceReporter';
15
+ import {
16
+ fetchHeadersToRecord,
17
+ finalizeCapturedHeaders,
18
+ recordRequestHeader
19
+ } from '../common/headerCapture';
15
20
  import { filterDevResource } from '../common/internalDevResourceBlocklist';
16
21
  import {
17
22
  getInstrumentationHeaders,
@@ -202,7 +207,9 @@ const buildHeaders = ({
202
207
 
203
208
  originalHeaders.forEach(({ header }) => headers.delete(header));
204
209
  originalHeaders.forEach(({ header, value }) => {
205
- applyHeader({ headers, context, header, value });
210
+ if (applyHeader({ headers, context, header, value })) {
211
+ recordRequestHeader(context.headerCapture, header, value);
212
+ }
206
213
  });
207
214
  getInstrumentationHeaders(context).forEach(({ header, value }) => {
208
215
  applyHeader({ headers, context, header, value });
@@ -221,11 +228,13 @@ const applyHeader = ({
221
228
  context: RequestContext;
222
229
  header: string;
223
230
  value: string;
224
- }) => {
231
+ }): boolean => {
225
232
  const processedHeader = processRequestHeader({ context, header, value });
226
233
  if (processedHeader.type === 'send') {
227
234
  headers.set(processedHeader.header, processedHeader.value);
235
+ return true;
228
236
  }
237
+ return false;
229
238
  };
230
239
 
231
240
  const reportFetch = async ({
@@ -237,6 +246,15 @@ const reportFetch = async ({
237
246
  response: Response;
238
247
  resourceReporter: ResourceReporter;
239
248
  }): Promise<void> => {
249
+ // Snapshot before any await: some Fetch implementations expose mutable
250
+ // response headers that the app could change while the body is parsed.
251
+ const capturedHeaders = finalizeCapturedHeaders({
252
+ state: context.headerCapture,
253
+ url: context.url,
254
+ statusCode: response.status,
255
+ responseHeaders: () => fetchHeadersToRecord(response.headers)
256
+ });
257
+
240
258
  // Only extract GraphQL errors if operationType is set AND error tracking is enabled
241
259
  if (context.graphql.operationType && context.graphql.trackErrors) {
242
260
  try {
@@ -267,6 +285,7 @@ const reportFetch = async ({
267
285
  },
268
286
  graphqlAttributes: context.graphql,
269
287
  tracingAttributes: context.tracingAttributes,
288
+ ...capturedHeaders,
270
289
  response: {
271
290
  statusCode: response.status,
272
291
  size: getResponseSize(response)