@datadog/mobile-react-native 3.11.0 → 3.12.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 (304) hide show
  1. package/README.md +2 -1
  2. package/android/build.gradle +14 -5
  3. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  4. package/datadog-configuration.gradle +59 -18
  5. package/datadog-configuration.schema.json +119 -0
  6. package/ios/Sources/SdkVersion.swift +1 -1
  7. package/lib/commonjs/DdSdkReactNative.js +6 -1
  8. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  9. package/lib/commonjs/config/FileBasedConfiguration.js +2 -0
  10. package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
  11. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +2 -1
  12. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  13. package/lib/commonjs/config/features/RumConfiguration.js +4 -0
  14. package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
  15. package/lib/commonjs/flags/DdFlags.js +4 -2
  16. package/lib/commonjs/flags/DdFlags.js.map +1 -1
  17. package/lib/commonjs/flags/FlagsClient.js +4 -2
  18. package/lib/commonjs/flags/FlagsClient.js.map +1 -1
  19. package/lib/commonjs/internal.js +97 -0
  20. package/lib/commonjs/internal.js.map +1 -0
  21. package/lib/commonjs/logs/DdLogs.js +4 -2
  22. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  23. package/lib/commonjs/rum/DdRum.js +4 -2
  24. package/lib/commonjs/rum/DdRum.js.map +1 -1
  25. package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +20 -15
  26. package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
  27. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -2
  28. package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  29. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +2 -1
  30. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -1
  31. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
  32. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js +308 -0
  33. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js.map +1 -0
  34. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js +275 -0
  35. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js.map +1 -0
  36. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js +167 -0
  37. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js.map +1 -0
  38. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js +36 -0
  39. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js.map +1 -0
  40. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js +158 -0
  41. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js.map +1 -0
  42. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js +58 -0
  43. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js.map +1 -0
  44. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js +39 -0
  45. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js.map +1 -0
  46. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js +38 -0
  47. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js.map +1 -0
  48. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/types.js +2 -0
  49. package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/types.js.map +1 -0
  50. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +17 -2
  51. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
  52. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +25 -3
  53. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
  54. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js +2 -35
  55. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js.map +1 -1
  56. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +3 -1
  57. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -1
  58. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js +8 -2
  59. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -1
  60. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js +88 -0
  61. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js.map +1 -0
  62. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
  63. package/lib/commonjs/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js +2 -3
  64. package/lib/commonjs/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js.map +1 -1
  65. package/lib/commonjs/sdk/DdSdkInternal.js +27 -22
  66. package/lib/commonjs/sdk/DdSdkInternal.js.map +1 -1
  67. package/lib/commonjs/specs/NativeDdFlags.js +19 -3
  68. package/lib/commonjs/specs/NativeDdFlags.js.map +1 -1
  69. package/lib/commonjs/specs/NativeDdLogs.js +19 -3
  70. package/lib/commonjs/specs/NativeDdLogs.js.map +1 -1
  71. package/lib/commonjs/specs/NativeDdRum.js +19 -3
  72. package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
  73. package/lib/commonjs/specs/NativeDdSdk.js +19 -3
  74. package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
  75. package/lib/commonjs/specs/NativeDdTrace.js +19 -3
  76. package/lib/commonjs/specs/NativeDdTrace.js.map +1 -1
  77. package/lib/commonjs/trace/DdTrace.js +4 -2
  78. package/lib/commonjs/trace/DdTrace.js.map +1 -1
  79. package/lib/commonjs/utils/stringUtils.js +48 -0
  80. package/lib/commonjs/utils/stringUtils.js.map +1 -0
  81. package/lib/commonjs/version.js +1 -1
  82. package/lib/module/DdSdkReactNative.js +6 -1
  83. package/lib/module/DdSdkReactNative.js.map +1 -1
  84. package/lib/module/config/FileBasedConfiguration.js +2 -0
  85. package/lib/module/config/FileBasedConfiguration.js.map +1 -1
  86. package/lib/module/config/async/AutoInstrumentationConfiguration.js +2 -1
  87. package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  88. package/lib/module/config/features/RumConfiguration.js +4 -0
  89. package/lib/module/config/features/RumConfiguration.js.map +1 -1
  90. package/lib/module/flags/DdFlags.js +4 -2
  91. package/lib/module/flags/DdFlags.js.map +1 -1
  92. package/lib/module/flags/FlagsClient.js +5 -2
  93. package/lib/module/flags/FlagsClient.js.map +1 -1
  94. package/lib/module/internal.js +27 -0
  95. package/lib/module/internal.js.map +1 -0
  96. package/lib/module/logs/DdLogs.js +4 -2
  97. package/lib/module/logs/DdLogs.js.map +1 -1
  98. package/lib/module/rum/DdRum.js +4 -2
  99. package/lib/module/rum/DdRum.js.map +1 -1
  100. package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +20 -14
  101. package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
  102. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -2
  103. package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
  104. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +1 -1
  105. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -1
  106. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
  107. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js +298 -0
  108. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js.map +1 -0
  109. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js +268 -0
  110. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js.map +1 -0
  111. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js +160 -0
  112. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js.map +1 -0
  113. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js +30 -0
  114. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js.map +1 -0
  115. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js +150 -0
  116. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js.map +1 -0
  117. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js +51 -0
  118. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js.map +1 -0
  119. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js +32 -0
  120. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js.map +1 -0
  121. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js +32 -0
  122. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js.map +1 -0
  123. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/types.js +2 -0
  124. package/lib/module/rum/instrumentation/resourceTracking/headerCapture/types.js.map +1 -0
  125. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +17 -2
  126. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
  127. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +25 -3
  128. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
  129. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js +1 -34
  130. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js.map +1 -1
  131. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +3 -1
  132. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -1
  133. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js +8 -2
  134. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -1
  135. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js +79 -0
  136. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js.map +1 -0
  137. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
  138. package/lib/module/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js +2 -3
  139. package/lib/module/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js.map +1 -1
  140. package/lib/module/sdk/DdSdkInternal.js +27 -22
  141. package/lib/module/sdk/DdSdkInternal.js.map +1 -1
  142. package/lib/module/specs/NativeDdFlags.js +14 -2
  143. package/lib/module/specs/NativeDdFlags.js.map +1 -1
  144. package/lib/module/specs/NativeDdLogs.js +14 -2
  145. package/lib/module/specs/NativeDdLogs.js.map +1 -1
  146. package/lib/module/specs/NativeDdRum.js +14 -2
  147. package/lib/module/specs/NativeDdRum.js.map +1 -1
  148. package/lib/module/specs/NativeDdSdk.js +14 -2
  149. package/lib/module/specs/NativeDdSdk.js.map +1 -1
  150. package/lib/module/specs/NativeDdTrace.js +14 -2
  151. package/lib/module/specs/NativeDdTrace.js.map +1 -1
  152. package/lib/module/trace/DdTrace.js +4 -2
  153. package/lib/module/trace/DdTrace.js.map +1 -1
  154. package/lib/module/utils/stringUtils.js +42 -0
  155. package/lib/module/utils/stringUtils.js.map +1 -0
  156. package/lib/module/version.js +1 -1
  157. package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
  158. package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
  159. package/lib/typescript/config/FileBasedConfiguration.type.d.ts +2 -0
  160. package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
  161. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +3 -0
  162. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
  163. package/lib/typescript/config/features/RumConfiguration.d.ts +3 -1
  164. package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
  165. package/lib/typescript/config/features/RumConfiguration.type.d.ts +107 -0
  166. package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
  167. package/lib/typescript/flags/DdFlags.d.ts.map +1 -1
  168. package/lib/typescript/flags/FlagsClient.d.ts +1 -1
  169. package/lib/typescript/flags/FlagsClient.d.ts.map +1 -1
  170. package/lib/typescript/index.d.ts +1 -0
  171. package/lib/typescript/index.d.ts.map +1 -1
  172. package/lib/typescript/internal.d.ts +26 -0
  173. package/lib/typescript/internal.d.ts.map +1 -0
  174. package/lib/typescript/logs/DdLogs.d.ts +1 -1
  175. package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
  176. package/lib/typescript/rum/DdRum.d.ts +1 -1
  177. package/lib/typescript/rum/DdRum.d.ts.map +1 -1
  178. package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
  179. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +3 -1
  180. package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
  181. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +1 -0
  182. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts.map +1 -1
  183. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.d.ts +85 -0
  184. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.d.ts.map +1 -0
  185. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.d.ts +18 -0
  186. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.d.ts.map +1 -0
  187. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.d.ts +24 -0
  188. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.d.ts.map +1 -0
  189. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.d.ts +12 -0
  190. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.d.ts.map +1 -0
  191. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.d.ts +28 -0
  192. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.d.ts.map +1 -0
  193. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.d.ts +16 -0
  194. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.d.ts.map +1 -0
  195. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.d.ts +13 -0
  196. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.d.ts.map +1 -0
  197. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.d.ts +13 -0
  198. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.d.ts.map +1 -0
  199. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/types.d.ts +27 -0
  200. package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/types.d.ts.map +1 -0
  201. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.d.ts.map +1 -1
  202. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
  203. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.d.ts.map +1 -1
  204. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts +2 -0
  205. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts.map +1 -1
  206. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.d.ts +43 -0
  207. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.d.ts.map +1 -0
  208. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +2 -0
  209. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts.map +1 -1
  210. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +2 -0
  211. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts.map +1 -1
  212. package/lib/typescript/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.d.ts.map +1 -1
  213. package/lib/typescript/sdk/DdSdkInternal.d.ts +1 -0
  214. package/lib/typescript/sdk/DdSdkInternal.d.ts.map +1 -1
  215. package/lib/typescript/specs/NativeDdFlags.d.ts +7 -2
  216. package/lib/typescript/specs/NativeDdFlags.d.ts.map +1 -1
  217. package/lib/typescript/specs/NativeDdLogs.d.ts +7 -2
  218. package/lib/typescript/specs/NativeDdLogs.d.ts.map +1 -1
  219. package/lib/typescript/specs/NativeDdRum.d.ts +7 -2
  220. package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
  221. package/lib/typescript/specs/NativeDdSdk.d.ts +7 -2
  222. package/lib/typescript/specs/NativeDdSdk.d.ts.map +1 -1
  223. package/lib/typescript/specs/NativeDdTrace.d.ts +7 -2
  224. package/lib/typescript/specs/NativeDdTrace.d.ts.map +1 -1
  225. package/lib/typescript/trace/DdTrace.d.ts.map +1 -1
  226. package/lib/typescript/utils/stringUtils.d.ts +12 -0
  227. package/lib/typescript/utils/stringUtils.d.ts.map +1 -0
  228. package/lib/typescript/version.d.ts +1 -1
  229. package/package.json +7 -2
  230. package/src/DdSdkReactNative.tsx +11 -1
  231. package/src/__tests__/DdSdkReactNative.test.tsx +145 -20
  232. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -0
  233. package/src/__tests__/internalEntry.test.ts +26 -0
  234. package/src/__tests__/mock.test.ts +1 -3
  235. package/src/__tests__/nativeSpecGetters.test.ts +102 -0
  236. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +3 -3
  237. package/src/__tests__/wrapperImportSafety.test.ts +129 -0
  238. package/src/config/FileBasedConfiguration.ts +3 -0
  239. package/src/config/FileBasedConfiguration.type.ts +2 -0
  240. package/src/config/__tests__/FileBasedConfiguration.test.ts +66 -0
  241. package/src/config/__tests__/__fixtures__/configuration-all-fields.json +8 -0
  242. package/src/config/async/AutoInstrumentationConfiguration.ts +5 -1
  243. package/src/config/features/RumConfiguration.ts +9 -0
  244. package/src/config/features/RumConfiguration.type.ts +117 -0
  245. package/src/flags/DdFlags.ts +4 -3
  246. package/src/flags/FlagsClient.ts +4 -3
  247. package/src/index.tsx +7 -0
  248. package/src/internal.ts +32 -0
  249. package/src/logs/DdLogs.ts +4 -3
  250. package/src/rum/DdRum.ts +4 -3
  251. package/src/rum/__tests__/DdRum.test.ts +4 -4
  252. package/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts +33 -26
  253. package/src/rum/instrumentation/interactionTracking/__tests__/BabelOptionalHandlers.test.ts +120 -0
  254. package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts +82 -2
  255. package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +7 -2
  256. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +46 -0
  257. package/src/rum/instrumentation/resourceTracking/__tests__/__utils__/XMLHttpRequestMock.ts +1 -1
  258. package/src/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.ts +1 -1
  259. package/src/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
  260. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/captureHeaders.test.ts +853 -0
  261. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/compileHeaderConfig.test.ts +697 -0
  262. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/enforceSizeLimits.integration.test.ts +183 -0
  263. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/enforceSizeLimits.test.ts +337 -0
  264. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/isHeaderAllowed.test.ts +35 -0
  265. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/normalizeUrlForMatching.test.ts +176 -0
  266. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/parseResponseHeaders.test.ts +114 -0
  267. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/sensitiveHeaderBlocklist.test.ts +112 -0
  268. package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/tracingHeaderExclusion.test.ts +59 -0
  269. package/src/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.ts +437 -0
  270. package/src/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.ts +339 -0
  271. package/src/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.ts +208 -0
  272. package/src/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.ts +29 -0
  273. package/src/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.ts +181 -0
  274. package/src/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.ts +59 -0
  275. package/src/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.ts +31 -0
  276. package/src/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.ts +61 -0
  277. package/src/rum/instrumentation/resourceTracking/headerCapture/types.ts +33 -0
  278. package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.ts +21 -2
  279. package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/__tests__/FetchProxy.test.ts +274 -0
  280. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/__tests__/ResourceReporter.test.ts +120 -0
  281. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +34 -3
  282. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +624 -2
  283. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.ts +1 -34
  284. package/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.ts +6 -1
  285. package/src/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.ts +16 -2
  286. package/src/rum/instrumentation/resourceTracking/requestProxy/common/__tests__/headerCapture.test.ts +164 -0
  287. package/src/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.ts +119 -0
  288. package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.ts +2 -0
  289. package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.ts +2 -0
  290. package/src/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.tsx +3 -4
  291. package/src/sdk/DatadogInternalBridge/__tests__/DdSdkNativeBridge.test.tsx +35 -2
  292. package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +5 -5
  293. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +2 -1
  294. package/src/sdk/DdSdkInternal.ts +27 -24
  295. package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +2 -2
  296. package/src/specs/NativeDdFlags.ts +14 -2
  297. package/src/specs/NativeDdLogs.ts +14 -2
  298. package/src/specs/NativeDdRum.ts +14 -2
  299. package/src/specs/NativeDdSdk.ts +14 -2
  300. package/src/specs/NativeDdTrace.ts +14 -2
  301. package/src/trace/DdTrace.ts +4 -3
  302. package/src/utils/__tests__/stringUtils.test.ts +90 -0
  303. package/src/utils/stringUtils.ts +41 -0
  304. package/src/version.ts +1 -1
@@ -61,6 +61,7 @@ describe('DdSdkReactNativeConfiguration', () => {
61
61
  "customEndpoint": undefined,
62
62
  "errorEventMapper": null,
63
63
  "firstPartyHosts": [],
64
+ "headerCaptureRules": undefined,
64
65
  "initialResourceThreshold": undefined,
65
66
  "longTaskThresholdMs": 0,
66
67
  "nativeCrashReportEnabled": false,
@@ -212,6 +213,7 @@ describe('DdSdkReactNativeConfiguration', () => {
212
213
  ],
213
214
  },
214
215
  ],
216
+ "headerCaptureRules": undefined,
215
217
  "initialResourceThreshold": 0.123,
216
218
  "longTaskThresholdMs": 567,
217
219
  "nativeCrashReportEnabled": true,
@@ -320,6 +322,7 @@ describe('DdSdkReactNativeConfiguration', () => {
320
322
  "customEndpoint": undefined,
321
323
  "errorEventMapper": null,
322
324
  "firstPartyHosts": [],
325
+ "headerCaptureRules": undefined,
323
326
  "initialResourceThreshold": 0,
324
327
  "longTaskThresholdMs": false,
325
328
  "nativeCrashReportEnabled": false,
@@ -0,0 +1,26 @@
1
+ describe('./internal entry', () => {
2
+ it('exports the internals react-native-vega needs', () => {
3
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
4
+ const internal = require('../internal');
5
+ const expected = [
6
+ 'addDefaultValuesToAutoInstrumentationConfiguration',
7
+ 'buildConfigurationFromPartialConfiguration',
8
+ 'DdSdkNativeConfiguration',
9
+ 'RUM_DEFAULTS',
10
+ 'adaptLongTaskThreshold',
11
+ 'version',
12
+ 'AccountInfoSingleton',
13
+ 'AttributesSingleton',
14
+ 'UserInfoSingleton',
15
+ 'GlobalState',
16
+ 'BufferSingleton',
17
+ 'DatadogProviderState',
18
+ 'DdRumResourceTracking'
19
+ ];
20
+ for (const name of expected) {
21
+ expect(internal[name]).toBeDefined();
22
+ }
23
+ });
24
+
25
+ // Import safety of this entry point is covered in wrapperImportSafety.test.ts.
26
+ });
@@ -22,9 +22,8 @@ import { DdLogs, DdRum, DdTrace, DdSdkReactNative } from '../index';
22
22
  */
23
23
 
24
24
  const privateProperties = {
25
- DdTrace: ['nativeTrace'],
25
+ DdTrace: [],
26
26
  DdLogs: [
27
- 'nativeLogs',
28
27
  'logEventMapper',
29
28
  'printLogDroppedSdkNotInitialized',
30
29
  'printLogDroppedByMapper',
@@ -33,7 +32,6 @@ const privateProperties = {
33
32
  'logWithError'
34
33
  ],
35
34
  DdRum: [
36
- 'nativeRum',
37
35
  'errorEventMapper',
38
36
  'resourceEventMapper',
39
37
  'actionEventMapper',
@@ -0,0 +1,102 @@
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
+ describe('native spec getters', () => {
8
+ afterEach(() => {
9
+ jest.restoreAllMocks();
10
+ });
11
+
12
+ it.each([
13
+ ['../specs/NativeDdSdk', 'getNativeDdSdk', 'DdSdk'],
14
+ ['../specs/NativeDdRum', 'getNativeDdRum', 'DdRum'],
15
+ ['../specs/NativeDdLogs', 'getNativeDdLogs', 'DdLogs'],
16
+ ['../specs/NativeDdTrace', 'getNativeDdTrace', 'DdTrace'],
17
+ ['../specs/NativeDdFlags', 'getNativeDdFlags', 'DdFlags']
18
+ ])(
19
+ '%s retries a missing module and caches it once found',
20
+ (modulePath, getterName, registryName) => {
21
+ jest.isolateModules(() => {
22
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
23
+ const { TurboModuleRegistry } = require('react-native');
24
+ const nativeModule = { name: registryName };
25
+ const getSpy = jest
26
+ .spyOn(TurboModuleRegistry, 'get')
27
+ .mockReturnValueOnce(null)
28
+ .mockReturnValue(nativeModule);
29
+ // eslint-disable-next-line global-require, import/no-dynamic-require, @typescript-eslint/no-var-requires
30
+ const getter = require(modulePath)[getterName];
31
+
32
+ expect(getter()).toBeNull();
33
+ expect(getter()).toBe(nativeModule);
34
+ expect(getter()).toBe(nativeModule);
35
+ expect(getSpy).toHaveBeenCalledTimes(2);
36
+ expect(getSpy).toHaveBeenCalledWith(registryName);
37
+ });
38
+ }
39
+ );
40
+
41
+ it('FlagsClient retries a missing module and uses it for fetching and tracking', async () => {
42
+ await jest.isolateModulesAsync(async () => {
43
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
44
+ const { TurboModuleRegistry } = require('react-native');
45
+ const nativeModule = {
46
+ setEvaluationContext: jest.fn().mockResolvedValue({
47
+ feature: { key: 'feature', value: true, reason: 'STATIC' }
48
+ }),
49
+ trackEvaluation: jest.fn().mockResolvedValue(undefined)
50
+ };
51
+ const getSpy = jest
52
+ .spyOn(TurboModuleRegistry, 'get')
53
+ .mockReturnValueOnce(null)
54
+ .mockReturnValue(nativeModule);
55
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
56
+ const { FlagsClient } = require('../flags/FlagsClient');
57
+ const client = new FlagsClient('late-native');
58
+ const context = { targetingKey: 'user', attributes: {} };
59
+
60
+ expect(getSpy).not.toHaveBeenCalled();
61
+ await expect(
62
+ client.setEvaluationContext(context)
63
+ ).rejects.toThrow();
64
+ await expect(
65
+ client.setEvaluationContext(context)
66
+ ).resolves.toBeUndefined();
67
+ expect(nativeModule.setEvaluationContext).toHaveBeenCalledWith(
68
+ 'late-native',
69
+ 'user',
70
+ {}
71
+ );
72
+ expect(client.getBooleanValue('feature', false)).toBe(true);
73
+ expect(nativeModule.trackEvaluation).toHaveBeenCalledWith(
74
+ 'late-native',
75
+ 'feature',
76
+ expect.objectContaining({ value: true }),
77
+ 'user',
78
+ {}
79
+ );
80
+ expect(getSpy).toHaveBeenCalledTimes(2);
81
+ expect(getSpy).toHaveBeenCalledWith('DdFlags');
82
+ });
83
+ });
84
+
85
+ it('DdSdkWrapper picks up a module that was missing on first use', () => {
86
+ jest.isolateModules(() => {
87
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
88
+ const { TurboModuleRegistry } = require('react-native');
89
+ const nativeModule = { clearAllData: jest.fn() };
90
+ jest.spyOn(TurboModuleRegistry, 'get')
91
+ .mockReturnValueOnce(null)
92
+ .mockReturnValue(nativeModule);
93
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
94
+ const { DdSdkWrapper } = require('../sdk/DdSdkInternal');
95
+ const sdk = new DdSdkWrapper();
96
+
97
+ expect(() => sdk.clearAllData()).toThrow();
98
+ sdk.clearAllData();
99
+ expect(nativeModule.clearAllData).toHaveBeenCalledTimes(1);
100
+ });
101
+ });
102
+ });
@@ -21,7 +21,7 @@ import React from 'react';
21
21
  import type { DdNativeRumType } from '../../../nativeModulesTypes';
22
22
  import { DdRumUserInteractionTracking } from '../../../rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';
23
23
  import { BufferSingleton } from '../../../sdk/DatadogProvider/Buffer/BufferSingleton';
24
- import NativeDdSdkSpec from '../../../specs/NativeDdSdk';
24
+ import { getNativeDdSdk } from '../../../specs/NativeDdSdk';
25
25
 
26
26
  const styles = StyleSheet.create({
27
27
  button: {
@@ -467,7 +467,7 @@ describe('startTracking', () => {
467
467
  jest.setMock('react/jsx-runtime', {});
468
468
  DdRumUserInteractionTracking.startTracking({});
469
469
  expect(DdRumUserInteractionTracking['isTracking']).toBe(true);
470
- expect(NativeDdSdkSpec.telemetryDebug).toBeCalledWith(
470
+ expect(getNativeDdSdk()?.telemetryDebug).toBeCalledWith(
471
471
  'React jsx runtime does not export new jsx transform'
472
472
  );
473
473
  });
@@ -477,7 +477,7 @@ describe('startTracking', () => {
477
477
 
478
478
  DdRumUserInteractionTracking.startTracking({});
479
479
  expect(DdRumUserInteractionTracking['isTracking']).toBe(true);
480
- expect(NativeDdSdkSpec.telemetryDebug).toBeCalledWith(
480
+ expect(getNativeDdSdk()?.telemetryDebug).toBeCalledWith(
481
481
  'React version does not support new jsx transform'
482
482
  );
483
483
  });
@@ -0,0 +1,129 @@
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
+ * The spy must be installed on the `react-native` instance from inside
9
+ * `jest.isolateModules`: lookups made by isolated modules go through that
10
+ * registry, not the one imported at the top of a test file.
11
+ */
12
+ const requireCountingLookups = (modulePath: string) => {
13
+ let lookups: string[] = [];
14
+ let mod: any;
15
+ jest.isolateModules(() => {
16
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
17
+ const { TurboModuleRegistry } = require('react-native');
18
+ const getSpy = jest.spyOn(TurboModuleRegistry, 'get');
19
+ // eslint-disable-next-line global-require, import/no-dynamic-require
20
+ mod = require(modulePath);
21
+ lookups = getSpy.mock.calls.map(call => call[0] as string);
22
+ });
23
+ return { mod, lookups };
24
+ };
25
+
26
+ describe('SDK wrappers are import-safe', () => {
27
+ afterEach(() => {
28
+ jest.restoreAllMocks();
29
+ // Singletons live on globalThis, which isolateModules does not reset.
30
+ const g = globalThis as Record<PropertyKey, unknown>;
31
+ for (const symbol of Object.getOwnPropertySymbols(g)) {
32
+ if (symbol.description?.startsWith('com.datadog.reactnative')) {
33
+ delete g[symbol];
34
+ }
35
+ }
36
+ });
37
+
38
+ it.each([
39
+ '../specs/NativeDdSdk',
40
+ '../specs/NativeDdRum',
41
+ '../specs/NativeDdLogs',
42
+ '../specs/NativeDdTrace',
43
+ '../specs/NativeDdFlags',
44
+ '../sdk/DdSdkInternal',
45
+ '../rum/DdRum',
46
+ '../logs/DdLogs',
47
+ '../trace/DdTrace',
48
+ '../flags/DdFlags'
49
+ ])('importing %s performs no native lookup', modulePath => {
50
+ expect(requireCountingLookups(modulePath).lookups).toEqual([]);
51
+ });
52
+
53
+ it('DdSdkWrapper only resolves the native module when a method is used', () => {
54
+ jest.isolateModules(() => {
55
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
56
+ const { TurboModuleRegistry } = require('react-native');
57
+ const getSpy = jest.spyOn(TurboModuleRegistry, 'get');
58
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
59
+ const { DdSdkWrapper } = require('../sdk/DdSdkInternal');
60
+
61
+ const sdk = new DdSdkWrapper();
62
+ expect(getSpy).not.toHaveBeenCalled();
63
+
64
+ sdk.getConstants();
65
+ expect(getSpy).toHaveBeenCalledWith('DdSdk');
66
+ });
67
+ });
68
+
69
+ it('importing the public barrel performs no native lookup', () => {
70
+ expect(requireCountingLookups('../index').lookups).toEqual([]);
71
+ });
72
+
73
+ it('importing the internal entry performs no native lookup', () => {
74
+ expect(requireCountingLookups('../internal').lookups).toEqual([]);
75
+ });
76
+ });
77
+
78
+ describe('SDK wrappers do not rely on Proxy', () => {
79
+ // Older Android JSC and Hermes versions supported by the SDK lack Proxy.
80
+ it.each(['../sdk/DdSdkInternal', '../index', '../internal'])(
81
+ 'importing %s works without Proxy',
82
+ modulePath => {
83
+ const g = globalThis as Record<string, unknown>;
84
+ const originalProxy = g.Proxy;
85
+ try {
86
+ delete g.Proxy;
87
+ expect(() => requireCountingLookups(modulePath)).not.toThrow();
88
+ } finally {
89
+ g.Proxy = originalProxy;
90
+ }
91
+ }
92
+ );
93
+
94
+ it('DdSdkWrapper forwards every method to the native module', () => {
95
+ jest.isolateModules(() => {
96
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
97
+ const { TurboModuleRegistry } = require('react-native');
98
+ const nativeModule: Record<string, jest.Mock> = {};
99
+ jest.spyOn(TurboModuleRegistry, 'get').mockReturnValue(
100
+ nativeModule
101
+ );
102
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
103
+ const { DdSdkWrapper } = require('../sdk/DdSdkInternal');
104
+ const sdk = new DdSdkWrapper();
105
+ const methods = Object.getOwnPropertyNames(
106
+ DdSdkWrapper.prototype
107
+ ).filter(
108
+ name =>
109
+ name !== 'constructor' &&
110
+ !name.startsWith('_') &&
111
+ typeof Object.getOwnPropertyDescriptor(
112
+ DdSdkWrapper.prototype,
113
+ name
114
+ )?.value === 'function'
115
+ );
116
+ for (const name of methods) {
117
+ nativeModule[name] = jest.fn().mockReturnValue(name);
118
+ }
119
+
120
+ for (const name of methods) {
121
+ const arg =
122
+ name === 'initialize' ? { attributeEncoders: [] } : 'arg';
123
+ expect(sdk[name](arg)).toBe(name);
124
+ expect(nativeModule[name]).toHaveBeenCalledTimes(1);
125
+ }
126
+ expect(methods.length).toBeGreaterThan(15);
127
+ });
128
+ });
129
+ });
@@ -165,6 +165,9 @@ export const getJSONConfiguration = (
165
165
  buildFirstPartyHosts(
166
166
  configuration.rumConfiguration.firstPartyHosts
167
167
  ) || RUM_DEFAULTS.getFirstPartyHosts(),
168
+ // Validated when compiled at resource tracking start
169
+ headerCaptureRules:
170
+ configuration.rumConfiguration.headerCaptureRules,
168
171
  useAccessibilityLabel:
169
172
  configuration.rumConfiguration.useAccessibilityLabel,
170
173
  trackInteractions:
@@ -6,6 +6,7 @@
6
6
  import type { FirstPartyHost } from '../rum/types';
7
7
 
8
8
  import type { CoreConfigurationOptions } from './features/CoreConfiguration.type';
9
+ import type { HeaderCaptureRule } from './features/RumConfiguration.type';
9
10
  import type {
10
11
  BatchProcessingLevel,
11
12
  BatchSize,
@@ -40,6 +41,7 @@ export interface JsonConfiguration extends CoreConfigurationOptions {
40
41
  actionNameAttribute?: string;
41
42
  appHangThreshold?: number;
42
43
  firstPartyHosts?: FirstPartyHost[];
44
+ headerCaptureRules?: 'defaults' | HeaderCaptureRule[];
43
45
  initialResourceThreshold?: number;
44
46
  trackMemoryWarnings?: boolean;
45
47
  nativeCrashReportEnabled?: boolean;
@@ -55,6 +55,20 @@ describe('FileBasedConfiguration', () => {
55
55
  ],
56
56
  },
57
57
  ],
58
+ "headerCaptureRules": [
59
+ {
60
+ "type": "defaults",
61
+ },
62
+ {
63
+ "forURLs": [
64
+ "api.example.com",
65
+ ],
66
+ "headers": [
67
+ "x-request-id",
68
+ ],
69
+ "type": "matchResponseHeaders",
70
+ },
71
+ ],
58
72
  "initialResourceThreshold": 456,
59
73
  "longTaskThresholdMs": 44,
60
74
  "nativeCrashReportEnabled": true,
@@ -172,6 +186,7 @@ describe('FileBasedConfiguration', () => {
172
186
  ],
173
187
  },
174
188
  ],
189
+ "headerCaptureRules": undefined,
175
190
  "initialResourceThreshold": undefined,
176
191
  "longTaskThresholdMs": 44,
177
192
  "nativeCrashReportEnabled": false,
@@ -239,6 +254,7 @@ describe('FileBasedConfiguration', () => {
239
254
  "customEndpoint": undefined,
240
255
  "errorEventMapper": null,
241
256
  "firstPartyHosts": [],
257
+ "headerCaptureRules": undefined,
242
258
  "initialResourceThreshold": undefined,
243
259
  "longTaskThresholdMs": 0,
244
260
  "nativeCrashReportEnabled": false,
@@ -346,6 +362,56 @@ describe('FileBasedConfiguration', () => {
346
362
  ).toEqual(disallowList);
347
363
  });
348
364
 
365
+ it('leaves headerCaptureRules undefined when not set', () => {
366
+ const config = new FileBasedConfiguration({
367
+ configuration: {
368
+ env: 'fake-env',
369
+ clientToken: 'fake-client-token',
370
+ rumConfiguration: {
371
+ applicationId: 'fake-app-id'
372
+ }
373
+ }
374
+ });
375
+ expect(config.rumConfiguration?.headerCaptureRules).toBeUndefined();
376
+ });
377
+
378
+ it('passes the headerCaptureRules defaults preset through', () => {
379
+ const config = new FileBasedConfiguration({
380
+ configuration: {
381
+ env: 'fake-env',
382
+ clientToken: 'fake-client-token',
383
+ rumConfiguration: {
384
+ applicationId: 'fake-app-id',
385
+ headerCaptureRules: 'defaults'
386
+ }
387
+ }
388
+ });
389
+ expect(config.rumConfiguration?.headerCaptureRules).toBe(
390
+ 'defaults'
391
+ );
392
+ });
393
+
394
+ it('passes headerCaptureRules rules through', () => {
395
+ const rules = [
396
+ {
397
+ type: 'matchRequestHeaders',
398
+ headers: ['x-device-id'],
399
+ forURLs: ['api.example.com/v2']
400
+ }
401
+ ];
402
+ const config = new FileBasedConfiguration({
403
+ configuration: {
404
+ env: 'fake-env',
405
+ clientToken: 'fake-client-token',
406
+ rumConfiguration: {
407
+ applicationId: 'fake-app-id',
408
+ headerCaptureRules: rules
409
+ }
410
+ }
411
+ });
412
+ expect(config.rumConfiguration?.headerCaptureRules).toEqual(rules);
413
+ });
414
+
349
415
  it('applies event mappers to configuration when provided', () => {
350
416
  const actionEventMapper = () => null;
351
417
  const errorEventMapper = () => null;
@@ -25,6 +25,14 @@
25
25
  ]
26
26
  }
27
27
  ],
28
+ "headerCaptureRules": [
29
+ { "type": "defaults" },
30
+ {
31
+ "type": "matchResponseHeaders",
32
+ "headers": ["x-request-id"],
33
+ "forURLs": ["api.example.com"]
34
+ }
35
+ ],
28
36
  "initialResourceThreshold": 456,
29
37
  "nativeViewTracking": true,
30
38
  "nativeInteractionTracking": true,
@@ -9,6 +9,7 @@ import type { ResourceEventMapper } from '../../rum/eventMappers/resourceEventMa
9
9
  import type { FirstPartyHost } from '../../rum/types';
10
10
  import type { LogEventMapper } from '../../types';
11
11
  import { LOGS_DEFAULTS } from '../features/LogsConfiguration';
12
+ import type { HeaderCaptureRule } from '../features/RumConfiguration.type';
12
13
  import { RUM_DEFAULTS } from '../features/RumConfiguration';
13
14
  import type { TraceConfiguration } from '../features/TraceConfiguration';
14
15
 
@@ -25,6 +26,7 @@ export type AutoInstrumentationConfiguration = {
25
26
  readonly useAccessibilityLabel?: boolean;
26
27
  readonly actionNameAttribute?: string;
27
28
  readonly resourceTraceSampleRate?: number;
29
+ readonly headerCaptureRules?: 'defaults' | HeaderCaptureRule[];
28
30
  readonly nativeCrashReportEnabled?: boolean;
29
31
  readonly nativeLongTaskThresholdMs?: number;
30
32
  readonly nativeViewTracking?: boolean;
@@ -61,6 +63,7 @@ export type AutoInstrumentationParameters = {
61
63
  readonly errorEventMapper: ErrorEventMapper | null;
62
64
  readonly resourceEventMapper: ResourceEventMapper | null;
63
65
  readonly firstPartyHosts: FirstPartyHost[];
66
+ readonly headerCaptureRules?: 'defaults' | HeaderCaptureRule[];
64
67
  };
65
68
  readonly logsConfiguration?: {
66
69
  readonly logEventMapper: LogEventMapper | null;
@@ -128,7 +131,8 @@ export const addDefaultValuesToAutoInstrumentationConfiguration = (
128
131
  features.rumConfiguration.nativeIosResourceTrackingDisallowList,
129
132
  firstPartyHosts:
130
133
  features.rumConfiguration.firstPartyHosts ||
131
- RUM_DEFAULTS.getFirstPartyHosts()
134
+ RUM_DEFAULTS.getFirstPartyHosts(),
135
+ headerCaptureRules: features.rumConfiguration.headerCaptureRules
132
136
  },
133
137
  logsConfiguration: {
134
138
  logEventMapper:
@@ -10,6 +10,7 @@ import type { FirstPartyHost } from '../../rum/types';
10
10
  import { VitalsUpdateFrequency } from '../types';
11
11
 
12
12
  import type {
13
+ HeaderCaptureRule,
13
14
  RumConfigurationOptions,
14
15
  RumConfigurationType
15
16
  } from './RumConfiguration.type';
@@ -40,6 +41,10 @@ const DEFAULTS = {
40
41
  trackInteractions: false,
41
42
  trackMemoryWarnings: true,
42
43
  trackNonFatalAnrs: undefined,
44
+ headerCaptureRules: undefined as
45
+ | 'defaults'
46
+ | HeaderCaptureRule[]
47
+ | undefined,
43
48
  trackResources: false,
44
49
  trackWatchdogTerminations: false,
45
50
  useAccessibilityLabel: true,
@@ -126,6 +131,10 @@ export class RumConfiguration implements RumConfigurationType {
126
131
  // Track non-fatal ANRs enabled
127
132
  public trackNonFatalAnrs?: boolean = DEFAULTS.trackNonFatalAnrs;
128
133
 
134
+ // Header Capture Rules
135
+ public headerCaptureRules: 'defaults' | HeaderCaptureRule[] | undefined =
136
+ DEFAULTS.headerCaptureRules;
137
+
129
138
  // Track Watchdog Terminations enabled
130
139
  public trackWatchdogTerminations: boolean =
131
140
  DEFAULTS.trackWatchdogTerminations;
@@ -37,6 +37,108 @@ export interface RumConfigurationRequired {
37
37
  trackErrors?: boolean;
38
38
  }
39
39
 
40
+ /**
41
+ * Captures a predefined set of caching and content headers from both
42
+ * request and response.
43
+ *
44
+ * Default headers captured:
45
+ * - **Response:** cache-control, etag, age, expires, content-type,
46
+ * content-encoding, content-length, vary, server-timing, x-cache
47
+ * - **Request:** cache-control, content-type
48
+ *
49
+ * Optionally scoped to specific URLs via `forURLs`.
50
+ */
51
+ export type DefaultsRule = {
52
+ type: 'defaults';
53
+ /**
54
+ * URL patterns to scope this rule to. Supports hostname-only
55
+ * ('api.example.com') or hostname+path prefix ('api.example.com/v2').
56
+ * Omit to match all URLs.
57
+ */
58
+ forURLs?: string[];
59
+ };
60
+
61
+ /**
62
+ * Captures the specified headers from both request and response.
63
+ *
64
+ * Use this when the same header names should be captured regardless
65
+ * of direction (e.g. 'content-type', 'x-request-id').
66
+ * Optionally scoped to specific URLs via `forURLs`.
67
+ */
68
+ export type MatchHeadersRule = {
69
+ type: 'matchHeaders';
70
+ /**
71
+ * Header names to capture from both request and response.
72
+ * Preserved as-is; compared case-insensitively at capture time.
73
+ */
74
+ headers: string[];
75
+ /**
76
+ * URL patterns to scope this rule to. Supports hostname-only
77
+ * ('api.example.com') or hostname+path prefix ('api.example.com/v2').
78
+ * Omit to match all URLs.
79
+ */
80
+ forURLs?: string[];
81
+ };
82
+
83
+ /**
84
+ * Captures the specified headers from requests only.
85
+ *
86
+ * Use this when you need to capture request-specific headers
87
+ * (e.g. 'x-request-id', 'if-none-match') without capturing response headers.
88
+ * Optionally scoped to specific URLs via `forURLs`.
89
+ */
90
+ export type MatchRequestHeadersRule = {
91
+ type: 'matchRequestHeaders';
92
+ /**
93
+ * Request header names to capture.
94
+ * Preserved as-is; compared case-insensitively at capture time.
95
+ */
96
+ headers: string[];
97
+ /**
98
+ * URL patterns to scope this rule to. Supports hostname-only
99
+ * ('api.example.com') or hostname+path prefix ('api.example.com/v2').
100
+ * Omit to match all URLs.
101
+ */
102
+ forURLs?: string[];
103
+ };
104
+
105
+ /**
106
+ * Captures the specified headers from responses only.
107
+ *
108
+ * Use this when you need to capture response-specific headers
109
+ * (e.g. 'x-request-id', 'x-ratelimit-remaining') without capturing
110
+ * request headers.
111
+ * Optionally scoped to specific URLs via `forURLs`.
112
+ */
113
+ export type MatchResponseHeadersRule = {
114
+ type: 'matchResponseHeaders';
115
+ /**
116
+ * Response header names to capture.
117
+ * Preserved as-is; compared case-insensitively at capture time.
118
+ */
119
+ headers: string[];
120
+ /**
121
+ * URL patterns to scope this rule to. Supports hostname-only
122
+ * ('api.example.com') or hostname+path prefix ('api.example.com/v2').
123
+ * Omit to match all URLs.
124
+ */
125
+ forURLs?: string[];
126
+ };
127
+
128
+ /**
129
+ * A composable header capture rule.
130
+ *
131
+ * Discriminated union on the `type` field. Multiple rules can be combined
132
+ * in an array. Matching rules are merged additively (union of headers).
133
+ * If at least one scoped rule (explicit `forURLs` patterns) matches a URL,
134
+ * catch-all rules (omitted `forURLs` / `['*']`) are ignored for that URL.
135
+ */
136
+ export type HeaderCaptureRule =
137
+ | DefaultsRule
138
+ | MatchHeadersRule
139
+ | MatchRequestHeadersRule
140
+ | MatchResponseHeadersRule;
141
+
40
142
  /**
41
143
  * Optional RUM configuration values.
42
144
  */
@@ -79,6 +181,21 @@ export interface RumConfigurationOptions {
79
181
  */
80
182
  firstPartyHosts?: FirstPartyHost[];
81
183
 
184
+ /**
185
+ * Controls which resource headers the SDK captures on network requests.
186
+ *
187
+ * - **Omitted** (default): No headers are captured.
188
+ * - `'defaults'`: Captures a predefined set of caching and content headers
189
+ * across all URLs.
190
+ * - `HeaderCaptureRule[]`: An array of composable rules. When multiple rules
191
+ * match a URL their header sets are merged. If at least one scoped rule
192
+ * (with explicit `forURLs` patterns) matches, catch-all rules (no `forURLs`
193
+ * or `['*']`) are ignored for that URL.
194
+ *
195
+ * Requires `trackResources: true` to take effect.
196
+ */
197
+ headerCaptureRules?: 'defaults' | HeaderCaptureRule[];
198
+
82
199
  /**
83
200
  * Initial resource collection threshold in seconds.
84
201
  */