@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.
- package/README.md +2 -1
- package/android/build.gradle +14 -5
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/datadog-configuration.gradle +59 -18
- package/datadog-configuration.schema.json +119 -0
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +6 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/config/FileBasedConfiguration.js +2 -0
- package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +2 -1
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/commonjs/config/features/RumConfiguration.js +4 -0
- package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
- package/lib/commonjs/flags/DdFlags.js +4 -2
- package/lib/commonjs/flags/DdFlags.js.map +1 -1
- package/lib/commonjs/flags/FlagsClient.js +4 -2
- package/lib/commonjs/flags/FlagsClient.js.map +1 -1
- package/lib/commonjs/internal.js +97 -0
- package/lib/commonjs/internal.js.map +1 -0
- package/lib/commonjs/logs/DdLogs.js +4 -2
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +4 -2
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +20 -15
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +2 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js +308 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js +275 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js +167 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js +36 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js +158 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js +58 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js +39 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js +38 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/types.js +2 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/types.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +17 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +25 -3
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js +2 -35
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +3 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js +8 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js +88 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
- package/lib/commonjs/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js +2 -3
- package/lib/commonjs/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js.map +1 -1
- package/lib/commonjs/sdk/DdSdkInternal.js +27 -22
- package/lib/commonjs/sdk/DdSdkInternal.js.map +1 -1
- package/lib/commonjs/specs/NativeDdFlags.js +19 -3
- package/lib/commonjs/specs/NativeDdFlags.js.map +1 -1
- package/lib/commonjs/specs/NativeDdLogs.js +19 -3
- package/lib/commonjs/specs/NativeDdLogs.js.map +1 -1
- package/lib/commonjs/specs/NativeDdRum.js +19 -3
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
- package/lib/commonjs/specs/NativeDdSdk.js +19 -3
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
- package/lib/commonjs/specs/NativeDdTrace.js +19 -3
- package/lib/commonjs/specs/NativeDdTrace.js.map +1 -1
- package/lib/commonjs/trace/DdTrace.js +4 -2
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/utils/stringUtils.js +48 -0
- package/lib/commonjs/utils/stringUtils.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +6 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/config/FileBasedConfiguration.js +2 -0
- package/lib/module/config/FileBasedConfiguration.js.map +1 -1
- package/lib/module/config/async/AutoInstrumentationConfiguration.js +2 -1
- package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/module/config/features/RumConfiguration.js +4 -0
- package/lib/module/config/features/RumConfiguration.js.map +1 -1
- package/lib/module/flags/DdFlags.js +4 -2
- package/lib/module/flags/DdFlags.js.map +1 -1
- package/lib/module/flags/FlagsClient.js +5 -2
- package/lib/module/flags/FlagsClient.js.map +1 -1
- package/lib/module/internal.js +27 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/logs/DdLogs.js +4 -2
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/rum/DdRum.js +4 -2
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +20 -14
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -2
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js +298 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js +268 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js +160 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js +30 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js +150 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js +51 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js +32 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js +32 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/types.js +2 -0
- package/lib/module/rum/instrumentation/resourceTracking/headerCapture/types.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +17 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +25 -3
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js +1 -34
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +3 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js +8 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js +79 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
- package/lib/module/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js +2 -3
- package/lib/module/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.js.map +1 -1
- package/lib/module/sdk/DdSdkInternal.js +27 -22
- package/lib/module/sdk/DdSdkInternal.js.map +1 -1
- package/lib/module/specs/NativeDdFlags.js +14 -2
- package/lib/module/specs/NativeDdFlags.js.map +1 -1
- package/lib/module/specs/NativeDdLogs.js +14 -2
- package/lib/module/specs/NativeDdLogs.js.map +1 -1
- package/lib/module/specs/NativeDdRum.js +14 -2
- package/lib/module/specs/NativeDdRum.js.map +1 -1
- package/lib/module/specs/NativeDdSdk.js +14 -2
- package/lib/module/specs/NativeDdSdk.js.map +1 -1
- package/lib/module/specs/NativeDdTrace.js +14 -2
- package/lib/module/specs/NativeDdTrace.js.map +1 -1
- package/lib/module/trace/DdTrace.js +4 -2
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/utils/stringUtils.js +42 -0
- package/lib/module/utils/stringUtils.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts +2 -0
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +3 -0
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.d.ts +3 -1
- package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.type.d.ts +107 -0
- package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/flags/DdFlags.d.ts.map +1 -1
- package/lib/typescript/flags/FlagsClient.d.ts +1 -1
- package/lib/typescript/flags/FlagsClient.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/internal.d.ts +26 -0
- package/lib/typescript/internal.d.ts.map +1 -0
- package/lib/typescript/logs/DdLogs.d.ts +1 -1
- package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
- package/lib/typescript/rum/DdRum.d.ts +1 -1
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +3 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.d.ts +85 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.d.ts +18 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.d.ts +24 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.d.ts +12 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.d.ts +28 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.d.ts +16 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.d.ts +13 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.d.ts +13 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/types.d.ts +27 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/headerCapture/types.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts +2 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.d.ts +43 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +2 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +2 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts.map +1 -1
- package/lib/typescript/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.d.ts.map +1 -1
- package/lib/typescript/sdk/DdSdkInternal.d.ts +1 -0
- package/lib/typescript/sdk/DdSdkInternal.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdFlags.d.ts +7 -2
- package/lib/typescript/specs/NativeDdFlags.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdLogs.d.ts +7 -2
- package/lib/typescript/specs/NativeDdLogs.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdRum.d.ts +7 -2
- package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdSdk.d.ts +7 -2
- package/lib/typescript/specs/NativeDdSdk.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdTrace.d.ts +7 -2
- package/lib/typescript/specs/NativeDdTrace.d.ts.map +1 -1
- package/lib/typescript/trace/DdTrace.d.ts.map +1 -1
- package/lib/typescript/utils/stringUtils.d.ts +12 -0
- package/lib/typescript/utils/stringUtils.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +7 -2
- package/src/DdSdkReactNative.tsx +11 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +145 -20
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -0
- package/src/__tests__/internalEntry.test.ts +26 -0
- package/src/__tests__/mock.test.ts +1 -3
- package/src/__tests__/nativeSpecGetters.test.ts +102 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +3 -3
- package/src/__tests__/wrapperImportSafety.test.ts +129 -0
- package/src/config/FileBasedConfiguration.ts +3 -0
- package/src/config/FileBasedConfiguration.type.ts +2 -0
- package/src/config/__tests__/FileBasedConfiguration.test.ts +66 -0
- package/src/config/__tests__/__fixtures__/configuration-all-fields.json +8 -0
- package/src/config/async/AutoInstrumentationConfiguration.ts +5 -1
- package/src/config/features/RumConfiguration.ts +9 -0
- package/src/config/features/RumConfiguration.type.ts +117 -0
- package/src/flags/DdFlags.ts +4 -3
- package/src/flags/FlagsClient.ts +4 -3
- package/src/index.tsx +7 -0
- package/src/internal.ts +32 -0
- package/src/logs/DdLogs.ts +4 -3
- package/src/rum/DdRum.ts +4 -3
- package/src/rum/__tests__/DdRum.test.ts +4 -4
- package/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts +33 -26
- package/src/rum/instrumentation/interactionTracking/__tests__/BabelOptionalHandlers.test.ts +120 -0
- package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts +82 -2
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +7 -2
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +46 -0
- package/src/rum/instrumentation/resourceTracking/__tests__/__utils__/XMLHttpRequestMock.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/headerCapture/README.md +142 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/captureHeaders.test.ts +853 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/compileHeaderConfig.test.ts +697 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/enforceSizeLimits.integration.test.ts +183 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/enforceSizeLimits.test.ts +337 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/isHeaderAllowed.test.ts +35 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/normalizeUrlForMatching.test.ts +176 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/parseResponseHeaders.test.ts +114 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/sensitiveHeaderBlocklist.test.ts +112 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/__tests__/tracingHeaderExclusion.test.ts +59 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/captureHeaders.ts +437 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/compileHeaderConfig.ts +339 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.ts +208 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.ts +29 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.ts +181 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.ts +59 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.ts +31 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.ts +61 -0
- package/src/rum/instrumentation/resourceTracking/headerCapture/types.ts +33 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.ts +21 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/__tests__/FetchProxy.test.ts +274 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/__tests__/ResourceReporter.test.ts +120 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +34 -3
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +624 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.ts +1 -34
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.ts +6 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.ts +16 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/__tests__/headerCapture.test.ts +164 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/headerCapture.ts +119 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.ts +2 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.ts +2 -0
- package/src/sdk/DatadogEventEmitter/DatadogDefaultEventEmitter.tsx +3 -4
- package/src/sdk/DatadogInternalBridge/__tests__/DdSdkNativeBridge.test.tsx +35 -2
- package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +5 -5
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +2 -1
- package/src/sdk/DdSdkInternal.ts +27 -24
- package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +2 -2
- package/src/specs/NativeDdFlags.ts +14 -2
- package/src/specs/NativeDdLogs.ts +14 -2
- package/src/specs/NativeDdRum.ts +14 -2
- package/src/specs/NativeDdSdk.ts +14 -2
- package/src/specs/NativeDdTrace.ts +14 -2
- package/src/trace/DdTrace.ts +4 -3
- package/src/utils/__tests__/stringUtils.test.ts +90 -0
- package/src/utils/stringUtils.ts +41 -0
- 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)
|