@datadog/mobile-react-native 3.11.0 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +357 -14
- package/README.md +5 -3
- package/android/build.gradle +23 -14
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +27 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +27 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +25 -0
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +4 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +104 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +8 -0
- package/android/src/test/resources/input/complete-configuration.json +5 -0
- package/datadog-configuration.gradle +59 -18
- package/datadog-configuration.schema.json +140 -0
- package/ios/Sources/DdFlagsImplementation.swift +3 -0
- package/ios/Sources/DdSdkConfiguration.swift +11 -1
- package/ios/Sources/DdSdkNativeInitialization.swift +24 -2
- package/ios/Sources/RNDdSdkConfiguration.swift +14 -2
- 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 +4 -1
- package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +3 -1
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/commonjs/config/features/RumConfiguration.js +8 -0
- package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
- package/lib/commonjs/config/features/RumConfigurationNative.js +4 -0
- package/lib/commonjs/config/types/TimeseriesConfiguration.js +25 -0
- package/lib/commonjs/config/types/TimeseriesConfiguration.js.map +1 -0
- package/lib/commonjs/config/types/index.js +7 -0
- package/lib/commonjs/config/types/index.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/index.js +7 -0
- package/lib/commonjs/index.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 +4 -1
- package/lib/module/config/FileBasedConfiguration.js.map +1 -1
- package/lib/module/config/async/AutoInstrumentationConfiguration.js +3 -1
- package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/module/config/features/RumConfiguration.js +8 -0
- package/lib/module/config/features/RumConfiguration.js.map +1 -1
- package/lib/module/config/features/RumConfigurationNative.js +1 -1
- package/lib/module/config/types/TimeseriesConfiguration.js +19 -0
- package/lib/module/config/types/TimeseriesConfiguration.js.map +1 -0
- package/lib/module/config/types/index.js +1 -0
- package/lib/module/config/types/index.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/index.js +2 -1
- package/lib/module/index.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 +4 -1
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +6 -0
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +2 -1
- package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.d.ts +6 -1
- package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.type.d.ts +116 -1
- package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfigurationNative.d.ts +2 -0
- package/lib/typescript/config/features/RumConfigurationNative.d.ts.map +1 -1
- package/lib/typescript/config/types/TimeseriesConfiguration.d.ts +19 -0
- package/lib/typescript/config/types/TimeseriesConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/types/index.d.ts +2 -0
- package/lib/typescript/config/types/index.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 +5 -2
- 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 +8 -3
- package/src/DdSdkReactNative.tsx +11 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +145 -20
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +6 -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 +6 -1
- package/src/config/FileBasedConfiguration.type.ts +4 -0
- package/src/config/__tests__/FileBasedConfiguration.test.ts +73 -0
- package/src/config/__tests__/__fixtures__/configuration-all-fields.json +14 -1
- package/src/config/async/AutoInstrumentationConfiguration.ts +9 -1
- package/src/config/async/PartialInitializationConfiguration.ts +2 -0
- package/src/config/features/RumConfiguration.ts +15 -0
- package/src/config/features/RumConfiguration.type.ts +128 -1
- package/src/config/features/RumConfigurationNative.ts +3 -0
- package/src/config/types/TimeseriesConfiguration.ts +26 -0
- package/src/config/types/index.ts +5 -0
- package/src/flags/DdFlags.ts +4 -3
- package/src/flags/FlagsClient.ts +4 -3
- package/src/index.tsx +15 -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 +54 -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,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.enforceSizeLimits = exports.MAX_TOTAL_BYTES = exports.MAX_HEADER_VALUE_BYTES = exports.MAX_HEADER_COUNT = void 0;
|
|
7
|
+
var _InternalLog = require("../../../../InternalLog");
|
|
8
|
+
var _types = require("../../../../config/types");
|
|
9
|
+
var _stringUtils = require("../../../../utils/stringUtils");
|
|
10
|
+
/*
|
|
11
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const TAG = '[DatadogRUM][HeaderCapture]';
|
|
17
|
+
|
|
18
|
+
/** Maximum UTF-8 byte length for any single header value. */
|
|
19
|
+
|
|
20
|
+
const MAX_HEADER_VALUE_BYTES = exports.MAX_HEADER_VALUE_BYTES = 128;
|
|
21
|
+
|
|
22
|
+
/** Maximum combined header count (request + response). */
|
|
23
|
+
const MAX_HEADER_COUNT = exports.MAX_HEADER_COUNT = 100;
|
|
24
|
+
|
|
25
|
+
/** Maximum total UTF-8 bytes across all header names and values. */
|
|
26
|
+
const MAX_TOTAL_BYTES = exports.MAX_TOTAL_BYTES = 2048;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Truncates a string so its UTF-8 byte length does not exceed maxBytes.
|
|
30
|
+
* Single forward pass — O(n). Mirrors the surrogate-pair logic in utf8ByteLength.
|
|
31
|
+
*/
|
|
32
|
+
const truncateToBytes = (str, maxBytes) => {
|
|
33
|
+
let bytes = 0;
|
|
34
|
+
for (let i = 0; i < str.length; i++) {
|
|
35
|
+
const code = str.charCodeAt(i);
|
|
36
|
+
let charBytes;
|
|
37
|
+
let advance = 1;
|
|
38
|
+
if (code < 0x80) {
|
|
39
|
+
charBytes = 1;
|
|
40
|
+
} else if (code < 0x800) {
|
|
41
|
+
charBytes = 2;
|
|
42
|
+
} else if (code >= 0xd800 && code <= 0xdbff) {
|
|
43
|
+
const next = i + 1 < str.length ? str.charCodeAt(i + 1) : 0;
|
|
44
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
45
|
+
charBytes = 4;
|
|
46
|
+
advance = 2;
|
|
47
|
+
} else {
|
|
48
|
+
charBytes = 3; // lone high surrogate
|
|
49
|
+
}
|
|
50
|
+
} else if (code >= 0xdc00 && code <= 0xdfff) {
|
|
51
|
+
charBytes = 3; // lone low surrogate
|
|
52
|
+
} else {
|
|
53
|
+
charBytes = 3;
|
|
54
|
+
}
|
|
55
|
+
if (bytes + charBytes > maxBytes) {
|
|
56
|
+
return str.slice(0, i);
|
|
57
|
+
}
|
|
58
|
+
bytes += charBytes;
|
|
59
|
+
i += advance - 1; // -1 because the for-loop will also increment i
|
|
60
|
+
}
|
|
61
|
+
return str;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Converts a non-empty record to undefined-or-record.
|
|
66
|
+
* Locked decision: no empty objects -- undefined or absent, not `{}`.
|
|
67
|
+
*/
|
|
68
|
+
const toUndefinedIfEmpty = record => {
|
|
69
|
+
return Object.keys(record).length > 0 ? record : undefined;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Enforces per-value truncation, header count cap, and total size budget
|
|
74
|
+
* on captured header records. All limits are in UTF-8 bytes.
|
|
75
|
+
*
|
|
76
|
+
* Processing order:
|
|
77
|
+
* 1. Short-circuit if both inputs undefined
|
|
78
|
+
* 2. Truncate each value to MAX_HEADER_VALUE_BYTES
|
|
79
|
+
* 3. Cap combined count to MAX_HEADER_COUNT (request priority)
|
|
80
|
+
* 4. Drop headers from end until total bytes <= MAX_TOTAL_BYTES
|
|
81
|
+
* 5. Return undefined (not {}) for empty records
|
|
82
|
+
*
|
|
83
|
+
* Pure function with no stateful side effects (emits DEBUG logs when limits are hit).
|
|
84
|
+
*/
|
|
85
|
+
const enforceSizeLimits = (requestHeaders, responseHeaders) => {
|
|
86
|
+
// Step 1: Short-circuit
|
|
87
|
+
if (requestHeaders === undefined && responseHeaders === undefined) {
|
|
88
|
+
return {
|
|
89
|
+
requestHeaders: undefined,
|
|
90
|
+
responseHeaders: undefined
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Step 2: Truncate values to MAX_HEADER_VALUE_BYTES (UTF-8 bytes)
|
|
95
|
+
const reqEntries = requestHeaders ? Object.entries(requestHeaders).map(([name, value]) => {
|
|
96
|
+
const truncated = truncateToBytes(value, MAX_HEADER_VALUE_BYTES);
|
|
97
|
+
if (truncated.length < value.length) {
|
|
98
|
+
_InternalLog.InternalLog.log(`${TAG} Truncated request header "${name}" value from ${(0, _stringUtils.utf8ByteLength)(value)} to ${MAX_HEADER_VALUE_BYTES} bytes`, _types.SdkVerbosity.DEBUG);
|
|
99
|
+
}
|
|
100
|
+
return [name, truncated];
|
|
101
|
+
}) : [];
|
|
102
|
+
const resEntries = responseHeaders ? Object.entries(responseHeaders).map(([name, value]) => {
|
|
103
|
+
const truncated = truncateToBytes(value, MAX_HEADER_VALUE_BYTES);
|
|
104
|
+
if (truncated.length < value.length) {
|
|
105
|
+
_InternalLog.InternalLog.log(`${TAG} Truncated response header "${name}" value from ${(0, _stringUtils.utf8ByteLength)(value)} to ${MAX_HEADER_VALUE_BYTES} bytes`, _types.SdkVerbosity.DEBUG);
|
|
106
|
+
}
|
|
107
|
+
return [name, truncated];
|
|
108
|
+
}) : [];
|
|
109
|
+
|
|
110
|
+
// Step 3: Count cap -- request headers take priority
|
|
111
|
+
const totalCount = reqEntries.length + resEntries.length;
|
|
112
|
+
let cappedReqEntries = reqEntries;
|
|
113
|
+
let cappedResEntries = resEntries;
|
|
114
|
+
if (totalCount > MAX_HEADER_COUNT) {
|
|
115
|
+
const reqSlots = Math.min(reqEntries.length, MAX_HEADER_COUNT);
|
|
116
|
+
cappedReqEntries = reqEntries.slice(0, reqSlots);
|
|
117
|
+
const remainingSlots = MAX_HEADER_COUNT - cappedReqEntries.length;
|
|
118
|
+
cappedResEntries = resEntries.slice(0, remainingSlots);
|
|
119
|
+
_InternalLog.InternalLog.log(`${TAG} Header count cap hit (${totalCount} > ${MAX_HEADER_COUNT}): keeping ${cappedReqEntries.length} request + ${cappedResEntries.length} response headers`, _types.SdkVerbosity.DEBUG);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Step 4: Total byte budget -- drop from end (response first, then request)
|
|
123
|
+
let totalBytes = 0;
|
|
124
|
+
for (const [name, value] of cappedReqEntries) {
|
|
125
|
+
totalBytes += (0, _stringUtils.utf8ByteLength)(name) + (0, _stringUtils.utf8ByteLength)(value);
|
|
126
|
+
}
|
|
127
|
+
for (const [name, value] of cappedResEntries) {
|
|
128
|
+
totalBytes += (0, _stringUtils.utf8ByteLength)(name) + (0, _stringUtils.utf8ByteLength)(value);
|
|
129
|
+
}
|
|
130
|
+
if (totalBytes > MAX_TOTAL_BYTES) {
|
|
131
|
+
_InternalLog.InternalLog.log(`${TAG} Total byte budget exceeded (${totalBytes} > ${MAX_TOTAL_BYTES}): dropping headers from end`, _types.SdkVerbosity.DEBUG);
|
|
132
|
+
// Drop response headers from end first
|
|
133
|
+
while (cappedResEntries.length > 0 && totalBytes > MAX_TOTAL_BYTES) {
|
|
134
|
+
const entry = cappedResEntries.pop();
|
|
135
|
+
if (entry === undefined) {
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
_InternalLog.InternalLog.log(`${TAG} Dropped response header "${entry[0]}" to fit byte budget`, _types.SdkVerbosity.DEBUG);
|
|
139
|
+
totalBytes -= (0, _stringUtils.utf8ByteLength)(entry[0]) + (0, _stringUtils.utf8ByteLength)(entry[1]);
|
|
140
|
+
}
|
|
141
|
+
// Then drop request headers from end
|
|
142
|
+
while (cappedReqEntries.length > 0 && totalBytes > MAX_TOTAL_BYTES) {
|
|
143
|
+
const entry = cappedReqEntries.pop();
|
|
144
|
+
if (entry === undefined) {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
_InternalLog.InternalLog.log(`${TAG} Dropped request header "${entry[0]}" to fit byte budget`, _types.SdkVerbosity.DEBUG);
|
|
148
|
+
totalBytes -= (0, _stringUtils.utf8ByteLength)(entry[0]) + (0, _stringUtils.utf8ByteLength)(entry[1]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Step 5: Build result records
|
|
153
|
+
const reqResult = {};
|
|
154
|
+
for (const [name, value] of cappedReqEntries) {
|
|
155
|
+
reqResult[name] = value;
|
|
156
|
+
}
|
|
157
|
+
const resResult = {};
|
|
158
|
+
for (const [name, value] of cappedResEntries) {
|
|
159
|
+
resResult[name] = value;
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
requestHeaders: requestHeaders !== undefined ? toUndefinedIfEmpty(reqResult) : undefined,
|
|
163
|
+
responseHeaders: responseHeaders !== undefined ? toUndefinedIfEmpty(resResult) : undefined
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
exports.enforceSizeLimits = enforceSizeLimits;
|
|
167
|
+
//# sourceMappingURL=enforceSizeLimits.js.map
|
package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/enforceSizeLimits.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_InternalLog","require","_types","_stringUtils","TAG","MAX_HEADER_VALUE_BYTES","exports","MAX_HEADER_COUNT","MAX_TOTAL_BYTES","truncateToBytes","str","maxBytes","bytes","i","length","code","charCodeAt","charBytes","advance","next","slice","toUndefinedIfEmpty","record","Object","keys","undefined","enforceSizeLimits","requestHeaders","responseHeaders","reqEntries","entries","map","name","value","truncated","InternalLog","log","utf8ByteLength","SdkVerbosity","DEBUG","resEntries","totalCount","cappedReqEntries","cappedResEntries","reqSlots","Math","min","remainingSlots","totalBytes","entry","pop","reqResult","resResult"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceT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AGP,gBAAgB,CAACQ,GAAG,CAAC,CAAC;MACpC,IAAID,KAAK,KAAKxB,SAAS,EAAE;QACrB;MACJ;MACAU,wBAAW,CAACC,GAAG,CACX,GAAGhC,GAAG,4BAA4B6C,KAAK,CAAC,CAAC,CAAC,sBAAsB,EAChEX,mBAAY,CAACC,KACjB,CAAC;MACDS,UAAU,IAAI,IAAAX,2BAAc,EAACY,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAAZ,2BAAc,EAACY,KAAK,CAAC,CAAC,CAAC,CAAC;IACrE;EACJ;;EAEA;EACA,MAAME,SAAiC,GAAG,CAAC,CAAC;EAC5C,KAAK,MAAM,CAACnB,IAAI,EAAEC,KAAK,CAAC,IAAIS,gBAAgB,EAAE;IAC1CS,SAAS,CAACnB,IAAI,CAAC,GAAGC,KAAK;EAC3B;EAEA,MAAMmB,SAAiC,GAAG,CAAC,CAAC;EAC5C,KAAK,MAAM,CAACpB,IAAI,EAAEC,KAAK,CAAC,IAAIU,gBAAgB,EAAE;IAC1CS,SAAS,CAACpB,IAAI,CAAC,GAAGC,KAAK;EAC3B;EAEA,OAAO;IACHN,cAAc,EACVA,cAAc,KAAKF,SAAS,GACtBJ,kBAAkB,CAAC8B,SAAS,CAAC,GAC7B1B,SAAS;IACnBG,eAAe,EACXA,eAAe,KAAKH,SAAS,GACvBJ,kBAAkB,CAAC+B,SAAS,CAAC,GAC7B3B;EACd,CAAC;AACL,CAAC;AAACnB,OAAA,CAAAoB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isHeaderAllowed = void 0;
|
|
7
|
+
var _sensitiveHeaderBlocklist = require("./sensitiveHeaderBlocklist");
|
|
8
|
+
var _tracingHeaderExclusion = require("./tracingHeaderExclusion");
|
|
9
|
+
/*
|
|
10
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
11
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
12
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Composed check: returns true if a header is allowed for capture.
|
|
17
|
+
* A header is allowed only if it is NOT sensitive AND NOT a tracing header.
|
|
18
|
+
*
|
|
19
|
+
* This is the single entry point for Phase 3 XHR integration to call for
|
|
20
|
+
* every header considered for capture.
|
|
21
|
+
*
|
|
22
|
+
* @param headerName - The header name to check (case-insensitive).
|
|
23
|
+
* @returns `true` if the header may be captured, `false` if blocked.
|
|
24
|
+
*/
|
|
25
|
+
const isHeaderAllowed = headerName => {
|
|
26
|
+
const lowered = headerName.toLowerCase();
|
|
27
|
+
if ((0, _sensitiveHeaderBlocklist.isSensitiveHeader)(lowered)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if ((0, _tracingHeaderExclusion.isTracingHeader)(lowered)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
exports.isHeaderAllowed = isHeaderAllowed;
|
|
36
|
+
//# sourceMappingURL=isHeaderAllowed.js.map
|
package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_sensitiveHeaderBlocklist","require","_tracingHeaderExclusion","isHeaderAllowed","headerName","lowered","toLowerCase","isSensitiveHeader","isTracingHeader","exports"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/headerCapture/isHeaderAllowed.ts"],"mappings":";;;;;;AAMA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AAPA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,eAAe,GAAIC,UAAkB,IAAc;EAC5D,MAAMC,OAAO,GAAGD,UAAU,CAACE,WAAW,CAAC,CAAC;EACxC,IAAI,IAAAC,2CAAiB,EAACF,OAAO,CAAC,EAAE;IAC5B,OAAO,KAAK;EAChB;EACA,IAAI,IAAAG,uCAAe,EAACH,OAAO,CAAC,EAAE;IAC1B,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAACI,OAAA,CAAAN,eAAA,GAAAA,eAAA","ignoreList":[]}
|
package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normalizeUrlForMatching = exports.normalizeHostname = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
9
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
10
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// URL parsers ignore leading/trailing C0 control characters and spaces, and
|
|
14
|
+
// remove ASCII tabs and newlines anywhere in the URL.
|
|
15
|
+
// eslint-disable-next-line no-control-regex
|
|
16
|
+
const LEADING_TRAILING_C0_OR_SPACE = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g;
|
|
17
|
+
const TAB_OR_NEWLINE = /[\t\n\r]/g;
|
|
18
|
+
|
|
19
|
+
// HTTP(S) URL parsers accept any number of slashes (or backslashes) after the scheme
|
|
20
|
+
const HTTP_SCHEME_AND_SLASHES = /^(https?):[/\\]*/i;
|
|
21
|
+
const ENCODED_HOST_CHARACTER = /%([0-9a-fA-F]{2})/g;
|
|
22
|
+
const HOST_CHARACTER = /^[A-Za-z0-9.-]$/;
|
|
23
|
+
// Label separators that IDNA maps to '.'
|
|
24
|
+
const ALTERNATIVE_DOTS = /[\u3002\uFF0E\uFF61]/g;
|
|
25
|
+
// Characters that cannot appear in a hostname: decoding must never produce them,
|
|
26
|
+
// otherwise an encoded character could move the host boundary
|
|
27
|
+
// eslint-disable-next-line no-control-regex
|
|
28
|
+
const FORBIDDEN_HOST_CHARACTER = /[\u0000-\u0020/\\?#@:%<>[\]^|]/;
|
|
29
|
+
const SINGLE_DOT_SEGMENTS = new Set(['.', '%2e']);
|
|
30
|
+
const DOUBLE_DOT_SEGMENTS = new Set(['..', '.%2e', '%2e.', '%2e%2e']);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Normalizes a URL for `forURLs` scope matching, following the URL parsing
|
|
34
|
+
* semantics of HTTP clients:
|
|
35
|
+
* - leading/trailing control characters and spaces are trimmed, and tabs,
|
|
36
|
+
* CRs and LFs are removed;
|
|
37
|
+
* - extra slashes after `http(s):` are collapsed (`https:///host` -> `https://host`);
|
|
38
|
+
* - the scheme and authority are lowercased, and the hostname is normalized
|
|
39
|
+
* with {@link normalizeHostname};
|
|
40
|
+
* - an omitted path is treated as `/`;
|
|
41
|
+
* - in the path, backslashes are treated as slashes and dot segments
|
|
42
|
+
* (`.`, `..`, and their `%2e` encodings) are resolved;
|
|
43
|
+
* - path case, query and fragment are left untouched.
|
|
44
|
+
*
|
|
45
|
+
* Example: `HTTPS://API.Example.com/Public/../Private?Q=1` -> `https://api.example.com/Private?Q=1`
|
|
46
|
+
*/
|
|
47
|
+
const normalizeUrlForMatching = rawUrl => {
|
|
48
|
+
const url = rawUrl.replace(LEADING_TRAILING_C0_OR_SPACE, '').replace(TAB_OR_NEWLINE, '').replace(HTTP_SCHEME_AND_SLASHES, '$1://');
|
|
49
|
+
const schemeEnd = url.indexOf('://');
|
|
50
|
+
if (schemeEnd === -1) {
|
|
51
|
+
return url;
|
|
52
|
+
}
|
|
53
|
+
const authorityEnd = findFirstOf(url, schemeEnd + 3, '/\\?#');
|
|
54
|
+
const pathEnd = findFirstOf(url, authorityEnd, '?#');
|
|
55
|
+
return normalizeAuthority(url.slice(0, authorityEnd)) + normalizePath(url.slice(authorityEnd, pathEnd)) + url.slice(pathEnd);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Normalizes a hostname the way HTTP clients resolve it before connecting:
|
|
60
|
+
* percent-encodings are decoded, Unicode compatibility characters are mapped
|
|
61
|
+
* (NFKC, e.g. fullwidth letters), IDNA label separators (`。`, `.`, `。`)
|
|
62
|
+
* become `.`, and the result is lowercased.
|
|
63
|
+
* Used for both request URLs and configured `forURLs` hostnames.
|
|
64
|
+
*
|
|
65
|
+
* If decoding would produce a character that is not allowed in a hostname,
|
|
66
|
+
* only ASCII hostname characters are decoded.
|
|
67
|
+
*/
|
|
68
|
+
exports.normalizeUrlForMatching = normalizeUrlForMatching;
|
|
69
|
+
const normalizeHostname = hostname => {
|
|
70
|
+
if (/^[A-Za-z0-9.-]*$/.test(hostname)) {
|
|
71
|
+
return hostname.toLowerCase();
|
|
72
|
+
}
|
|
73
|
+
const normalized = mapUnicodeHostname(decodeUtf8(hostname));
|
|
74
|
+
if (!FORBIDDEN_HOST_CHARACTER.test(normalized)) {
|
|
75
|
+
return normalized;
|
|
76
|
+
}
|
|
77
|
+
return mapUnicodeHostname(hostname.replace(ENCODED_HOST_CHARACTER, (encoded, hex) => {
|
|
78
|
+
const char = String.fromCharCode(parseInt(hex, 16));
|
|
79
|
+
return HOST_CHARACTER.test(char) ? char : encoded;
|
|
80
|
+
}));
|
|
81
|
+
};
|
|
82
|
+
exports.normalizeHostname = normalizeHostname;
|
|
83
|
+
const decodeUtf8 = value => {
|
|
84
|
+
try {
|
|
85
|
+
return decodeURIComponent(value);
|
|
86
|
+
} catch (_e) {
|
|
87
|
+
// Malformed percent-encoding: leave it to the ASCII-only fallback
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const mapUnicodeHostname = hostname => {
|
|
92
|
+
let mapped = hostname;
|
|
93
|
+
try {
|
|
94
|
+
// Not available on every JS engine configuration
|
|
95
|
+
if (typeof mapped.normalize === 'function') {
|
|
96
|
+
mapped = mapped.normalize('NFKC');
|
|
97
|
+
}
|
|
98
|
+
} catch (_e) {
|
|
99
|
+
// Keep the unmapped hostname
|
|
100
|
+
}
|
|
101
|
+
return mapped.replace(ALTERNATIVE_DOTS, '.').toLowerCase();
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Lowercases the scheme and authority and normalizes the hostname.
|
|
106
|
+
* Userinfo (before the last `@`) is lowercased but not decoded, and the port
|
|
107
|
+
* is kept as-is, so encoded characters can never move the host boundaries.
|
|
108
|
+
* IPv6 literals (`[...]`) are only lowercased.
|
|
109
|
+
*/
|
|
110
|
+
const normalizeAuthority = schemeAndAuthority => {
|
|
111
|
+
const userinfoEnd = schemeAndAuthority.lastIndexOf('@');
|
|
112
|
+
const hostStart = userinfoEnd === -1 ? schemeAndAuthority.indexOf('://') + 3 : userinfoEnd + 1;
|
|
113
|
+
const hostAndPort = schemeAndAuthority.slice(hostStart);
|
|
114
|
+
const portMatch = /:\d*$/.exec(hostAndPort);
|
|
115
|
+
const host = portMatch ? hostAndPort.slice(0, portMatch.index) : hostAndPort;
|
|
116
|
+
const port = portMatch ? portMatch[0] : '';
|
|
117
|
+
const normalizedHost = host.startsWith('[') ? host.toLowerCase() : normalizeHostname(host);
|
|
118
|
+
return `${schemeAndAuthority.slice(0, hostStart).toLowerCase()}${normalizedHost}${port}`;
|
|
119
|
+
};
|
|
120
|
+
const findFirstOf = (url, from, chars) => {
|
|
121
|
+
for (let i = from; i < url.length; i++) {
|
|
122
|
+
if (chars.includes(url[i])) {
|
|
123
|
+
return i;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return url.length;
|
|
127
|
+
};
|
|
128
|
+
const normalizePath = path => {
|
|
129
|
+
// HTTP requests without a path are sent to `/`
|
|
130
|
+
if (path === '') {
|
|
131
|
+
return '/';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Fast path: nothing to resolve
|
|
135
|
+
if (!/[.\\%]/.test(path)) {
|
|
136
|
+
return path;
|
|
137
|
+
}
|
|
138
|
+
const segments = path.replace(/\\/g, '/').slice(1).split('/');
|
|
139
|
+
const output = [];
|
|
140
|
+
segments.forEach((segment, index) => {
|
|
141
|
+
const isLast = index === segments.length - 1;
|
|
142
|
+
const lowered = segment.toLowerCase();
|
|
143
|
+
if (DOUBLE_DOT_SEGMENTS.has(lowered)) {
|
|
144
|
+
output.pop();
|
|
145
|
+
if (isLast) {
|
|
146
|
+
output.push('');
|
|
147
|
+
}
|
|
148
|
+
} else if (SINGLE_DOT_SEGMENTS.has(lowered)) {
|
|
149
|
+
if (isLast) {
|
|
150
|
+
output.push('');
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
output.push(segment);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return `/${output.join('/')}`;
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=normalizeUrlForMatching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LEADING_TRAILING_C0_OR_SPACE","TAB_OR_NEWLINE","HTTP_SCHEME_AND_SLASHES","ENCODED_HOST_CHARACTER","HOST_CHARACTER","ALTERNATIVE_DOTS","FORBIDDEN_HOST_CHARACTER","SINGLE_DOT_SEGMENTS","Set","DOUBLE_DOT_SEGMENTS","normalizeUrlForMatching","rawUrl","url","replace","schemeEnd","indexOf","authorityEnd","findFirstOf","pathEnd","normalizeAuthority","slice","normalizePath","exports","normalizeHostname","hostname","test","toLowerCase","normalized","mapUnicodeHostname","decodeUtf8","encoded","hex","char","String","fromCharCode","parseInt","value","decodeURIComponent","_e","mapped","normalize","schemeAndAuthority","userinfoEnd","lastIndexOf","hostStart","hostAndPort","portMatch","exec","host","index","port","normalizedHost","startsWith","from","chars","i","length","includes","path","segments","split","output","forEach","segment","isLast","lowered","has","pop","push","join"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/headerCapture/normalizeUrlForMatching.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAMA,4BAA4B,GAAG,sCAAsC;AAC3E,MAAMC,cAAc,GAAG,WAAW;;AAElC;AACA,MAAMC,uBAAuB,GAAG,mBAAmB;AAEnD,MAAMC,sBAAsB,GAAG,oBAAoB;AACnD,MAAMC,cAAc,GAAG,iBAAiB;AACxC;AACA,MAAMC,gBAAgB,GAAG,uBAAuB;AAChD;AACA;AACA;AACA,MAAMC,wBAAwB,GAAG,gCAAgC;AAEjE,MAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACjD,MAAMC,mBAAmB,GAAG,IAAID,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,uBAAuB,GAAIC,MAAc,IAAa;EAC/D,MAAMC,GAAG,GAAGD,MAAM,CACbE,OAAO,CAACb,4BAA4B,EAAE,EAAE,CAAC,CACzCa,OAAO,CAACZ,cAAc,EAAE,EAAE,CAAC,CAC3BY,OAAO,CAACX,uBAAuB,EAAE,OAAO,CAAC;EAC9C,MAAMY,SAAS,GAAGF,GAAG,CAACG,OAAO,CAAC,KAAK,CAAC;EACpC,IAAID,SAAS,KAAK,CAAC,CAAC,EAAE;IAClB,OAAOF,GAAG;EACd;EAEA,MAAMI,YAAY,GAAGC,WAAW,CAACL,GAAG,EAAEE,SAAS,GAAG,CAAC,EAAE,OAAO,CAAC;EAC7D,MAAMI,OAAO,GAAGD,WAAW,CAACL,GAAG,EAAEI,YAAY,EAAE,IAAI,CAAC;EAEpD,OACIG,kBAAkB,CAACP,GAAG,CA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,IAAI,CAAC,GAAG,CAAC,EAAE;AACjC,CAAC","ignoreList":[]}
|
package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseResponseHeaders = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
9
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
10
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Parses a CRLF-delimited `getAllResponseHeaders()` string into a
|
|
15
|
+
* `Record<string, string>` of lowercase header names to trimmed values.
|
|
16
|
+
*
|
|
17
|
+
* Handles all edge cases defensively — SDK stability takes priority over
|
|
18
|
+
* strict compliance. Never throws on any input.
|
|
19
|
+
*
|
|
20
|
+
* - Splits on `\r?\n` to handle both CRLF and bare LF
|
|
21
|
+
* - Uses `indexOf(':')` so values containing colons (e.g. URLs) are preserved
|
|
22
|
+
* - Header names are trimmed and lowercased; values are trimmed (HTTP OWS)
|
|
23
|
+
* - Duplicate names resolve to last-value-wins
|
|
24
|
+
* - Malformed lines (no colon, empty name) are silently skipped
|
|
25
|
+
* - Headers rejected by `isAllowed` (if provided) are never stored
|
|
26
|
+
*/
|
|
27
|
+
const parseResponseHeaders = (rawHeaders, isAllowed) => {
|
|
28
|
+
if (!rawHeaders) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
const result = {};
|
|
32
|
+
const lines = rawHeaders.split(/\r?\n/);
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
// Skip empty lines (trailing delimiter produces empty last element)
|
|
35
|
+
if (line === '') {
|
|
36
|
+
continue;
|
|
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
|
+
const name = line.slice(0, colonIndex).trim().toLowerCase();
|
|
45
|
+
|
|
46
|
+
// Name is empty after trimming, or the header is not allowed — skip
|
|
47
|
+
if (name === '' || isAllowed !== undefined && !isAllowed(name)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const value = line.slice(colonIndex + 1).trim();
|
|
51
|
+
|
|
52
|
+
// Last value wins for duplicate header names
|
|
53
|
+
result[name] = value;
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
exports.parseResponseHeaders = parseResponseHeaders;
|
|
58
|
+
//# sourceMappingURL=parseResponseHeaders.js.map
|
package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseResponseHeaders","rawHeaders","isAllowed","result","lines","split","line","colonIndex","indexOf","name","slice","trim","toLowerCase","undefined","value","exports"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/headerCapture/parseResponseHeaders.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAGA,CAChCC,UAAqC,EACrCC,SAA2C,KAClB;EACzB,IAAI,CAACD,UAAU,EAAE;IACb,OAAO,CAAC,CAAC;EACb;EAEA,MAAME,MAA8B,GAAG,CAAC,CAAC;EACzC,MAAMC,KAAK,GAAGH,UAAU,CAACI,KAAK,CAAC,OAAO,CAAC;EAEvC,KAAK,MAAMC,IAAI,IAAIF,KAAK,EAAE;IACtB;IACA,IAAIE,IAAI,KAAK,EAAE,EAAE;MACb;IACJ;IAEA,MAAMC,UAAU,GAAGD,IAAI,CAACE,OAAO,CAAC,GAAG,CAAC;;IAEpC;IACA,IAAID,UAAU,IAAI,CAAC,EAAE;MACjB;IACJ;IAEA,MAAME,IAAI,GAAGH,IAAI,CAACI,KAAK,CAAC,CAAC,EAAEH,UAAU,CAAC,CAACI,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;;IAE3D;IACA,IAAIH,IAAI,KAAK,EAAE,IAAKP,SAAS,KAAKW,SAAS,IAAI,CAACX,SAAS,CAACO,IAAI,CAAE,EAAE;MAC9D;IACJ;IAEA,MAAMK,KAAK,GAAGR,IAAI,CAACI,KAAK,CAACH,UAAU,GAAG,CAAC,CAAC,CAACI,IAAI,CAAC,CAAC;;IAE/C;IACAR,MAAM,CAACM,IAAI,CAAC,GAAGK,KAAK;EACxB;EAEA,OAAOX,MAAM;AACjB,CAAC;AAACY,OAAA,CAAAf,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isSensitiveHeader = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
9
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
10
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Compiled regex matching sensitive header name patterns.
|
|
15
|
+
*
|
|
16
|
+
* Matches headers containing: token, cookie, secret, authorization, password,
|
|
17
|
+
* credential, bearer, api/secret/access/app key variants, forwarding/IP headers.
|
|
18
|
+
*
|
|
19
|
+
* The `/i` flag ensures case-insensitive matching. Compiled once at module load
|
|
20
|
+
* time — no per-call allocation.
|
|
21
|
+
*/
|
|
22
|
+
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;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Checks whether a header name matches a known sensitive header pattern.
|
|
26
|
+
* Sensitive headers (authorization, cookies, tokens, API keys, etc.) must
|
|
27
|
+
* never be captured regardless of configuration mode.
|
|
28
|
+
*
|
|
29
|
+
* Blocked headers are expected behavior, so they never produce WARN or ERROR
|
|
30
|
+
* logs; the capture pipeline only reports them at DEBUG verbosity.
|
|
31
|
+
*
|
|
32
|
+
* @param headerName - The header name to check (case-insensitive via regex /i flag).
|
|
33
|
+
* @returns `true` if the header is sensitive and must be blocked.
|
|
34
|
+
*/
|
|
35
|
+
const isSensitiveHeader = headerName => {
|
|
36
|
+
return SENSITIVE_HEADER_PATTERN.test(headerName);
|
|
37
|
+
};
|
|
38
|
+
exports.isSensitiveHeader = isSensitiveHeader;
|
|
39
|
+
//# sourceMappingURL=sensitiveHeaderBlocklist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SENSITIVE_HEADER_PATTERN","isSensitiveHeader","headerName","test","exports"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/headerCapture/sensitiveHeaderBlocklist.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,wBAAwB,GAAG,2JAA2J;;AAE5L;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAAIC,UAAkB,IAAc;EAC9D,OAAOF,wBAAwB,CAACG,IAAI,CAACD,UAAU,CAAC;AACpD,CAAC;AAACE,OAAA,CAAAH,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/lib/commonjs/rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isTracingHeader = void 0;
|
|
7
|
+
var _headers = require("../distributedTracing/headers");
|
|
8
|
+
/*
|
|
9
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
10
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
11
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Set of all SDK-injected distributed tracing (and tracking) header names, lowercased.
|
|
16
|
+
*
|
|
17
|
+
* Built once at module load time from the canonical header constants in
|
|
18
|
+
* `distributedTracing/headers.ts`. The B3 multi-headers have mixed case
|
|
19
|
+
* (e.g. `X-B3-TraceId`), so all values are lowercased for uniform lookup.
|
|
20
|
+
*/
|
|
21
|
+
const TRACING_HEADERS = new Set([_headers.SAMPLING_PRIORITY_HEADER_KEY, _headers.ORIGIN_HEADER_KEY, _headers.TRACE_ID_HEADER_KEY, _headers.PARENT_ID_HEADER_KEY, _headers.TAGS_HEADER_KEY, _headers.TRACECONTEXT_HEADER_KEY, _headers.TRACESTATE_HEADER_KEY, _headers.BAGGAGE_HEADER_KEY, _headers.B3_HEADER_KEY, _headers.B3_MULTI_TRACE_ID_HEADER_KEY, _headers.B3_MULTI_SPAN_ID_HEADER_KEY, _headers.B3_MULTI_SAMPLED_HEADER_KEY, _headers.TRACKED_BY_HEADER_KEY].map(h => h.toLowerCase()));
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Checks whether a header name is an SDK-injected distributed tracing header.
|
|
25
|
+
* Tracing headers must never be captured because they are SDK internals,
|
|
26
|
+
* not application-level headers.
|
|
27
|
+
*
|
|
28
|
+
* Uses an explicit list (not prefix matching) — `x-datadog-customer-id`
|
|
29
|
+
* would NOT be excluded.
|
|
30
|
+
*
|
|
31
|
+
* @param headerName - The header name to check (lowercased internally for lookup).
|
|
32
|
+
* @returns `true` if the header is a tracing header and must be excluded.
|
|
33
|
+
*/
|
|
34
|
+
const isTracingHeader = headerName => {
|
|
35
|
+
return TRACING_HEADERS.has(headerName.toLowerCase());
|
|
36
|
+
};
|
|
37
|
+
exports.isTracingHeader = isTracingHeader;
|
|
38
|
+
//# sourceMappingURL=tracingHeaderExclusion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_headers","require","TRACING_HEADERS","Set","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_HEADER_KEY","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","TAGS_HEADER_KEY","TRACECONTEXT_HEADER_KEY","TRACESTATE_HEADER_KEY","BAGGAGE_HEADER_KEY","B3_HEADER_KEY","B3_MULTI_TRACE_ID_HEADER_KEY","B3_MULTI_SPAN_ID_HEADER_KEY","B3_MULTI_SAMPLED_HEADER_KEY","TRACKED_BY_HEADER_KEY","map","h","toLowerCase","isTracingHeader","headerName","has","exports"],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/headerCapture/tracingHeaderExclusion.ts"],"mappings":";;;;;;AAMA,IAAAA,QAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAA4B,GAAG,IAAIC,GAAG,CACxC,CACIC,qCAA4B,EAC5BC,0BAAiB,EACjBC,4BAAmB,EACnBC,6BAAoB,EACpBC,wBAAe,EACfC,gCAAuB,EACvBC,8BAAqB,EACrBC,2BAAkB,EAClBC,sBAAa,EACbC,qCAA4B,EAC5BC,oCAA2B,EAC3BC,oCAA2B,EAC3BC,8BAAqB,CACxB,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,WAAW,CAAC,CAAC,CAC9B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,GAAIC,UAAkB,IAAc;EAC5D,OAAOnB,eAAe,CAACoB,GAAG,CAACD,UAAU,CAACF,WAAW,CAAC,CAAC,CAAC;AACxD,CAAC;AAACI,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../../src","sources":["rum/instrumentation/resourceTracking/headerCapture/types.ts"],"mappings":"","ignoreList":[]}
|
package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js
CHANGED
|
@@ -11,6 +11,7 @@ var _xhrUtils = require("../XHRProxy/xhrUtils");
|
|
|
11
11
|
var _FetchProxyState = require("../common/FetchProxyState");
|
|
12
12
|
var _RequestContext = require("../common/RequestContext");
|
|
13
13
|
var _ResourceReporter = require("../common/ResourceReporter");
|
|
14
|
+
var _headerCapture = require("../common/headerCapture");
|
|
14
15
|
var _internalDevResourceBlocklist = require("../common/internalDevResourceBlocklist");
|
|
15
16
|
var _requestHeaders = require("../common/requestHeaders");
|
|
16
17
|
var _RequestProxy = require("../interfaces/RequestProxy");
|
|
@@ -159,12 +160,14 @@ const buildHeaders = ({
|
|
|
159
160
|
header,
|
|
160
161
|
value
|
|
161
162
|
}) => {
|
|
162
|
-
applyHeader({
|
|
163
|
+
if (applyHeader({
|
|
163
164
|
headers,
|
|
164
165
|
context,
|
|
165
166
|
header,
|
|
166
167
|
value
|
|
167
|
-
})
|
|
168
|
+
})) {
|
|
169
|
+
(0, _headerCapture.recordRequestHeader)(context.headerCapture, header, value);
|
|
170
|
+
}
|
|
168
171
|
});
|
|
169
172
|
(0, _requestHeaders.getInstrumentationHeaders)(context).forEach(({
|
|
170
173
|
header,
|
|
@@ -192,13 +195,24 @@ const applyHeader = ({
|
|
|
192
195
|
});
|
|
193
196
|
if (processedHeader.type === 'send') {
|
|
194
197
|
headers.set(processedHeader.header, processedHeader.value);
|
|
198
|
+
return true;
|
|
195
199
|
}
|
|
200
|
+
return false;
|
|
196
201
|
};
|
|
197
202
|
const reportFetch = async ({
|
|
198
203
|
context,
|
|
199
204
|
response,
|
|
200
205
|
resourceReporter
|
|
201
206
|
}) => {
|
|
207
|
+
// Snapshot before any await: some Fetch implementations expose mutable
|
|
208
|
+
// response headers that the app could change while the body is parsed.
|
|
209
|
+
const capturedHeaders = (0, _headerCapture.finalizeCapturedHeaders)({
|
|
210
|
+
state: context.headerCapture,
|
|
211
|
+
url: context.url,
|
|
212
|
+
statusCode: response.status,
|
|
213
|
+
responseHeaders: () => (0, _headerCapture.fetchHeadersToRecord)(response.headers)
|
|
214
|
+
});
|
|
215
|
+
|
|
202
216
|
// Only extract GraphQL errors if operationType is set AND error tracking is enabled
|
|
203
217
|
if (context.graphql.operationType && context.graphql.trackErrors) {
|
|
204
218
|
try {
|
|
@@ -226,6 +240,7 @@ const reportFetch = async ({
|
|
|
226
240
|
},
|
|
227
241
|
graphqlAttributes: context.graphql,
|
|
228
242
|
tracingAttributes: context.tracingAttributes,
|
|
243
|
+
...capturedHeaders,
|
|
229
244
|
response: {
|
|
230
245
|
statusCode: response.status,
|
|
231
246
|
size: getResponseSize(response)
|