@datadog/mobile-react-native 3.10.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/DatadogSDKReactNative.podspec +7 -7
- package/README.md +2 -1
- package/android/build.gradle +23 -13
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +10 -0
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +10 -0
- package/android/src/oldarchCommon/kotlin/com/datadog/reactnative/DdRum.kt +10 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +9 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +3 -3
- package/datadog-configuration.gradle +59 -18
- package/datadog-configuration.schema.json +119 -0
- package/ios/Sources/DdRum.mm +13 -1
- package/ios/Sources/DdRumImplementation.swift +6 -0
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +3 -0
- 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 +8 -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 +19 -4
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +26 -4
- 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 +10 -2
- 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/rum/types.js.map +1 -1
- package/lib/commonjs/sdk/AccountInfoSingleton/AccountInfoSingleton.js +1 -0
- package/lib/commonjs/sdk/AccountInfoSingleton/AccountInfoSingleton.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/sdk/UserInfoSingleton/UserInfoSingleton.js +1 -0
- package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.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 +8 -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 +20 -5
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +27 -5
- 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 +8 -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/rum/types.js.map +1 -1
- package/lib/module/sdk/AccountInfoSingleton/AccountInfoSingleton.js +2 -1
- package/lib/module/sdk/AccountInfoSingleton/AccountInfoSingleton.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/sdk/UserInfoSingleton/UserInfoSingleton.js +2 -1
- package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.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 +2 -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 +4 -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/rum/types.d.ts +6 -0
- package/lib/typescript/rum/types.d.ts.map +1 -1
- package/lib/typescript/sdk/AccountInfoSingleton/AccountInfoSingleton.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/sdk/UserInfoSingleton/UserInfoSingleton.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 +13 -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 +14 -3
- package/src/rum/__tests__/DdRum.test.ts +14 -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 +24 -5
- package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/__tests__/FetchProxy.test.ts +303 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/__tests__/ResourceReporter.test.ts +120 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +36 -5
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +664 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.ts +1 -34
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.ts +15 -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/rum/types.ts +7 -0
- package/src/sdk/AccountInfoSingleton/AccountInfoSingleton.ts +2 -1
- package/src/sdk/AccountInfoSingleton/__tests__/AccountInfoSingleton.test.ts +59 -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/sdk/UserInfoSingleton/UserInfoSingleton.ts +2 -1
- package/src/sdk/UserInfoSingleton/__tests__/UserInfoSingleton.test.ts +55 -0
- package/src/specs/NativeDdFlags.ts +14 -2
- package/src/specs/NativeDdLogs.ts +14 -2
- package/src/specs/NativeDdRum.ts +21 -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,120 @@
|
|
|
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
|
+
// Babel is a development dependency of the workspace root.
|
|
8
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
9
|
+
import { transformSync } from '@babel/core';
|
|
10
|
+
import { createRequire } from 'module';
|
|
11
|
+
import Pressability from 'react-native/Libraries/Pressability/Pressability';
|
|
12
|
+
import * as ReactNative from 'react-native';
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
|
|
15
|
+
import plugin from '../../../../../../react-native-babel-plugin/src';
|
|
16
|
+
|
|
17
|
+
const nodeRequire = createRequire(__filename);
|
|
18
|
+
|
|
19
|
+
function loadButtonFixture(trackingAvailable: boolean) {
|
|
20
|
+
const trackAction = jest.fn();
|
|
21
|
+
const tracking = {
|
|
22
|
+
getInstance: () => (trackingAvailable ? tracking : null),
|
|
23
|
+
wrapRumAction: (handler: (...args: any[]) => any) => (
|
|
24
|
+
...args: any[]
|
|
25
|
+
) => {
|
|
26
|
+
trackAction();
|
|
27
|
+
return handler?.(...args);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// Reproduce #1509 independently of the example app: optional handlers must
|
|
31
|
+
// remain absent after transforming a component with Metro's preset.
|
|
32
|
+
const output = transformSync(
|
|
33
|
+
`
|
|
34
|
+
import React from 'react';
|
|
35
|
+
import { Pressable } from 'react-native';
|
|
36
|
+
|
|
37
|
+
export function OptionalHandlerButton({ onPress, onLongPress }) {
|
|
38
|
+
return <Pressable onPress={onPress} onLongPress={onLongPress} />;
|
|
39
|
+
}
|
|
40
|
+
`,
|
|
41
|
+
{
|
|
42
|
+
filename: 'optional-handlers.tsx',
|
|
43
|
+
configFile: false,
|
|
44
|
+
babelrc: false,
|
|
45
|
+
presets: ['module:@react-native/babel-preset'],
|
|
46
|
+
plugins: [[plugin, { sessionReplay: { svgTracking: false } }]]
|
|
47
|
+
}
|
|
48
|
+
)?.code as string;
|
|
49
|
+
const modules: Record<string, any> = {
|
|
50
|
+
react: React,
|
|
51
|
+
'react-native': ReactNative,
|
|
52
|
+
'@datadog/mobile-react-native': {
|
|
53
|
+
DdBabelInteractionTracking: tracking
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const exports: Record<string, any> = {};
|
|
57
|
+
// eslint-disable-next-line no-new-func
|
|
58
|
+
new Function('require', 'exports', output)(
|
|
59
|
+
(id: string) => modules[id] ?? nodeRequire(id),
|
|
60
|
+
exports
|
|
61
|
+
);
|
|
62
|
+
return { Button: exports.OptionalHandlerButton, trackAction };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
describe.each([true, false])(
|
|
66
|
+
'issue #1509 with tracking available=%s',
|
|
67
|
+
trackingAvailable => {
|
|
68
|
+
beforeEach(() => jest.useFakeTimers());
|
|
69
|
+
afterEach(() => {
|
|
70
|
+
jest.clearAllTimers();
|
|
71
|
+
jest.useRealTimers();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it.each([undefined, null, 'defined'])(
|
|
75
|
+
'preserves short and long presses with onLongPress=%s',
|
|
76
|
+
value => {
|
|
77
|
+
const { Button, trackAction } = loadButtonFixture(
|
|
78
|
+
trackingAvailable
|
|
79
|
+
);
|
|
80
|
+
const onPress = jest.fn();
|
|
81
|
+
const onLongPress = value === 'defined' ? jest.fn() : value;
|
|
82
|
+
const element = Button({ onPress, onLongPress });
|
|
83
|
+
// Exercise React Native's actual state machine, including its timer
|
|
84
|
+
// and the onLongPress-presence check that suppresses onPress.
|
|
85
|
+
const pressability = new Pressability(element.props);
|
|
86
|
+
const handlers = pressability.getEventHandlers();
|
|
87
|
+
const event = {
|
|
88
|
+
currentTarget: 1,
|
|
89
|
+
nativeEvent: { pageX: 0, pageY: 0 },
|
|
90
|
+
persist: jest.fn()
|
|
91
|
+
} as any;
|
|
92
|
+
|
|
93
|
+
handlers.onResponderGrant(event);
|
|
94
|
+
jest.advanceTimersByTime(100);
|
|
95
|
+
handlers.onResponderRelease(event);
|
|
96
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
97
|
+
if (typeof onLongPress === 'function') {
|
|
98
|
+
expect(onLongPress).not.toHaveBeenCalled();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
handlers.onResponderGrant(event);
|
|
102
|
+
jest.advanceTimersByTime(600);
|
|
103
|
+
handlers.onResponderRelease(event);
|
|
104
|
+
expect(onPress).toHaveBeenCalledTimes(
|
|
105
|
+
onLongPress == null ? 2 : 1
|
|
106
|
+
);
|
|
107
|
+
if (onLongPress == null) {
|
|
108
|
+
expect(element.props.onLongPress).toBe(onLongPress);
|
|
109
|
+
}
|
|
110
|
+
if (typeof onLongPress === 'function') {
|
|
111
|
+
expect(onLongPress).toHaveBeenCalledTimes(1);
|
|
112
|
+
}
|
|
113
|
+
expect(trackAction).toHaveBeenCalledTimes(
|
|
114
|
+
trackingAvailable ? 2 : 0
|
|
115
|
+
);
|
|
116
|
+
pressability.reset();
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
);
|
package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts
CHANGED
|
@@ -9,10 +9,10 @@ import { DdBabelInteractionTracking } from '../DdBabelInteractionTracking';
|
|
|
9
9
|
|
|
10
10
|
jest.mock('../../../../specs/NativeDdSdk', () => ({
|
|
11
11
|
__esModule: true,
|
|
12
|
-
|
|
12
|
+
getNativeDdSdk: jest.fn().mockReturnValue({
|
|
13
13
|
sendTelemetryLog: jest.fn(),
|
|
14
14
|
telemetryError: jest.fn()
|
|
15
|
-
}
|
|
15
|
+
})
|
|
16
16
|
}));
|
|
17
17
|
|
|
18
18
|
jest.mock('../../../../utils/time-provider/DefaultTimeProvider', () => ({
|
|
@@ -198,3 +198,83 @@ describe('DdBabelInteractionTracking.wrapRumAction', () => {
|
|
|
198
198
|
);
|
|
199
199
|
});
|
|
200
200
|
});
|
|
201
|
+
|
|
202
|
+
describe('DdBabelInteractionTracking target name resolution', () => {
|
|
203
|
+
const mockAddAction = jest.fn().mockResolvedValue(undefined);
|
|
204
|
+
|
|
205
|
+
beforeEach(() => {
|
|
206
|
+
mockAddAction.mockClear();
|
|
207
|
+
DdBabelInteractionTracking.config = {
|
|
208
|
+
trackInteractions: true,
|
|
209
|
+
useAccessibilityLabel: true
|
|
210
|
+
};
|
|
211
|
+
DdBabelInteractionTracking.attachRumInstance({
|
|
212
|
+
addAction: mockAddAction
|
|
213
|
+
} as any);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const getTargetName = (targetObject: Record<string, any>) => {
|
|
217
|
+
DdBabelInteractionTracking.wrapRumAction(jest.fn(), RumActionType.TAP, {
|
|
218
|
+
...mockTargetObject,
|
|
219
|
+
options: { useContent: true, useNamePrefix: false },
|
|
220
|
+
...targetObject
|
|
221
|
+
} as any)();
|
|
222
|
+
return mockAddAction.mock.calls[0][1];
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
it('should use the actionNameAttribute value', () => {
|
|
226
|
+
expect(getTargetName({ testID: ['save_button'] })).toBe('save_button');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('should skip undefined and empty actionNameAttribute values', () => {
|
|
230
|
+
expect(
|
|
231
|
+
getTargetName({
|
|
232
|
+
testID: [undefined, ''],
|
|
233
|
+
accessibilityLabel: ['Save']
|
|
234
|
+
})
|
|
235
|
+
).toBe('Save');
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should skip empty dd-action-name and fall back to actionNameAttribute', () => {
|
|
239
|
+
expect(
|
|
240
|
+
getTargetName({ 'dd-action-name': [], testID: ['save_button'] })
|
|
241
|
+
).toBe('save_button');
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should fall back to content when no attribute resolves', () => {
|
|
245
|
+
expect(
|
|
246
|
+
getTargetName({
|
|
247
|
+
testID: [null],
|
|
248
|
+
accessibilityLabel: [undefined],
|
|
249
|
+
getContent: () => ['Save content']
|
|
250
|
+
})
|
|
251
|
+
).toBe('Save content');
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('should fall back to the component name when nothing resolves', () => {
|
|
255
|
+
expect(getTargetName({ testID: [undefined] })).toBe('Button');
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('should stringify numeric values', () => {
|
|
259
|
+
expect(getTargetName({ testID: [42] })).toBe('42');
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should keep positions when resolving the indexed value', () => {
|
|
263
|
+
expect(
|
|
264
|
+
getTargetName({
|
|
265
|
+
testID: ['first', undefined, 'third'],
|
|
266
|
+
handlerArgs: [2]
|
|
267
|
+
})
|
|
268
|
+
).toBe('third');
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('should fall back to the next source when the indexed value is unresolved', () => {
|
|
272
|
+
expect(
|
|
273
|
+
getTargetName({
|
|
274
|
+
testID: ['first', undefined, 'third'],
|
|
275
|
+
accessibilityLabel: ['a11y_first', 'a11y_second'],
|
|
276
|
+
handlerArgs: [1]
|
|
277
|
+
})
|
|
278
|
+
).toBe('a11y_second');
|
|
279
|
+
});
|
|
280
|
+
});
|
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
import BigInt from 'big-integer';
|
|
8
8
|
|
|
9
9
|
import { InternalLog } from '../../../InternalLog';
|
|
10
|
+
import type { HeaderCaptureRule } from '../../../config/features/RumConfiguration.type';
|
|
10
11
|
import { SdkVerbosity } from '../../../config/types/SdkVerbosity';
|
|
11
12
|
import { getGlobalInstance } from '../../../utils/singletonUtils';
|
|
12
13
|
import type { FirstPartyHost } from '../../types';
|
|
13
14
|
|
|
14
15
|
import { DistributedTracingSampling } from './distributedTracing/distributedTracingSampling';
|
|
15
16
|
import { firstPartyHostsRegexMapBuilder } from './distributedTracing/firstPartyHosts';
|
|
17
|
+
import { compileHeaderCaptureConfig } from './headerCapture/compileHeaderConfig';
|
|
16
18
|
import { FetchProxy } from './requestProxy/FetchProxy/FetchProxy';
|
|
17
19
|
import { XHRProxy } from './requestProxy/XHRProxy/XHRProxy';
|
|
18
20
|
import type { RequestProxy } from './requestProxy/interfaces/RequestProxy';
|
|
@@ -42,11 +44,13 @@ class RumResourceTracking {
|
|
|
42
44
|
startTracking({
|
|
43
45
|
resourceTraceSampleRate,
|
|
44
46
|
firstPartyHosts,
|
|
45
|
-
trackFetchResources = false
|
|
47
|
+
trackFetchResources = false,
|
|
48
|
+
headerCaptureRules
|
|
46
49
|
}: {
|
|
47
50
|
resourceTraceSampleRate: number;
|
|
48
51
|
firstPartyHosts: FirstPartyHost[];
|
|
49
52
|
trackFetchResources?: boolean;
|
|
53
|
+
headerCaptureRules?: 'defaults' | HeaderCaptureRule[] | undefined;
|
|
50
54
|
}): void {
|
|
51
55
|
// extra safety to avoid proxying the XHR class twice
|
|
52
56
|
if (this._isTracking) {
|
|
@@ -61,7 +65,8 @@ class RumResourceTracking {
|
|
|
61
65
|
tracingSamplingRate: resourceTraceSampleRate,
|
|
62
66
|
firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder(
|
|
63
67
|
firstPartyHosts
|
|
64
|
-
)
|
|
68
|
+
),
|
|
69
|
+
headerCaptureConfig: compileHeaderCaptureConfig(headerCaptureRules)
|
|
65
70
|
};
|
|
66
71
|
|
|
67
72
|
const xhrProxy = XHRProxy.createWithResourceReporter();
|
|
@@ -193,6 +193,52 @@ describe('DdRumResourceTracking', () => {
|
|
|
193
193
|
);
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
+
it('captures headers once on an XHR-backed Fetch when header capture is enabled', async () => {
|
|
197
|
+
const fetchResponse = ({
|
|
198
|
+
status: 200,
|
|
199
|
+
headers: new Headers({ 'cache-control': 'max-age=60' })
|
|
200
|
+
} as unknown) as Response;
|
|
201
|
+
const xhrBackedFetch = jest.fn(
|
|
202
|
+
(input: RequestInfo | URL, init?: RequestInit) => {
|
|
203
|
+
const xhr = new XMLHttpRequestMock();
|
|
204
|
+
xhr.open(init?.method ?? 'GET', String(input));
|
|
205
|
+
new Headers(init?.headers).forEach((value, header) => {
|
|
206
|
+
xhr.setRequestHeader(header, value);
|
|
207
|
+
});
|
|
208
|
+
xhr.send();
|
|
209
|
+
xhr.notifyResponseArrived();
|
|
210
|
+
xhr.getAllResponseHeaders.mockReturnValue(
|
|
211
|
+
'cache-control: max-age=60\r\n'
|
|
212
|
+
);
|
|
213
|
+
xhr.complete(200, 'ok');
|
|
214
|
+
return Promise.resolve(fetchResponse);
|
|
215
|
+
}
|
|
216
|
+
) as jest.MockedFunction<typeof fetch>;
|
|
217
|
+
global.fetch = xhrBackedFetch;
|
|
218
|
+
|
|
219
|
+
DdRumResourceTracking.startTracking({
|
|
220
|
+
resourceTraceSampleRate: 100,
|
|
221
|
+
firstPartyHosts: [],
|
|
222
|
+
trackFetchResources: true,
|
|
223
|
+
headerCaptureRules: 'defaults'
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
await global.fetch('https://api.example.com/fetch', {
|
|
227
|
+
headers: { 'Content-Type': 'application/json' }
|
|
228
|
+
});
|
|
229
|
+
await flushPromises();
|
|
230
|
+
|
|
231
|
+
expect(DdRum.stopResource).toHaveBeenCalledTimes(1);
|
|
232
|
+
const [, , kind, , context] = DdRum.stopResource.mock.calls[0];
|
|
233
|
+
expect(kind).toBe('fetch');
|
|
234
|
+
expect(context['_dd.request_headers']).toEqual({
|
|
235
|
+
'Content-Type': 'application/json'
|
|
236
|
+
});
|
|
237
|
+
expect(context['_dd.response_headers']).toEqual({
|
|
238
|
+
'Cache-Control': 'max-age=60'
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
196
242
|
describe('updateTrackingContext', () => {
|
|
197
243
|
beforeEach(() => {
|
|
198
244
|
DdRumResourceTracking.stopTracking();
|
|
@@ -27,7 +27,7 @@ export class XMLHttpRequestMock implements XMLHttpRequest {
|
|
|
27
27
|
timeout: number = -1;
|
|
28
28
|
upload: XMLHttpRequestUpload = {} as XMLHttpRequestUpload;
|
|
29
29
|
withCredentials: boolean = false;
|
|
30
|
-
getAllResponseHeaders = jest.fn();
|
|
30
|
+
getAllResponseHeaders = jest.fn().mockReturnValue('');
|
|
31
31
|
overrideMimeType = jest.fn();
|
|
32
32
|
DONE = 4 as const;
|
|
33
33
|
HEADERS_RECEIVED = 2 as const;
|
|
@@ -15,7 +15,7 @@ export type Hostname = { _type: 'Hostname' } & string;
|
|
|
15
15
|
export const NO_MATCH_REGEX = new RegExp('a^');
|
|
16
16
|
|
|
17
17
|
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
|
18
|
-
const escapeRegExp = (string: string) => {
|
|
18
|
+
export const escapeRegExp = (string: string) => {
|
|
19
19
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Resource Header Capture
|
|
2
|
+
|
|
3
|
+
The Datadog React Native SDK can capture HTTP request and response headers on RUM resource events. This helps debug caching, CDN, and content negotiation issues without extra instrumentation.
|
|
4
|
+
|
|
5
|
+
Header capture is **disabled by default** and requires `trackResources: true`.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
Set `headerCaptureRules` in your RUM configuration:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import {
|
|
13
|
+
DatadogProvider,
|
|
14
|
+
DatadogProviderConfiguration,
|
|
15
|
+
TrackingConsent
|
|
16
|
+
} from '@datadog/mobile-react-native';
|
|
17
|
+
|
|
18
|
+
const config = new DatadogProviderConfiguration(
|
|
19
|
+
'<CLIENT_TOKEN>',
|
|
20
|
+
'<ENVIRONMENT_NAME>',
|
|
21
|
+
TrackingConsent.GRANTED,
|
|
22
|
+
{
|
|
23
|
+
rumConfiguration: {
|
|
24
|
+
applicationId: '<RUM_APPLICATION_ID>',
|
|
25
|
+
trackResources: true,
|
|
26
|
+
headerCaptureRules: 'defaults'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// <DatadogProvider configuration={config}>...</DatadogProvider>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
With `FileBasedConfiguration`, set the same value under `rumConfiguration` in your JSON configuration file:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"configuration": {
|
|
39
|
+
"rumConfiguration": {
|
|
40
|
+
"trackResources": true,
|
|
41
|
+
"headerCaptureRules": "defaults"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Modes
|
|
48
|
+
|
|
49
|
+
| Value | What gets captured |
|
|
50
|
+
|---|---|
|
|
51
|
+
| Omitted (default) | Nothing |
|
|
52
|
+
| `'defaults'` | A predefined set of caching and content headers across all URLs |
|
|
53
|
+
| `HeaderCaptureRule[]` | Custom rules — see below |
|
|
54
|
+
|
|
55
|
+
### Default headers
|
|
56
|
+
|
|
57
|
+
`'defaults'` captures:
|
|
58
|
+
|
|
59
|
+
- **Response:** `Cache-Control`, `ETag`, `Age`, `Expires`, `Content-Type`, `Content-Encoding`, `Content-Length`, `Vary`, `Server-Timing`, `X-Cache`
|
|
60
|
+
- **Request:** `Cache-Control`, `Content-Type`
|
|
61
|
+
|
|
62
|
+
### Custom rules
|
|
63
|
+
|
|
64
|
+
Use an array of rules to control exactly which headers are captured and for which URLs:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
headerCaptureRules: [
|
|
68
|
+
// Capture default headers everywhere
|
|
69
|
+
{ type: 'defaults' },
|
|
70
|
+
|
|
71
|
+
// Capture a custom response header on a specific API
|
|
72
|
+
{
|
|
73
|
+
type: 'matchResponseHeaders',
|
|
74
|
+
headers: ['x-request-id', 'x-ratelimit-remaining'],
|
|
75
|
+
forURLs: ['api.example.com']
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// Capture a custom request header on a path prefix
|
|
79
|
+
{
|
|
80
|
+
type: 'matchRequestHeaders',
|
|
81
|
+
headers: ['x-device-id'],
|
|
82
|
+
forURLs: ['api.example.com/v2']
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Each rule has a `type`:
|
|
88
|
+
|
|
89
|
+
| `type` | Captures from |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `'defaults'` | Request + response (predefined set) |
|
|
92
|
+
| `'matchHeaders'` | Both request and response (named headers) |
|
|
93
|
+
| `'matchRequestHeaders'` | Request only |
|
|
94
|
+
| `'matchResponseHeaders'` | Response only |
|
|
95
|
+
|
|
96
|
+
The optional `forURLs` field scopes a rule to specific URL patterns. Supports hostname-only (`api.example.com`) or hostname + path prefix (`api.example.com/v2`). Omit it (or use `['*']`) to match all URLs.
|
|
97
|
+
|
|
98
|
+
- A hostname matches itself and its subdomains (`api.example.com` matches `cdn.api.example.com`), but never a hostname that only appears in the path or query of another URL.
|
|
99
|
+
- A path prefix matches whole path segments: `api.example.com/v2` matches `/v2` and `/v2/users`, but not `/v22`.
|
|
100
|
+
- URLs are matched the way HTTP clients resolve them: `..` and `.` segments (including `%2e` encodings) are resolved first, so `api.example.com/public/../private` does not match `api.example.com/public`. Equivalent hostname spellings are normalized (percent-encodings, fullwidth characters, `。`/`.`/`。` label separators, extra slashes after `https:`), and a URL without a path (`https://api.example.com?x=1`) matches as `/`. Hostnames in `forURLs` are normalized the same way. Hostnames match case-insensitively, paths case-sensitively.
|
|
101
|
+
|
|
102
|
+
**Rule precedence:** when multiple rules match a URL, their header sets are merged. However, if at least one scoped rule (with explicit `forURLs` patterns) matches, catch-all rules (no `forURLs`, or a `forURLs` list containing `'*'`) are ignored for that URL. For example, `[{ type: 'defaults' }, { type: 'matchResponseHeaders', headers: ['x-request-id'], forURLs: ['api.example.com'] }]` captures only `x-request-id` on `api.example.com`, and the default headers everywhere else.
|
|
103
|
+
|
|
104
|
+
## Output
|
|
105
|
+
|
|
106
|
+
Captured headers appear as attributes on RUM resource events:
|
|
107
|
+
|
|
108
|
+
- `_dd.request_headers` — captured request headers
|
|
109
|
+
- `_dd.response_headers` — captured response headers
|
|
110
|
+
|
|
111
|
+
Header names use RFC Title-Case for default headers (`Cache-Control`, `ETag`, …) and preserve the casing from your rule's `headers` array for custom headers.
|
|
112
|
+
|
|
113
|
+
When nothing is captured these attributes are omitted entirely.
|
|
114
|
+
|
|
115
|
+
## Supported clients
|
|
116
|
+
|
|
117
|
+
Headers are captured for every request tracked by the SDK:
|
|
118
|
+
|
|
119
|
+
- **XHR** (`trackResources: true`) — covers React Native's built-in `fetch`, axios and any other XMLHttpRequest-based client.
|
|
120
|
+
- **Global Fetch** (`trackFetchResources: true`) — covers the Expo-installed global `fetch`. When the global `fetch` is backed by XHR, headers are reported once, on the Fetch resource. Direct imports retained from `expo/fetch` are not intercepted.
|
|
121
|
+
|
|
122
|
+
Fetch `Headers` lowercase header names, so on Fetch resources custom request headers use the casing from your rule's `headers` array rather than the casing passed to `fetch`.
|
|
123
|
+
|
|
124
|
+
Requests that fail without a response (aborted, network error) never report headers.
|
|
125
|
+
|
|
126
|
+
## Security
|
|
127
|
+
|
|
128
|
+
Two filters are always enforced, regardless of configuration:
|
|
129
|
+
|
|
130
|
+
**Sensitive header blocklist** — headers matching patterns like `token`, `cookie`, `secret`, `authorization`, `password`, `bearer`, `api-key`, `x-forwarded-for`, etc. are always blocked and never stored.
|
|
131
|
+
|
|
132
|
+
**SDK tracing headers** — the Datadog and W3C/B3 tracing headers injected by the SDK itself (`x-datadog-trace-id`, `traceparent`, `b3`, etc.) are always excluded.
|
|
133
|
+
|
|
134
|
+
## Size limits
|
|
135
|
+
|
|
136
|
+
To protect event size, the SDK enforces:
|
|
137
|
+
|
|
138
|
+
- **128 bytes** max per header value (values are truncated)
|
|
139
|
+
- **100 headers** max total (request + response combined)
|
|
140
|
+
- **2 048 bytes** max total across all header names and values
|
|
141
|
+
|
|
142
|
+
All limits are measured in UTF-8 bytes.
|