@datadog/mobile-react-native 2.14.1 → 3.0.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 +6 -6
- package/README.md +23 -13
- package/android/build.gradle +10 -11
- package/android/gradle.properties +1 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +36 -93
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +46 -59
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +2 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +98 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +125 -75
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +199 -90
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +151 -24
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +57 -33
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +2 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdTelemetry.kt +96 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +20 -19
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +100 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +68 -14
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +94 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +70 -11
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +58 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +63 -43
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +2024 -1199
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +44 -40
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +60 -91
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +34 -14
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +47 -43
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +0 -1
- package/android/src/test/resources/input/complete-configuration.json +32 -28
- package/android/src/test/resources/input/malformed-configuration.json +1 -1
- package/android/src/test/resources/input/minimal-configuration.json +4 -2
- package/datadog-configuration.schema.json +187 -139
- package/ios/Sources/AnyEncodable.swift +14 -7
- package/ios/Sources/Attributes.swift +0 -7
- package/ios/Sources/DatadogSDKWrapper.swift +12 -128
- package/ios/Sources/DdLogsImplementation.swift +9 -39
- package/ios/Sources/DdRum.mm +89 -1
- package/ios/Sources/DdRumImplementation.swift +79 -0
- package/ios/Sources/DdSdk.mm +76 -11
- package/ios/Sources/DdSdkConfiguration.swift +159 -117
- package/ios/Sources/DdSdkImplementation.swift +235 -82
- package/ios/Sources/DdSdkNativeInitialization.swift +116 -80
- package/ios/Sources/DdTelemetry.swift +49 -0
- package/ios/Sources/GlobalState.swift +1 -1
- package/ios/Sources/RNDdSdkConfiguration.swift +334 -172
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +43 -4
- package/lib/commonjs/DdAttributes.js.map +1 -0
- package/lib/commonjs/DdSdkReactNative.js +159 -56
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/InternalLog.js +1 -1
- package/lib/commonjs/config/DatadogProviderConfiguration.js +25 -0
- package/lib/commonjs/config/DatadogProviderConfiguration.js.map +1 -0
- package/lib/commonjs/config/FileBasedConfiguration.js +349 -0
- package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -0
- package/lib/commonjs/config/FileBasedConfiguration.type.js +6 -0
- package/lib/commonjs/config/FileBasedConfiguration.type.js.map +1 -0
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +51 -0
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -0
- package/lib/commonjs/config/async/PartialInitializationConfiguration.js +6 -0
- package/lib/commonjs/config/async/PartialInitializationConfiguration.js.map +1 -0
- package/lib/commonjs/config/async/asyncInitializationHelper.js +44 -0
- package/lib/commonjs/config/async/asyncInitializationHelper.js.map +1 -0
- package/lib/commonjs/config/features/CoreConfiguration.js +104 -0
- package/lib/commonjs/config/features/CoreConfiguration.js.map +1 -0
- package/lib/commonjs/config/features/CoreConfiguration.type.js +6 -0
- package/lib/commonjs/config/features/CoreConfiguration.type.js.map +1 -0
- package/lib/commonjs/config/features/CoreConfigurationNative.js +38 -0
- package/lib/commonjs/config/features/CoreConfigurationNative.js.map +1 -0
- package/lib/commonjs/config/features/LogsConfiguration.js +36 -0
- package/lib/commonjs/config/features/LogsConfiguration.js.map +1 -0
- package/lib/commonjs/config/features/LogsConfiguration.type.js +6 -0
- package/lib/commonjs/config/features/LogsConfiguration.type.js.map +1 -0
- package/lib/commonjs/config/features/LogsConfigurationNative.js +2 -0
- package/lib/commonjs/config/features/LogsConfigurationNative.js.map +1 -0
- package/lib/commonjs/config/features/RumConfiguration.js +120 -0
- package/lib/commonjs/config/features/RumConfiguration.js.map +1 -0
- package/lib/commonjs/config/features/RumConfiguration.type.js +6 -0
- package/lib/commonjs/config/features/RumConfiguration.type.js.map +1 -0
- package/lib/commonjs/config/features/RumConfigurationNative.js +2 -0
- package/lib/commonjs/config/features/RumConfigurationNative.js.map +1 -0
- package/lib/commonjs/config/features/TraceConfiguration.js +24 -0
- package/lib/commonjs/config/features/TraceConfiguration.js.map +1 -0
- package/lib/commonjs/config/features/TraceConfiguration.type.js +2 -0
- package/lib/commonjs/config/features/TraceConfiguration.type.js.map +1 -0
- package/lib/commonjs/config/features/TraceConfigurationNative.js +2 -0
- package/lib/commonjs/config/features/TraceConfigurationNative.js.map +1 -0
- package/lib/commonjs/config/types/BatchProcessingLevel.js +30 -0
- package/lib/commonjs/config/types/BatchProcessingLevel.js.map +1 -0
- package/lib/commonjs/config/types/BatchSize.js +31 -0
- package/lib/commonjs/config/types/BatchSize.js.map +1 -0
- package/lib/commonjs/config/types/InitializationMode.js +17 -0
- package/lib/commonjs/config/types/InitializationMode.js.map +1 -0
- package/lib/commonjs/config/types/InitializationModeForTelemetry.js +2 -0
- package/lib/commonjs/config/types/InitializationModeForTelemetry.js.map +1 -0
- package/lib/commonjs/{ProxyConfiguration.js → config/types/ProxyConfiguration.js} +6 -0
- package/lib/commonjs/config/types/ProxyConfiguration.js.map +1 -0
- package/lib/commonjs/config/types/SdkVerbosity.js.map +1 -0
- package/lib/commonjs/config/types/TrackingConsent.js.map +1 -0
- package/lib/commonjs/config/types/UploadFrequency.js +30 -0
- package/lib/commonjs/config/types/UploadFrequency.js.map +1 -0
- package/lib/commonjs/config/types/VitalsUpdateFrequency.js +19 -0
- package/lib/commonjs/config/types/VitalsUpdateFrequency.js.map +1 -0
- package/lib/commonjs/config/types/index.js +68 -0
- package/lib/commonjs/config/types/index.js.map +1 -0
- package/lib/commonjs/index.js +51 -21
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +13 -9
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/logs/eventMapper.js +4 -1
- package/lib/commonjs/logs/eventMapper.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +0 -45
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +56 -28
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/helper.js +63 -0
- package/lib/commonjs/rum/helper.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +14 -18
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +15 -25
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +15 -5
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +34 -22
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.js +21 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +16 -3
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +10 -12
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.js +6 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +41 -47
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.js +62 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/headers.js +36 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/headers.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +19 -8
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js +90 -48
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js +1 -1
- package/lib/commonjs/rum/types.js +1 -9
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/sdk/AccountInfoSingleton/AccountInfoSingleton.js +46 -0
- package/lib/commonjs/sdk/AccountInfoSingleton/AccountInfoSingleton.js.map +1 -0
- package/lib/commonjs/sdk/AccountInfoSingleton/types.js +2 -0
- package/lib/commonjs/sdk/AccountInfoSingleton/types.js.map +1 -0
- package/lib/commonjs/sdk/AttributesEncoding/attributesEncoding.js +51 -0
- package/lib/commonjs/sdk/AttributesEncoding/attributesEncoding.js.map +1 -0
- package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js +140 -0
- package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js.map +1 -0
- package/lib/commonjs/{utils → sdk/AttributesEncoding}/errorUtils.js +39 -22
- package/lib/commonjs/sdk/AttributesEncoding/errorUtils.js.map +1 -0
- package/lib/commonjs/sdk/AttributesEncoding/helpers.js +123 -0
- package/lib/commonjs/sdk/AttributesEncoding/helpers.js.map +1 -0
- package/lib/commonjs/sdk/AttributesEncoding/types.js +2 -0
- package/lib/commonjs/sdk/AttributesEncoding/types.js.map +1 -0
- package/lib/commonjs/sdk/AttributesEncoding/utils.js +36 -0
- package/lib/commonjs/sdk/AttributesEncoding/utils.js.map +1 -0
- package/lib/commonjs/sdk/AttributesSingleton/AttributesSingleton.js +27 -1
- package/lib/commonjs/sdk/AttributesSingleton/AttributesSingleton.js.map +1 -1
- package/lib/commonjs/sdk/DatadogInternalBridge/DdSdkInternalNativeBridge.js +3 -3
- package/lib/commonjs/sdk/DatadogInternalBridge/DdSdkInternalNativeBridge.js.map +1 -1
- package/lib/commonjs/sdk/DatadogInternalBridge/DdSdkInternalNativeBridgeEvent.js +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +4 -4
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/DatadogProvider.js +10 -9
- package/lib/commonjs/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/DatadogProviderState.js +28 -0
- package/lib/commonjs/sdk/DatadogProvider/DatadogProviderState.js.map +1 -0
- package/lib/commonjs/sdk/DdSdk.js +4 -2
- package/lib/commonjs/sdk/DdSdk.js.map +1 -1
- package/lib/commonjs/sdk/DdSdkInternal.js +86 -0
- package/lib/commonjs/sdk/DdSdkInternal.js.map +1 -0
- package/lib/commonjs/sdk/EventMappers/EventMapper.js +6 -3
- package/lib/commonjs/sdk/EventMappers/EventMapper.js.map +1 -1
- package/lib/commonjs/sdk/GlobalState/GlobalState.js +5 -11
- package/lib/commonjs/sdk/GlobalState/GlobalState.js.map +1 -1
- package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js +6 -1
- package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -1
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
- package/lib/commonjs/trace/DdTrace.js +7 -5
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/types.js +19 -46
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/longTasksUtils.js.map +1 -1
- package/lib/commonjs/utils/singletonUtils.js +21 -0
- package/lib/commonjs/utils/singletonUtils.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdAttributes.js.map +1 -0
- package/lib/module/DdSdkReactNative.js +155 -52
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/InternalLog.js +1 -1
- package/lib/module/InternalLog.js.map +1 -1
- package/lib/module/config/DatadogProviderConfiguration.js +18 -0
- package/lib/module/config/DatadogProviderConfiguration.js.map +1 -0
- package/lib/module/config/FileBasedConfiguration.js +341 -0
- package/lib/module/config/FileBasedConfiguration.js.map +1 -0
- package/lib/module/config/FileBasedConfiguration.type.js +2 -0
- package/lib/module/config/FileBasedConfiguration.type.js.map +1 -0
- package/lib/module/config/async/AutoInstrumentationConfiguration.js +45 -0
- package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -0
- package/lib/module/config/async/PartialInitializationConfiguration.js +2 -0
- package/lib/module/config/async/PartialInitializationConfiguration.js.map +1 -0
- package/lib/module/config/async/asyncInitializationHelper.js +36 -0
- package/lib/module/config/async/asyncInitializationHelper.js.map +1 -0
- package/lib/module/config/features/CoreConfiguration.js +98 -0
- package/lib/module/config/features/CoreConfiguration.js.map +1 -0
- package/lib/module/config/features/CoreConfiguration.type.js +2 -0
- package/lib/module/config/features/CoreConfiguration.type.js.map +1 -0
- package/lib/module/config/features/CoreConfigurationNative.js +31 -0
- package/lib/module/config/features/CoreConfigurationNative.js.map +1 -0
- package/lib/module/config/features/LogsConfiguration.js +30 -0
- package/lib/module/config/features/LogsConfiguration.js.map +1 -0
- package/lib/module/config/features/LogsConfiguration.type.js +2 -0
- package/lib/module/config/features/LogsConfiguration.type.js.map +1 -0
- package/lib/module/config/features/LogsConfigurationNative.js +2 -0
- package/lib/module/config/features/LogsConfigurationNative.js.map +1 -0
- package/lib/module/config/features/RumConfiguration.js +114 -0
- package/lib/module/config/features/RumConfiguration.js.map +1 -0
- package/lib/module/config/features/RumConfiguration.type.js +2 -0
- package/lib/module/config/features/RumConfiguration.type.js.map +1 -0
- package/lib/module/config/features/RumConfigurationNative.js +2 -0
- package/lib/module/config/features/RumConfigurationNative.js.map +1 -0
- package/lib/module/config/features/TraceConfiguration.js +18 -0
- package/lib/module/config/features/TraceConfiguration.js.map +1 -0
- package/lib/module/config/features/TraceConfiguration.type.js +2 -0
- package/lib/module/config/features/TraceConfiguration.type.js.map +1 -0
- package/lib/module/config/features/TraceConfigurationNative.js +2 -0
- package/lib/module/config/features/TraceConfigurationNative.js.map +1 -0
- package/lib/module/config/types/BatchProcessingLevel.js +25 -0
- package/lib/module/config/types/BatchProcessingLevel.js.map +1 -0
- package/lib/module/config/types/BatchSize.js +26 -0
- package/lib/module/config/types/BatchSize.js.map +1 -0
- package/lib/module/config/types/InitializationMode.js +11 -0
- package/lib/module/config/types/InitializationMode.js.map +1 -0
- package/lib/module/config/types/InitializationModeForTelemetry.js +2 -0
- package/lib/module/config/types/InitializationModeForTelemetry.js.map +1 -0
- package/lib/module/{ProxyConfiguration.js → config/types/ProxyConfiguration.js} +6 -0
- package/lib/module/config/types/ProxyConfiguration.js.map +1 -0
- package/lib/module/config/types/SdkVerbosity.js.map +1 -0
- package/lib/module/config/types/TrackingConsent.js.map +1 -0
- package/lib/module/config/types/UploadFrequency.js +25 -0
- package/lib/module/config/types/UploadFrequency.js.map +1 -0
- package/lib/module/config/types/VitalsUpdateFrequency.js +13 -0
- package/lib/module/config/types/VitalsUpdateFrequency.js.map +1 -0
- package/lib/module/config/types/index.js +15 -0
- package/lib/module/config/types/index.js.map +1 -0
- package/lib/module/index.js +13 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/logs/DdLogs.js +13 -9
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/logs/eventMapper.js +4 -1
- package/lib/module/logs/eventMapper.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +1 -43
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +54 -26
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/helper.js +49 -0
- package/lib/module/rum/helper.js.map +1 -0
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +14 -18
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +15 -24
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +15 -5
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +33 -21
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.js +22 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +13 -2
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +10 -11
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.js +2 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +27 -33
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.js +54 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.js.map +1 -0
- 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/distributedTracing/headers.js +30 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/headers.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +14 -3
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js +90 -48
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -1
- package/lib/module/rum/types.js +0 -9
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/sdk/AccountInfoSingleton/AccountInfoSingleton.js +39 -0
- package/lib/module/sdk/AccountInfoSingleton/AccountInfoSingleton.js.map +1 -0
- package/lib/module/sdk/AccountInfoSingleton/types.js +2 -0
- package/lib/module/sdk/AccountInfoSingleton/types.js.map +1 -0
- package/lib/module/sdk/AttributesEncoding/attributesEncoding.js +46 -0
- package/lib/module/sdk/AttributesEncoding/attributesEncoding.js.map +1 -0
- package/lib/module/sdk/AttributesEncoding/defaultEncoders.js +134 -0
- package/lib/module/sdk/AttributesEncoding/defaultEncoders.js.map +1 -0
- package/lib/module/{utils → sdk/AttributesEncoding}/errorUtils.js +37 -20
- package/lib/module/sdk/AttributesEncoding/errorUtils.js.map +1 -0
- package/lib/module/sdk/AttributesEncoding/helpers.js +115 -0
- package/lib/module/sdk/AttributesEncoding/helpers.js.map +1 -0
- package/lib/module/sdk/AttributesEncoding/types.js +2 -0
- package/lib/module/sdk/AttributesEncoding/types.js.map +1 -0
- package/lib/module/sdk/AttributesEncoding/utils.js +28 -0
- package/lib/module/sdk/AttributesEncoding/utils.js.map +1 -0
- package/lib/module/sdk/AttributesSingleton/AttributesSingleton.js +27 -1
- package/lib/module/sdk/AttributesSingleton/AttributesSingleton.js.map +1 -1
- package/lib/module/sdk/DatadogInternalBridge/DdSdkInternalNativeBridge.js +2 -2
- package/lib/module/sdk/DatadogInternalBridge/DdSdkInternalNativeBridge.js.map +1 -1
- package/lib/module/sdk/DatadogInternalBridge/DdSdkInternalNativeBridgeEvent.js +1 -1
- package/lib/module/sdk/DatadogInternalBridge/DdSdkInternalNativeBridgeEvent.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +4 -4
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/DatadogProvider.js +9 -8
- package/lib/module/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/DatadogProviderState.js +21 -0
- package/lib/module/sdk/DatadogProvider/DatadogProviderState.js.map +1 -0
- package/lib/module/sdk/DdSdk.js +4 -4
- package/lib/module/sdk/DdSdk.js.map +1 -1
- package/lib/module/sdk/DdSdkInternal.js +80 -0
- package/lib/module/sdk/DdSdkInternal.js.map +1 -0
- package/lib/module/sdk/EventMappers/EventMapper.js +6 -3
- package/lib/module/sdk/EventMappers/EventMapper.js.map +1 -1
- package/lib/module/sdk/GlobalState/GlobalState.js +5 -10
- package/lib/module/sdk/GlobalState/GlobalState.js.map +1 -1
- package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js +6 -1
- package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -1
- package/lib/module/specs/NativeDdRum.js.map +1 -1
- package/lib/module/specs/NativeDdSdk.js.map +1 -1
- package/lib/module/trace/DdTrace.js +7 -6
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/types.js +22 -42
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/longTasksUtils.js.map +1 -1
- package/lib/module/utils/singletonUtils.js +14 -0
- package/lib/module/utils/singletonUtils.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdAttributes.d.ts.map +1 -0
- package/lib/typescript/DdSdkReactNative.d.ts +49 -12
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/InternalLog.d.ts +1 -1
- package/lib/typescript/InternalLog.d.ts.map +1 -1
- package/lib/typescript/config/DatadogProviderConfiguration.d.ts +12 -0
- package/lib/typescript/config/DatadogProviderConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/FileBasedConfiguration.d.ts +17 -0
- package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts +52 -0
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +60 -0
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +47 -0
- package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/async/asyncInitializationHelper.d.ts +5 -0
- package/lib/typescript/config/async/asyncInitializationHelper.d.ts.map +1 -0
- package/lib/typescript/config/features/CoreConfiguration.d.ts +52 -0
- package/lib/typescript/config/features/CoreConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/features/CoreConfiguration.type.d.ts +90 -0
- package/lib/typescript/config/features/CoreConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/config/features/CoreConfigurationNative.d.ts +54 -0
- package/lib/typescript/config/features/CoreConfigurationNative.d.ts.map +1 -0
- package/lib/typescript/config/features/LogsConfiguration.d.ts +17 -0
- package/lib/typescript/config/features/LogsConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/features/LogsConfiguration.type.d.ts +24 -0
- package/lib/typescript/config/features/LogsConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/config/features/LogsConfigurationNative.d.ts +6 -0
- package/lib/typescript/config/features/LogsConfigurationNative.d.ts.map +1 -0
- package/lib/typescript/config/features/RumConfiguration.d.ts +66 -0
- package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/features/RumConfiguration.type.d.ts +131 -0
- package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/config/features/RumConfigurationNative.d.ts +25 -0
- package/lib/typescript/config/features/RumConfigurationNative.d.ts.map +1 -0
- package/lib/typescript/config/features/TraceConfiguration.d.ts +10 -0
- package/lib/typescript/config/features/TraceConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/features/TraceConfiguration.type.d.ts +11 -0
- package/lib/typescript/config/features/TraceConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/config/features/TraceConfigurationNative.d.ts +4 -0
- package/lib/typescript/config/features/TraceConfigurationNative.d.ts.map +1 -0
- package/lib/typescript/config/types/BatchProcessingLevel.d.ts +18 -0
- package/lib/typescript/config/types/BatchProcessingLevel.d.ts.map +1 -0
- package/lib/typescript/config/types/BatchSize.d.ts +19 -0
- package/lib/typescript/config/types/BatchSize.d.ts.map +1 -0
- package/lib/typescript/config/types/InitializationMode.d.ts +5 -0
- package/lib/typescript/config/types/InitializationMode.d.ts.map +1 -0
- package/lib/typescript/config/types/InitializationModeForTelemetry.d.ts +2 -0
- package/lib/typescript/config/types/InitializationModeForTelemetry.d.ts.map +1 -0
- package/lib/typescript/config/types/ProxyConfiguration.d.ts.map +1 -0
- package/lib/typescript/config/types/SdkVerbosity.d.ts.map +1 -0
- package/lib/typescript/config/types/TrackingConsent.d.ts.map +1 -0
- package/lib/typescript/config/types/UploadFrequency.d.ts +18 -0
- package/lib/typescript/config/types/UploadFrequency.d.ts.map +1 -0
- package/lib/typescript/config/types/VitalsUpdateFrequency.d.ts +7 -0
- package/lib/typescript/config/types/VitalsUpdateFrequency.d.ts.map +1 -0
- package/lib/typescript/config/types/index.d.ts +10 -0
- package/lib/typescript/config/types/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +20 -9
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/logs/DdLogs.d.ts +2 -1
- package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
- package/lib/typescript/logs/eventMapper.d.ts +3 -2
- package/lib/typescript/logs/eventMapper.d.ts.map +1 -1
- package/lib/typescript/logs/types.d.ts +1 -16
- package/lib/typescript/logs/types.d.ts.map +1 -1
- package/lib/typescript/nativeModulesTypes.d.ts +2 -15
- package/lib/typescript/nativeModulesTypes.d.ts.map +1 -1
- package/lib/typescript/rum/DdRum.d.ts +10 -1
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +1 -1
- package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts.map +1 -1
- package/lib/typescript/rum/helper.d.ts +10 -0
- package/lib/typescript/rum/helper.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts +6 -6
- package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +7 -0
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +12 -6
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +5 -17
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.d.ts +20 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +3 -24
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.d.ts +12 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/headers.d.ts +24 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/headers.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +2 -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/interfaces/RumResource.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts.map +1 -1
- package/lib/typescript/rum/types.d.ts +47 -7
- package/lib/typescript/rum/types.d.ts.map +1 -1
- package/lib/typescript/sdk/AccountInfoSingleton/AccountInfoSingleton.d.ts +15 -0
- package/lib/typescript/sdk/AccountInfoSingleton/AccountInfoSingleton.d.ts.map +1 -0
- package/lib/typescript/sdk/AccountInfoSingleton/types.d.ts +6 -0
- package/lib/typescript/sdk/AccountInfoSingleton/types.d.ts.map +1 -0
- package/lib/typescript/sdk/AttributesEncoding/attributesEncoding.d.ts +13 -0
- package/lib/typescript/sdk/AttributesEncoding/attributesEncoding.d.ts.map +1 -0
- package/lib/typescript/sdk/AttributesEncoding/defaultEncoders.d.ts +33 -0
- package/lib/typescript/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -0
- package/lib/typescript/{utils → sdk/AttributesEncoding}/errorUtils.d.ts +4 -4
- package/lib/typescript/sdk/AttributesEncoding/errorUtils.d.ts.map +1 -0
- package/lib/typescript/sdk/AttributesEncoding/helpers.d.ts +17 -0
- package/lib/typescript/sdk/AttributesEncoding/helpers.d.ts.map +1 -0
- package/lib/typescript/sdk/AttributesEncoding/types.d.ts +21 -0
- package/lib/typescript/sdk/AttributesEncoding/types.d.ts.map +1 -0
- package/lib/typescript/sdk/AttributesEncoding/utils.d.ts +7 -0
- package/lib/typescript/sdk/AttributesEncoding/utils.d.ts.map +1 -0
- package/lib/typescript/sdk/AttributesSingleton/AttributesSingleton.d.ts +5 -1
- package/lib/typescript/sdk/AttributesSingleton/AttributesSingleton.d.ts.map +1 -1
- package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts +4 -3
- package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts.map +1 -1
- package/lib/typescript/sdk/DatadogProvider/DatadogProviderState.d.ts +9 -0
- package/lib/typescript/sdk/DatadogProvider/DatadogProviderState.d.ts.map +1 -0
- package/lib/typescript/sdk/DdSdk.d.ts +2 -3
- package/lib/typescript/sdk/DdSdk.d.ts.map +1 -1
- package/lib/typescript/sdk/DdSdkInternal.d.ts +39 -0
- package/lib/typescript/sdk/DdSdkInternal.d.ts.map +1 -0
- package/lib/typescript/sdk/EventMappers/EventMapper.d.ts +3 -1
- package/lib/typescript/sdk/EventMappers/EventMapper.d.ts.map +1 -1
- package/lib/typescript/sdk/GlobalState/GlobalState.d.ts +3 -3
- package/lib/typescript/sdk/GlobalState/GlobalState.d.ts.map +1 -1
- package/lib/typescript/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +2 -1
- package/lib/typescript/sdk/UserInfoSingleton/UserInfoSingleton.d.ts.map +1 -1
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +1 -2
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdRum.d.ts +45 -0
- package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdSdk.d.ts +34 -6
- package/lib/typescript/specs/NativeDdSdk.d.ts.map +1 -1
- package/lib/typescript/trace/DdTrace.d.ts +1 -2
- package/lib/typescript/trace/DdTrace.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +74 -92
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/longTasksUtils.d.ts +1 -1
- package/lib/typescript/utils/longTasksUtils.d.ts.map +1 -1
- package/lib/typescript/utils/singletonUtils.d.ts +2 -0
- package/lib/typescript/utils/singletonUtils.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +246 -104
- package/src/InternalLog.tsx +1 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +415 -207
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +237 -153
- package/src/__tests__/InternalLog.test.tsx +1 -1
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +2 -2
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +139 -216
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +10 -7
- package/src/config/DatadogProviderConfiguration.ts +17 -0
- package/src/config/FileBasedConfiguration.ts +464 -0
- package/src/config/FileBasedConfiguration.type.ts +66 -0
- package/src/config/__tests__/FileBasedConfiguration.test.ts +334 -0
- package/src/config/__tests__/__fixtures__/configuration-all-fields.json +57 -0
- package/src/config/__tests__/__fixtures__/malformed-configuration.json +4 -0
- package/src/config/async/AutoInstrumentationConfiguration.ts +126 -0
- package/src/config/async/PartialInitializationConfiguration.ts +58 -0
- package/src/config/async/asyncInitializationHelper.tsx +51 -0
- package/src/config/features/CoreConfiguration.ts +130 -0
- package/src/config/features/CoreConfiguration.type.ts +119 -0
- package/src/config/features/CoreConfigurationNative.ts +50 -0
- package/src/config/features/LogsConfiguration.ts +38 -0
- package/src/config/features/LogsConfiguration.type.ts +33 -0
- package/src/config/features/LogsConfigurationNative.ts +10 -0
- package/src/config/features/RumConfiguration.ts +137 -0
- package/src/config/features/RumConfiguration.type.ts +164 -0
- package/src/config/features/RumConfigurationNative.ts +26 -0
- package/src/config/features/TraceConfiguration.ts +24 -0
- package/src/config/features/TraceConfiguration.type.ts +17 -0
- package/src/config/features/TraceConfigurationNative.ts +8 -0
- package/src/config/types/BatchProcessingLevel.ts +23 -0
- package/src/config/types/BatchSize.ts +24 -0
- package/src/config/types/InitializationMode.ts +9 -0
- package/src/config/types/InitializationModeForTelemetry.ts +11 -0
- package/src/{ProxyConfiguration.tsx → config/types/ProxyConfiguration.ts} +6 -0
- package/src/config/types/UploadFrequency.tsx +23 -0
- package/src/config/types/VitalsUpdateFrequency.ts +11 -0
- package/src/config/types/index.ts +15 -0
- package/src/index.tsx +33 -16
- package/src/logs/DdLogs.ts +14 -13
- package/src/logs/__tests__/DdLogs.test.ts +60 -107
- package/src/logs/__tests__/eventMapper.test.ts +1 -1
- package/src/logs/eventMapper.ts +5 -4
- package/src/logs/types.ts +1 -20
- package/src/nativeModulesTypes.ts +2 -17
- package/src/rum/DdRum.ts +139 -42
- package/src/rum/__tests__/DdRum.test.ts +217 -47
- package/src/rum/eventMappers/errorEventMapper.ts +1 -1
- package/src/rum/helper.ts +62 -0
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +20 -38
- package/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts +20 -32
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +1 -1
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +18 -5
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +44 -23
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -2
- package/src/rum/instrumentation/resourceTracking/__tests__/__utils__/XMLHttpRequestMock.ts +44 -23
- package/src/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.ts +24 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.tsx +17 -2
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +327 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +22 -31
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.ts +29 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +54 -35
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.ts +80 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/headers.ts +29 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +19 -7
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +177 -119
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/baggageHeaderUtils.test.ts +85 -13
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.ts +110 -52
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.ts +1 -1
- package/src/rum/types.ts +68 -8
- package/src/sdk/AccountInfoSingleton/AccountInfoSingleton.ts +49 -0
- package/src/sdk/AccountInfoSingleton/__tests__/AccountInfoSingleton.test.ts +90 -0
- package/src/sdk/AccountInfoSingleton/types.ts +11 -0
- package/src/sdk/AttributesEncoding/__tests__/attributesEncoding.test.ts +518 -0
- package/src/sdk/AttributesEncoding/__tests__/defaultEncoders.test.ts +198 -0
- package/src/sdk/AttributesEncoding/attributesEncoding.ts +56 -0
- package/src/sdk/AttributesEncoding/defaultEncoders.ts +175 -0
- package/src/{utils → sdk/AttributesEncoding}/errorUtils.ts +50 -22
- package/src/sdk/AttributesEncoding/helpers.ts +176 -0
- package/src/sdk/AttributesEncoding/types.ts +33 -0
- package/src/sdk/AttributesEncoding/utils.ts +31 -0
- package/src/sdk/AttributesSingleton/AttributesSingleton.ts +25 -1
- package/src/sdk/AttributesSingleton/__tests__/AttributesSingleton.test.ts +52 -8
- package/src/sdk/DatadogInternalBridge/DdSdkInternalNativeBridge.tsx +2 -2
- package/src/sdk/DatadogInternalBridge/DdSdkInternalNativeBridgeEvent.tsx +1 -1
- package/src/sdk/DatadogInternalBridge/__tests__/DdSdkNativeBridge.test.tsx +1 -1
- package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +4 -4
- package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +5 -5
- package/src/sdk/DatadogProvider/DatadogProvider.tsx +12 -16
- package/src/sdk/DatadogProvider/DatadogProviderState.ts +30 -0
- package/src/sdk/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +18 -7
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +59 -33
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +26 -10
- package/src/sdk/DdSdk.ts +8 -5
- package/src/sdk/DdSdkInternal.ts +121 -0
- package/src/sdk/EventMappers/EventMapper.ts +9 -4
- package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +3 -3
- package/src/sdk/GlobalState/GlobalState.tsx +10 -11
- package/src/sdk/UserInfoSingleton/UserInfoSingleton.ts +9 -2
- package/src/sdk/UserInfoSingleton/__tests__/UserInfoSingleton.test.ts +46 -9
- package/src/sdk/UserInfoSingleton/types.ts +1 -4
- package/src/specs/NativeDdRum.ts +65 -0
- package/src/specs/NativeDdSdk.ts +40 -6
- package/src/trace/DdTrace.ts +11 -7
- package/src/trace/__tests__/DdTrace.test.ts +7 -8
- package/src/types.tsx +97 -76
- package/src/utils/__tests__/errorUtils.test.ts +1 -1
- package/src/utils/__tests__/singletonUtils.test.ts +75 -0
- package/src/utils/longTasksUtils.ts +1 -3
- package/src/utils/singletonUtils.ts +17 -0
- package/src/version.ts +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +0 -412
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +0 -1
- package/lib/commonjs/ProxyConfiguration.js.map +0 -1
- package/lib/commonjs/SdkVerbosity.js.map +0 -1
- package/lib/commonjs/TrackingConsent.js.map +0 -1
- package/lib/commonjs/rum/DdAttributes.js.map +0 -1
- package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js +0 -185
- package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +0 -1
- package/lib/commonjs/utils/argsUtils.js +0 -41
- package/lib/commonjs/utils/argsUtils.js.map +0 -1
- package/lib/commonjs/utils/errorUtils.js.map +0 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +0 -403
- package/lib/module/DdSdkReactNativeConfiguration.js.map +0 -1
- package/lib/module/ProxyConfiguration.js.map +0 -1
- package/lib/module/SdkVerbosity.js.map +0 -1
- package/lib/module/TrackingConsent.js.map +0 -1
- package/lib/module/rum/DdAttributes.js.map +0 -1
- package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js +0 -176
- package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +0 -1
- package/lib/module/utils/argsUtils.js +0 -35
- package/lib/module/utils/argsUtils.js.map +0 -1
- package/lib/module/utils/errorUtils.js.map +0 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +0 -376
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts.map +0 -1
- package/lib/typescript/ProxyConfiguration.d.ts.map +0 -1
- package/lib/typescript/SdkVerbosity.d.ts.map +0 -1
- package/lib/typescript/TrackingConsent.d.ts.map +0 -1
- package/lib/typescript/rum/DdAttributes.d.ts.map +0 -1
- package/lib/typescript/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts +0 -34
- package/lib/typescript/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts.map +0 -1
- package/lib/typescript/utils/argsUtils.d.ts +0 -8
- package/lib/typescript/utils/argsUtils.d.ts.map +0 -1
- package/lib/typescript/utils/errorUtils.d.ts.map +0 -1
- package/src/DdSdkReactNativeConfiguration.tsx +0 -582
- package/src/sdk/FileBasedConfiguration/FileBasedConfiguration.ts +0 -241
- package/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +0 -255
- package/src/sdk/FileBasedConfiguration/__tests__/__fixtures__/configuration-all-fields.json +0 -27
- package/src/sdk/FileBasedConfiguration/__tests__/__fixtures__/malformed-configuration.json +0 -5
- package/src/utils/__tests__/argsUtils.test.ts +0 -66
- package/src/utils/argsUtils.ts +0 -41
- /package/lib/commonjs/{rum/DdAttributes.js → DdAttributes.js} +0 -0
- /package/lib/commonjs/{SdkVerbosity.js → config/types/SdkVerbosity.js} +0 -0
- /package/lib/commonjs/{TrackingConsent.js → config/types/TrackingConsent.js} +0 -0
- /package/lib/module/{rum/DdAttributes.js → DdAttributes.js} +0 -0
- /package/lib/module/{SdkVerbosity.js → config/types/SdkVerbosity.js} +0 -0
- /package/lib/module/{TrackingConsent.js → config/types/TrackingConsent.js} +0 -0
- /package/lib/typescript/{rum/DdAttributes.d.ts → DdAttributes.d.ts} +0 -0
- /package/lib/typescript/{ProxyConfiguration.d.ts → config/types/ProxyConfiguration.d.ts} +0 -0
- /package/lib/typescript/{SdkVerbosity.d.ts → config/types/SdkVerbosity.d.ts} +0 -0
- /package/lib/typescript/{TrackingConsent.d.ts → config/types/TrackingConsent.d.ts} +0 -0
- /package/src/{rum/DdAttributes.ts → DdAttributes.ts} +0 -0
- /package/src/{SdkVerbosity.tsx → config/types/SdkVerbosity.ts} +0 -0
- /package/src/{TrackingConsent.tsx → config/types/TrackingConsent.ts} +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
stringEncoder,
|
|
9
|
+
numberEncoder,
|
|
10
|
+
booleanEncoder,
|
|
11
|
+
nullishEncoder,
|
|
12
|
+
arrayEncoder,
|
|
13
|
+
dateEncoder,
|
|
14
|
+
errorEncoder,
|
|
15
|
+
mapEncoder
|
|
16
|
+
} from '../defaultEncoders';
|
|
17
|
+
import { warn } from '../utils';
|
|
18
|
+
|
|
19
|
+
jest.mock('../utils', () => ({
|
|
20
|
+
...jest.requireActual('../utils'),
|
|
21
|
+
warn: jest.fn()
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
describe('default encoders', () => {
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
(warn as jest.Mock).mockClear();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('stringEncoder', () => {
|
|
30
|
+
it('encodes a string directly', () => {
|
|
31
|
+
expect(stringEncoder.check('foo')).toBe(true);
|
|
32
|
+
expect(stringEncoder.encode('foo')).toBe('foo');
|
|
33
|
+
});
|
|
34
|
+
it('rejects non-strings', () => {
|
|
35
|
+
expect(stringEncoder.check(123)).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('numberEncoder', () => {
|
|
40
|
+
it('encodes finite numbers', () => {
|
|
41
|
+
expect(numberEncoder.check(42)).toBe(true);
|
|
42
|
+
expect(numberEncoder.encode(42)).toBe(42);
|
|
43
|
+
});
|
|
44
|
+
it('drops NaN and Infinity', () => {
|
|
45
|
+
expect(numberEncoder.encode(NaN)).toBeUndefined();
|
|
46
|
+
expect(numberEncoder.encode(Infinity)).toBeUndefined();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('booleanEncoder', () => {
|
|
51
|
+
it('encodes booleans directly', () => {
|
|
52
|
+
expect(booleanEncoder.check(true)).toBe(true);
|
|
53
|
+
expect(booleanEncoder.encode(true)).toBe(true);
|
|
54
|
+
expect(booleanEncoder.encode(false)).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('nullishEncoder', () => {
|
|
59
|
+
it('encodes null and undefined directly', () => {
|
|
60
|
+
expect(nullishEncoder.check(null)).toBe(true);
|
|
61
|
+
expect(nullishEncoder.check(undefined)).toBe(true);
|
|
62
|
+
expect(nullishEncoder.encode(null)).toBeNull();
|
|
63
|
+
expect(nullishEncoder.encode(undefined)).toBeUndefined();
|
|
64
|
+
});
|
|
65
|
+
it('rejects non-nullish values', () => {
|
|
66
|
+
expect(nullishEncoder.check('')).toBe(false);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('arrayEncoder', () => {
|
|
71
|
+
it('encodes array of primitives', () => {
|
|
72
|
+
const result = arrayEncoder.encode([1, 'a', true]);
|
|
73
|
+
expect(result).toEqual([1, 'a', true]);
|
|
74
|
+
});
|
|
75
|
+
it('encodes nested objects inside array', () => {
|
|
76
|
+
const result = arrayEncoder.encode([{ foo: 'bar' }]);
|
|
77
|
+
expect((result as Record<string, string>[])[0]).toHaveProperty(
|
|
78
|
+
'foo',
|
|
79
|
+
'bar'
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
it('encodes nested arrays recursively', () => {
|
|
83
|
+
const result = arrayEncoder.encode([[1, 2], ['a']]);
|
|
84
|
+
expect(result).toEqual([[1, 2], ['a']]);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('dateEncoder', () => {
|
|
89
|
+
it('encodes Date to string', () => {
|
|
90
|
+
const date = new Date('2020-01-01T00:00:00Z');
|
|
91
|
+
expect(dateEncoder.check(date)).toBe(true);
|
|
92
|
+
expect(dateEncoder.encode(date)).toEqual(String(date));
|
|
93
|
+
});
|
|
94
|
+
it('rejects non-Date values', () => {
|
|
95
|
+
expect(dateEncoder.check('2020-01-01')).toBe(false);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('errorEncoder', () => {
|
|
100
|
+
it('encodes Error with name, message, and stack', () => {
|
|
101
|
+
const error = new Error('boom');
|
|
102
|
+
const result = errorEncoder.encode(error) as Record<string, string>;
|
|
103
|
+
expect(result.name).toBe('Error');
|
|
104
|
+
expect(result.message).toBe('boom');
|
|
105
|
+
expect(result.stack).toContain('Error: boom');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('removes duplicate fields like stack', () => {
|
|
109
|
+
const err = {
|
|
110
|
+
message: 'fail'
|
|
111
|
+
} as Record<string, any>;
|
|
112
|
+
|
|
113
|
+
err.name = 'CustomError';
|
|
114
|
+
err.stacktrace = 'custom-stack';
|
|
115
|
+
err.stack = 'error-stacktrace';
|
|
116
|
+
err.componentStack = 'component-stack';
|
|
117
|
+
|
|
118
|
+
const result = errorEncoder.encode(err) as Record<string, string>;
|
|
119
|
+
expect(result.name).toBe('CustomError');
|
|
120
|
+
expect(result.message).toBe('fail');
|
|
121
|
+
expect(result.stack).toBe('custom-stack');
|
|
122
|
+
expect(result).not.toHaveProperty('stacktrace');
|
|
123
|
+
expect(result).toHaveProperty('componentStack');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('encodes error with cause', () => {
|
|
127
|
+
const cause = new Error('inner');
|
|
128
|
+
const err: any = new Error('outer');
|
|
129
|
+
err.cause = cause;
|
|
130
|
+
const result = errorEncoder.encode(err) as Record<string, any>;
|
|
131
|
+
expect(result.cause).toBe(cause);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('mapEncoder', () => {
|
|
136
|
+
it('encodes map with string keys', () => {
|
|
137
|
+
const map = new Map<string, any>([
|
|
138
|
+
['a', 1],
|
|
139
|
+
['b', 'str']
|
|
140
|
+
]);
|
|
141
|
+
const result = mapEncoder.encode(map);
|
|
142
|
+
expect(result).toEqual(
|
|
143
|
+
expect.arrayContaining([
|
|
144
|
+
{ key: 'a', keyType: 'string', value: 1 },
|
|
145
|
+
{ key: 'b', keyType: 'string', value: 'str' }
|
|
146
|
+
])
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('encodes map with object key', () => {
|
|
151
|
+
const keyObj = { toString: () => 'objKey' };
|
|
152
|
+
const map = new Map<any, any>([[keyObj, 123]]);
|
|
153
|
+
const result = mapEncoder.encode(map);
|
|
154
|
+
expect((result as Record<string, any>[])[0]).toHaveProperty(
|
|
155
|
+
'key',
|
|
156
|
+
'objKey'
|
|
157
|
+
);
|
|
158
|
+
expect((result as Record<string, any>[])[0]).toHaveProperty(
|
|
159
|
+
'keyType',
|
|
160
|
+
'object'
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('encodes map with symbol key', () => {
|
|
165
|
+
const map = new Map<any, any>([[Symbol('s'), 'val']]);
|
|
166
|
+
const result = mapEncoder.encode(map);
|
|
167
|
+
expect((result as Record<string, any>[])[0].key).toContain(
|
|
168
|
+
'Symbol(s)'
|
|
169
|
+
);
|
|
170
|
+
expect((result as Record<string, any>[])[0].keyType).toBe('symbol');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('encodes map with null and undefined keys', () => {
|
|
174
|
+
const map = new Map<any, any>([
|
|
175
|
+
[null, 'nullVal'],
|
|
176
|
+
[undefined, 'undefVal']
|
|
177
|
+
]);
|
|
178
|
+
const result = mapEncoder.encode(map);
|
|
179
|
+
expect(result).toEqual(
|
|
180
|
+
expect.arrayContaining([
|
|
181
|
+
{ key: 'null', keyType: 'object', value: 'nullVal' },
|
|
182
|
+
{
|
|
183
|
+
key: 'undefined',
|
|
184
|
+
keyType: 'undefined',
|
|
185
|
+
value: 'undefVal'
|
|
186
|
+
}
|
|
187
|
+
])
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('warns and drops unsupported key types', () => {
|
|
192
|
+
const map = new Map<any, any>([[BigInt(1), 'big']]);
|
|
193
|
+
const result = mapEncoder.encode(map);
|
|
194
|
+
expect((result as Record<string, any>[])[0].key).toBe('1'); // bigint stringified
|
|
195
|
+
expect(warn).not.toHaveBeenCalled(); // bigint is allowed
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { DdSdk } from '../DdSdk';
|
|
8
|
+
|
|
9
|
+
import { builtInEncoders } from './defaultEncoders';
|
|
10
|
+
import type { EncodeContext } from './helpers';
|
|
11
|
+
import { encodeAttributesInPlace } from './helpers';
|
|
12
|
+
import type { Encodable } from './types';
|
|
13
|
+
import { isPlainObject, warn } from './utils';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Encodes arbitrary input into a flat dictionary of attributes.
|
|
17
|
+
* - Objects are flattened using dot syntax. Max depth handling is done on the native layer by the
|
|
18
|
+
* Android and iOS SDKs.
|
|
19
|
+
* - We assume the input does not always conform to Record<string, Encodable> and we:
|
|
20
|
+
* - Fallback to { context: givenValue } if a primitive is passed
|
|
21
|
+
* - Apply built-in and consumer encoders to all values
|
|
22
|
+
* - Drop values of unsupported types
|
|
23
|
+
* - Internal SDK attributes (starting with '_dd.') are preserved as-is without flattening
|
|
24
|
+
*/
|
|
25
|
+
export function encodeAttributes(input: unknown): Record<string, Encodable> {
|
|
26
|
+
const result: Record<string, Encodable> = {};
|
|
27
|
+
const allEncoders = [...DdSdk.attributeEncoders, ...builtInEncoders];
|
|
28
|
+
const context: EncodeContext = { numOfAttributes: 0 };
|
|
29
|
+
if (isPlainObject(input)) {
|
|
30
|
+
for (const [k, v] of Object.entries(input)) {
|
|
31
|
+
// Internal SDK attributes (starting with '_dd.') should not be flattened
|
|
32
|
+
// as they have a specific structure expected by the native SDK
|
|
33
|
+
if (k.startsWith('_dd.')) {
|
|
34
|
+
result[k] = v as Encodable;
|
|
35
|
+
context.numOfAttributes++;
|
|
36
|
+
} else {
|
|
37
|
+
encodeAttributesInPlace(v, result, [k], allEncoders, context);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
// Fallback for primitive values passed as root
|
|
42
|
+
encodeAttributesInPlace(
|
|
43
|
+
input,
|
|
44
|
+
result,
|
|
45
|
+
['context'],
|
|
46
|
+
allEncoders,
|
|
47
|
+
context
|
|
48
|
+
);
|
|
49
|
+
warn(
|
|
50
|
+
'Warning: attributes root should be an object.\n' +
|
|
51
|
+
'Received a primitive/array instead, which will be wrapped under the "context" key.'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* ----------------------------------------
|
|
8
|
+
* Built-in encoders
|
|
9
|
+
* -------------------------------------- */
|
|
10
|
+
import { DdSdk } from '../DdSdk';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
getErrorMessage,
|
|
14
|
+
getErrorName,
|
|
15
|
+
getErrorStackTrace
|
|
16
|
+
} from './errorUtils';
|
|
17
|
+
import { encodeAttributesInPlace, sanitizeForJson } from './helpers';
|
|
18
|
+
import type { AttributeEncoder, Encodable } from './types';
|
|
19
|
+
import { warn } from './utils';
|
|
20
|
+
|
|
21
|
+
/** Primitives: keep them explicit so the full pipeline is used uniformly. */
|
|
22
|
+
export const stringEncoder: AttributeEncoder<string> = {
|
|
23
|
+
check: (v): v is string => typeof v === 'string',
|
|
24
|
+
encode: v => v
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const numberEncoder: AttributeEncoder<number> = {
|
|
28
|
+
check: (v): v is number => typeof v === 'number',
|
|
29
|
+
encode: v => (Number.isFinite(v) ? v : undefined) // drop non-finite
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const booleanEncoder: AttributeEncoder<boolean> = {
|
|
33
|
+
check: (v): v is boolean => typeof v === 'boolean',
|
|
34
|
+
encode: v => v
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const nullishEncoder: AttributeEncoder<null | undefined> = {
|
|
38
|
+
check: (v): v is null | undefined => v === null || v === undefined,
|
|
39
|
+
encode: v => v
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Array encoder:
|
|
44
|
+
* - Sanitizes each item through the encoder pipeline.
|
|
45
|
+
* - Returns the sanitized array (it may later be flattened by the visitor if it still contains objects).
|
|
46
|
+
*/
|
|
47
|
+
export const arrayEncoder: AttributeEncoder<unknown[]> = {
|
|
48
|
+
check: Array.isArray,
|
|
49
|
+
encode: (arr: unknown[]) =>
|
|
50
|
+
arr.map(x =>
|
|
51
|
+
sanitizeForJson(x, [...DdSdk.attributeEncoders, ...builtInEncoders])
|
|
52
|
+
)
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Default Datadog Date Encoder.
|
|
57
|
+
* This does not make assumptions on format; uses String(date).
|
|
58
|
+
*/
|
|
59
|
+
export const dateEncoder: AttributeEncoder<Date> = {
|
|
60
|
+
check: (v: unknown): v is Date => v instanceof Date,
|
|
61
|
+
encode: (d: Date) => String(d)
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Extended Error Encoder.
|
|
66
|
+
* Serializes name, message, stack, and cause (ES2022+) for Error objects.
|
|
67
|
+
* If the error has other enumerable properties, they are included and sanitized.
|
|
68
|
+
*/
|
|
69
|
+
export const errorEncoder: AttributeEncoder<any> = {
|
|
70
|
+
check: (v: unknown): v is Error => v instanceof Error,
|
|
71
|
+
encode: (e: any) => {
|
|
72
|
+
const extraAttributes: Record<string, Encodable> = {};
|
|
73
|
+
|
|
74
|
+
// In React Native, some errors have extra fields we want to capture
|
|
75
|
+
if (e && typeof e === 'object') {
|
|
76
|
+
const allEncoders = [
|
|
77
|
+
...DdSdk.attributeEncoders,
|
|
78
|
+
...builtInEncoders
|
|
79
|
+
];
|
|
80
|
+
encodeAttributesInPlace(e, extraAttributes, [], allEncoders);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Remove fields that are duplicated in the dedicated fields below
|
|
84
|
+
if ('stacktrace' in e) {
|
|
85
|
+
delete extraAttributes['stacktrace'];
|
|
86
|
+
} else if ('stack' in e) {
|
|
87
|
+
delete extraAttributes['stack'];
|
|
88
|
+
} else if ('componentStack' in e) {
|
|
89
|
+
delete extraAttributes['componentStack'];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
...extraAttributes,
|
|
94
|
+
name: getErrorName(e),
|
|
95
|
+
message: getErrorMessage(e),
|
|
96
|
+
stack: getErrorStackTrace(e),
|
|
97
|
+
cause: (e as any).cause
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Map encoder:
|
|
104
|
+
* - Converts Map into an array of entries.
|
|
105
|
+
* - Each entry is { key: string, keyType: string, value: Encodable }.
|
|
106
|
+
* - Keys are stringified with type info to reduce collision risk.
|
|
107
|
+
* - Entries with un-stringifiable keys are dropped (with a warning).
|
|
108
|
+
*/
|
|
109
|
+
export const mapEncoder: AttributeEncoder<Map<unknown, unknown>> = {
|
|
110
|
+
check: (v: unknown): v is Map<unknown, unknown> => v instanceof Map,
|
|
111
|
+
encode: (map: Map<any, any>) => {
|
|
112
|
+
const entries: Encodable[] = [];
|
|
113
|
+
|
|
114
|
+
for (const [k, v] of map.entries()) {
|
|
115
|
+
try {
|
|
116
|
+
const keyType = typeof k;
|
|
117
|
+
let keyStr: string;
|
|
118
|
+
|
|
119
|
+
if (k === null) {
|
|
120
|
+
keyStr = 'null';
|
|
121
|
+
} else if (k === undefined) {
|
|
122
|
+
keyStr = 'undefined';
|
|
123
|
+
} else if (
|
|
124
|
+
keyType === 'string' ||
|
|
125
|
+
keyType === 'number' ||
|
|
126
|
+
keyType === 'boolean' ||
|
|
127
|
+
keyType === 'bigint'
|
|
128
|
+
) {
|
|
129
|
+
keyStr = String(k);
|
|
130
|
+
} else if (typeof k === 'symbol') {
|
|
131
|
+
keyStr = k.description
|
|
132
|
+
? `Symbol(${k.description})`
|
|
133
|
+
: 'Symbol';
|
|
134
|
+
} else if (typeof k === 'object' || typeof k === 'function') {
|
|
135
|
+
// Try to get a descriptive form
|
|
136
|
+
if (typeof (k as any).toString === 'function') {
|
|
137
|
+
keyStr = (k as any).toString();
|
|
138
|
+
} else {
|
|
139
|
+
keyStr = Object.prototype.toString.call(k); // e.g. "[object Object]"
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
warn(
|
|
143
|
+
`Dropping Map entry: unsupported key type "${keyType}".`
|
|
144
|
+
);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const allEncoders = [
|
|
149
|
+
...DdSdk.attributeEncoders,
|
|
150
|
+
...builtInEncoders
|
|
151
|
+
];
|
|
152
|
+
entries.push({
|
|
153
|
+
key: keyStr,
|
|
154
|
+
keyType,
|
|
155
|
+
value: sanitizeForJson(v, allEncoders)
|
|
156
|
+
});
|
|
157
|
+
} catch (err) {
|
|
158
|
+
warn(`Failed to encode Map key: ${k}. ERROR: ${String(err)}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return entries;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export const builtInEncoders = [
|
|
167
|
+
stringEncoder,
|
|
168
|
+
numberEncoder,
|
|
169
|
+
booleanEncoder,
|
|
170
|
+
nullishEncoder,
|
|
171
|
+
arrayEncoder,
|
|
172
|
+
dateEncoder,
|
|
173
|
+
errorEncoder,
|
|
174
|
+
mapEncoder
|
|
175
|
+
];
|
|
@@ -3,23 +3,9 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
9
|
-
export const DEFAULT_ERROR_NAME = 'Error';
|
|
10
|
-
|
|
11
|
-
export const getErrorMessage = (error: any | undefined): string => {
|
|
12
|
-
let message = EMPTY_MESSAGE;
|
|
13
|
-
if (error === undefined || error === null) {
|
|
14
|
-
message = EMPTY_MESSAGE;
|
|
15
|
-
} else if (typeof error === 'object' && 'message' in error) {
|
|
16
|
-
message = String(error.message);
|
|
17
|
-
} else {
|
|
18
|
-
message = String(error);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return message;
|
|
22
|
-
};
|
|
6
|
+
export const ERROR_EMPTY_STACKTRACE = '';
|
|
7
|
+
export const ERROR_EMPTY_MESSAGE = 'Unknown Error';
|
|
8
|
+
export const ERROR_DEFAULT_NAME = 'Error';
|
|
23
9
|
|
|
24
10
|
/**
|
|
25
11
|
* Will extract the stack from the error, taking the first key found among:
|
|
@@ -30,13 +16,13 @@ export const getErrorMessage = (error: any | undefined): string => {
|
|
|
30
16
|
* generate a stack from this information.
|
|
31
17
|
*/
|
|
32
18
|
export const getErrorStackTrace = (error: any | undefined): string => {
|
|
33
|
-
let stack =
|
|
19
|
+
let stack = ERROR_EMPTY_STACKTRACE;
|
|
34
20
|
|
|
35
21
|
try {
|
|
36
22
|
if (error === undefined || error === null) {
|
|
37
|
-
stack =
|
|
23
|
+
stack = ERROR_EMPTY_STACKTRACE;
|
|
38
24
|
} else if (typeof error === 'string') {
|
|
39
|
-
stack =
|
|
25
|
+
stack = ERROR_EMPTY_STACKTRACE;
|
|
40
26
|
} else if (typeof error === 'object') {
|
|
41
27
|
if ('stacktrace' in error) {
|
|
42
28
|
stack = String(error.stacktrace);
|
|
@@ -58,10 +44,52 @@ export const getErrorStackTrace = (error: any | undefined): string => {
|
|
|
58
44
|
return stack;
|
|
59
45
|
};
|
|
60
46
|
|
|
47
|
+
export const getErrorMessage = (error: any | undefined): string => {
|
|
48
|
+
if (error == null) {
|
|
49
|
+
return ERROR_EMPTY_MESSAGE;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// If it's an actual Error (or subclass)
|
|
53
|
+
if (error instanceof Error) {
|
|
54
|
+
// Prefer .message if defined, otherwise fallback to .toString()
|
|
55
|
+
return error.message || error.toString() || ERROR_EMPTY_MESSAGE;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// If it's an object with a message property (not necessarily Error)
|
|
59
|
+
if (
|
|
60
|
+
typeof error === 'object' &&
|
|
61
|
+
'message' in error &&
|
|
62
|
+
typeof (error as any).message === 'string'
|
|
63
|
+
) {
|
|
64
|
+
return (error as any).message || ERROR_EMPTY_MESSAGE;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// If it’s a primitive (string, number, boolean, symbol)
|
|
68
|
+
if (
|
|
69
|
+
typeof error === 'string' ||
|
|
70
|
+
typeof error === 'number' ||
|
|
71
|
+
typeof error === 'boolean' ||
|
|
72
|
+
typeof error === 'symbol'
|
|
73
|
+
) {
|
|
74
|
+
return String(error);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// If it has its own toString (not the default Object one)
|
|
78
|
+
if (
|
|
79
|
+
typeof error?.toString === 'function' &&
|
|
80
|
+
error.toString !== Object.prototype.toString
|
|
81
|
+
) {
|
|
82
|
+
return error.toString();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Fallback
|
|
86
|
+
return ERROR_EMPTY_MESSAGE;
|
|
87
|
+
};
|
|
88
|
+
|
|
61
89
|
export const getErrorName = (error: unknown): string => {
|
|
62
90
|
try {
|
|
63
91
|
if (typeof error !== 'object' || error === null) {
|
|
64
|
-
return
|
|
92
|
+
return ERROR_DEFAULT_NAME;
|
|
65
93
|
}
|
|
66
94
|
if (typeof (error as any).name === 'string') {
|
|
67
95
|
return (error as any).name;
|
|
@@ -69,5 +97,5 @@ export const getErrorName = (error: unknown): string => {
|
|
|
69
97
|
} catch (e) {
|
|
70
98
|
// Do nothing
|
|
71
99
|
}
|
|
72
|
-
return
|
|
100
|
+
return ERROR_DEFAULT_NAME;
|
|
73
101
|
};
|