@datadog/mobile-react-native 1.2.1 → 1.3.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/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +31 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +222 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +6 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ActionEventForgeryFactory.kt +106 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +2 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ResourceEventForgeryFactory.kt +116 -0
- package/ios/Sources/Attributes.swift +14 -0
- package/ios/Sources/DdSdk.swift +18 -0
- package/lib/commonjs/DdSdkReactNative.js +40 -8
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +42 -2
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/foundation.js +2 -139
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +18 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +71 -0
- package/lib/commonjs/logs/DdLogs.js.map +1 -0
- package/lib/commonjs/logs/eventMapper.js +39 -0
- package/lib/commonjs/logs/eventMapper.js.map +1 -0
- package/lib/commonjs/logs/types.js +2 -0
- package/lib/commonjs/{rum/instrumentation/EventsInterceptor.js.map → logs/types.js.map} +0 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +234 -0
- package/lib/commonjs/rum/DdRum.js.map +1 -0
- package/lib/commonjs/rum/eventMappers/actionEventMapper.js +36 -0
- package/lib/commonjs/rum/eventMappers/actionEventMapper.js.map +1 -0
- package/lib/commonjs/rum/eventMappers/errorEventMapper.js +32 -0
- package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -0
- package/lib/commonjs/rum/eventMappers/resourceEventMapper.js +38 -0
- package/lib/commonjs/rum/eventMappers/resourceEventMapper.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/{DdEventsInterceptor.js → interactionTracking/DdEventsInterceptor.js} +6 -6
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/{DdRumUserInteractionTracking.js → interactionTracking/DdRumUserInteractionTracking.js} +4 -4
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/{EventsInterceptor.js → interactionTracking/EventsInterceptor.js} +0 -0
- package/lib/{module/rum/instrumentation → commonjs/rum/instrumentation/interactionTracking}/EventsInterceptor.js.map +0 -0
- package/lib/commonjs/rum/instrumentation/{NoOpEventsInterceptor.js → interactionTracking/NoOpEventsInterceptor.js} +0 -0
- package/lib/commonjs/rum/instrumentation/{NoOpEventsInterceptor.js.map → interactionTracking/NoOpEventsInterceptor.js.map} +0 -0
- package/lib/commonjs/rum/instrumentation/{ShallowObjectEqualityChecker.js → interactionTracking/ShallowObjectEqualityChecker.js} +0 -0
- package/lib/commonjs/rum/instrumentation/{ShallowObjectEqualityChecker.js.map → interactionTracking/ShallowObjectEqualityChecker.js.map} +0 -0
- package/lib/commonjs/rum/instrumentation/{getJsxRuntime.js → interactionTracking/getJsxRuntime.js} +0 -0
- package/lib/commonjs/rum/instrumentation/{getJsxRuntime.js.map → interactionTracking/getJsxRuntime.js.map} +0 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +3 -3
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +2 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -1
- package/lib/commonjs/rum/types.js +42 -0
- package/lib/commonjs/rum/types.js.map +1 -0
- package/lib/commonjs/sdk/AttributesSingleton/AttributesSingleton.js +45 -0
- package/lib/commonjs/sdk/AttributesSingleton/AttributesSingleton.js.map +1 -0
- package/lib/commonjs/sdk/AttributesSingleton/types.js +2 -0
- package/lib/commonjs/sdk/AttributesSingleton/types.js.map +1 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/BoundedBuffer.js +4 -4
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/BufferSingleton.js +0 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/BufferSingleton.js.map +0 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/DatadogBuffer.js +0 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/DatadogBuffer.js.map +0 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/PassThroughBuffer.js +0 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/PassThroughBuffer.js.map +0 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/bufferNativeCall.js +0 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/Buffer/bufferNativeCall.js.map +0 -0
- package/lib/commonjs/{DatadogProvider → sdk/DatadogProvider}/DatadogProvider.js +4 -4
- package/lib/commonjs/sdk/DatadogProvider/DatadogProvider.js.map +1 -0
- package/lib/commonjs/sdk/EventMappers/EventMapper.js +85 -0
- package/lib/commonjs/sdk/EventMappers/EventMapper.js.map +1 -0
- package/lib/commonjs/sdk/EventMappers/utils/deepClone.js +98 -0
- package/lib/commonjs/sdk/EventMappers/utils/deepClone.js.map +1 -0
- package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js +43 -0
- package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -0
- package/lib/commonjs/sdk/UserInfoSingleton/types.js +2 -0
- package/lib/commonjs/sdk/UserInfoSingleton/types.js.map +1 -0
- package/lib/commonjs/types.js +1 -26
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +33 -7
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +42 -2
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/foundation.js +2 -124
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +5 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/logs/DdLogs.js +64 -0
- package/lib/module/logs/DdLogs.js.map +1 -0
- package/lib/module/logs/eventMapper.js +20 -0
- package/lib/module/logs/eventMapper.js.map +1 -0
- package/lib/module/logs/types.js +2 -0
- package/lib/module/logs/types.js.map +1 -0
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +212 -0
- package/lib/module/rum/DdRum.js.map +1 -0
- package/lib/module/rum/eventMappers/actionEventMapper.js +26 -0
- package/lib/module/rum/eventMappers/actionEventMapper.js.map +1 -0
- package/lib/module/rum/eventMappers/errorEventMapper.js +22 -0
- package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -0
- package/lib/module/rum/eventMappers/resourceEventMapper.js +28 -0
- package/lib/module/rum/eventMappers/resourceEventMapper.js.map +1 -0
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +2 -2
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/{DdEventsInterceptor.js → interactionTracking/DdEventsInterceptor.js} +6 -6
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -0
- package/lib/module/rum/instrumentation/{DdRumUserInteractionTracking.js → interactionTracking/DdRumUserInteractionTracking.js} +4 -4
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -0
- package/lib/module/rum/instrumentation/{EventsInterceptor.js → interactionTracking/EventsInterceptor.js} +0 -0
- package/lib/module/rum/instrumentation/interactionTracking/EventsInterceptor.js.map +1 -0
- package/lib/module/rum/instrumentation/{NoOpEventsInterceptor.js → interactionTracking/NoOpEventsInterceptor.js} +0 -0
- package/lib/module/rum/instrumentation/{NoOpEventsInterceptor.js.map → interactionTracking/NoOpEventsInterceptor.js.map} +0 -0
- package/lib/module/rum/instrumentation/{ShallowObjectEqualityChecker.js → interactionTracking/ShallowObjectEqualityChecker.js} +0 -0
- package/lib/module/rum/instrumentation/{ShallowObjectEqualityChecker.js.map → interactionTracking/ShallowObjectEqualityChecker.js.map} +0 -0
- package/lib/module/rum/instrumentation/{getJsxRuntime.js → interactionTracking/getJsxRuntime.js} +0 -0
- package/lib/module/rum/instrumentation/{getJsxRuntime.js.map → interactionTracking/getJsxRuntime.js.map} +0 -0
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -2
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +2 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -1
- package/lib/module/rum/types.js +33 -0
- package/lib/module/rum/types.js.map +1 -0
- package/lib/module/sdk/AttributesSingleton/AttributesSingleton.js +36 -0
- package/lib/module/sdk/AttributesSingleton/AttributesSingleton.js.map +1 -0
- package/lib/module/sdk/AttributesSingleton/types.js +2 -0
- package/lib/module/sdk/AttributesSingleton/types.js.map +1 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/BoundedBuffer.js +4 -4
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/BufferSingleton.js +0 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/BufferSingleton.js.map +0 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/DatadogBuffer.js +0 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/DatadogBuffer.js.map +0 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/PassThroughBuffer.js +0 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/PassThroughBuffer.js.map +0 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/bufferNativeCall.js +0 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/Buffer/bufferNativeCall.js.map +0 -0
- package/lib/module/{DatadogProvider → sdk/DatadogProvider}/DatadogProvider.js +4 -4
- package/lib/module/sdk/DatadogProvider/DatadogProvider.js.map +1 -0
- package/lib/module/sdk/EventMappers/EventMapper.js +72 -0
- package/lib/module/sdk/EventMappers/EventMapper.js.map +1 -0
- package/lib/module/sdk/EventMappers/utils/deepClone.js +89 -0
- package/lib/module/sdk/EventMappers/utils/deepClone.js.map +1 -0
- package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js +34 -0
- package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -0
- package/lib/module/sdk/UserInfoSingleton/types.js +2 -0
- package/lib/module/sdk/UserInfoSingleton/types.js.map +1 -0
- package/lib/module/types.js +0 -23
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +7 -3
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +22 -0
- package/lib/typescript/foundation.d.ts +2 -4
- package/lib/typescript/index.d.ts +5 -3
- package/lib/typescript/logs/DdLogs.d.ts +14 -0
- package/lib/typescript/logs/eventMapper.d.ts +11 -0
- package/lib/typescript/logs/types.d.ts +54 -0
- package/lib/typescript/nativeModulesTypes.d.ts +1 -1
- package/lib/typescript/rum/DdRum.d.ts +36 -0
- package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts +21 -0
- package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +21 -0
- package/lib/typescript/rum/eventMappers/resourceEventMapper.d.ts +25 -0
- package/lib/typescript/rum/instrumentation/{DdEventsInterceptor.d.ts → interactionTracking/DdEventsInterceptor.d.ts} +0 -0
- package/lib/typescript/rum/instrumentation/{DdRumUserInteractionTracking.d.ts → interactionTracking/DdRumUserInteractionTracking.d.ts} +0 -0
- package/lib/typescript/rum/instrumentation/{EventsInterceptor.d.ts → interactionTracking/EventsInterceptor.d.ts} +0 -0
- package/lib/typescript/rum/instrumentation/{NoOpEventsInterceptor.d.ts → interactionTracking/NoOpEventsInterceptor.d.ts} +0 -0
- package/lib/typescript/rum/instrumentation/{ShallowObjectEqualityChecker.d.ts → interactionTracking/ShallowObjectEqualityChecker.d.ts} +0 -0
- package/lib/typescript/rum/instrumentation/{getJsxRuntime.d.ts → interactionTracking/getJsxRuntime.d.ts} +0 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +3 -1
- package/lib/typescript/rum/types.d.ts +110 -0
- package/lib/typescript/sdk/AttributesSingleton/AttributesSingleton.d.ts +12 -0
- package/lib/typescript/sdk/AttributesSingleton/types.d.ts +3 -0
- package/lib/typescript/{DatadogProvider → sdk/DatadogProvider}/Buffer/BoundedBuffer.d.ts +0 -0
- package/lib/typescript/{DatadogProvider → sdk/DatadogProvider}/Buffer/BufferSingleton.d.ts +0 -0
- package/lib/typescript/{DatadogProvider → sdk/DatadogProvider}/Buffer/DatadogBuffer.d.ts +0 -0
- package/lib/typescript/{DatadogProvider → sdk/DatadogProvider}/Buffer/PassThroughBuffer.d.ts +0 -0
- package/lib/typescript/{DatadogProvider → sdk/DatadogProvider}/Buffer/bufferNativeCall.d.ts +0 -0
- package/lib/typescript/{DatadogProvider → sdk/DatadogProvider}/DatadogProvider.d.ts +2 -2
- package/lib/typescript/sdk/EventMappers/EventMapper.d.ts +24 -0
- package/lib/typescript/sdk/EventMappers/utils/deepClone.d.ts +10 -0
- package/lib/typescript/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +12 -0
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +6 -0
- package/lib/typescript/types.d.ts +0 -139
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/scripts/replace-react-require.js +3 -2
- package/src/DdSdkReactNative.tsx +41 -7
- package/src/DdSdkReactNativeConfiguration.tsx +83 -3
- package/src/__tests__/DdSdkReactNative.test.tsx +244 -13
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +22 -1
- package/src/__tests__/{longTasksUtils.ts → longTasksUtils.test.ts} +0 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +4 -3
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +1 -1
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +5 -3
- package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +1 -1
- package/src/foundation.tsx +4 -114
- package/src/index.tsx +5 -3
- package/src/logs/DdLogs.ts +67 -0
- package/src/logs/__tests__/DdLogs.test.ts +51 -0
- package/src/logs/__tests__/eventMapper.test.ts +53 -0
- package/src/logs/eventMapper.ts +43 -0
- package/src/logs/types.ts +70 -0
- package/src/nativeModulesTypes.ts +1 -1
- package/src/rum/DdRum.ts +387 -0
- package/src/rum/__tests__/DdRum.test.ts +386 -0
- package/src/rum/eventMappers/actionEventMapper.ts +66 -0
- package/src/rum/eventMappers/errorEventMapper.ts +57 -0
- package/src/rum/eventMappers/resourceEventMapper.ts +74 -0
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +2 -2
- package/src/rum/instrumentation/{DdEventsInterceptor.tsx → interactionTracking/DdEventsInterceptor.tsx} +14 -6
- package/src/rum/instrumentation/{DdRumUserInteractionTracking.tsx → interactionTracking/DdRumUserInteractionTracking.tsx} +4 -4
- package/src/rum/instrumentation/{EventsInterceptor.tsx → interactionTracking/EventsInterceptor.tsx} +0 -0
- package/src/rum/instrumentation/{NoOpEventsInterceptor.tsx → interactionTracking/NoOpEventsInterceptor.tsx} +0 -0
- package/src/rum/instrumentation/{ShallowObjectEqualityChecker.ts → interactionTracking/ShallowObjectEqualityChecker.ts} +0 -0
- package/src/rum/instrumentation/{getJsxRuntime.ts → interactionTracking/getJsxRuntime.ts} +0 -0
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +2 -1
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +3 -2
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.ts +2 -1
- package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +83 -39
- package/src/rum/types.ts +182 -0
- package/src/sdk/AttributesSingleton/AttributesSingleton.ts +34 -0
- package/src/sdk/AttributesSingleton/__tests__/AttributesSingleton.test.ts +44 -0
- package/src/sdk/AttributesSingleton/types.ts +9 -0
- package/src/{DatadogProvider → sdk/DatadogProvider}/Buffer/BoundedBuffer.ts +4 -4
- package/src/{DatadogProvider → sdk/DatadogProvider}/Buffer/BufferSingleton.ts +0 -0
- package/src/{DatadogProvider → sdk/DatadogProvider}/Buffer/DatadogBuffer.ts +0 -0
- package/src/{DatadogProvider → sdk/DatadogProvider}/Buffer/PassThroughBuffer.ts +0 -0
- package/src/{DatadogProvider → sdk/DatadogProvider}/Buffer/__tests__/BoundedBuffer.test.ts +2 -2
- package/src/{DatadogProvider → sdk/DatadogProvider}/Buffer/__tests__/BufferSingleton.test.ts +0 -0
- package/src/{DatadogProvider → sdk/DatadogProvider}/Buffer/bufferNativeCall.ts +0 -0
- package/src/{DatadogProvider → sdk/DatadogProvider}/DatadogProvider.tsx +5 -5
- package/src/{DatadogProvider → sdk/DatadogProvider}/__tests__/__utils__/renderWithProvider.tsx +2 -2
- package/src/{DatadogProvider → sdk/DatadogProvider}/__tests__/initialization.test.tsx +8 -6
- package/src/{DatadogProvider → sdk/DatadogProvider}/__tests__/initializationModes.test.tsx +5 -5
- package/src/sdk/EventMappers/EventMapper.ts +94 -0
- package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +50 -0
- package/src/sdk/EventMappers/utils/__tests__/deepClone.test.ts +79 -0
- package/src/sdk/EventMappers/utils/deepClone.ts +86 -0
- package/src/sdk/UserInfoSingleton/UserInfoSingleton.ts +31 -0
- package/src/sdk/UserInfoSingleton/__tests__/UserInfoSingleton.test.ts +29 -0
- package/src/sdk/UserInfoSingleton/types.ts +12 -0
- package/src/types.tsx +0 -210
- package/src/version.ts +1 -1
- package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js.map +0 -1
- package/lib/commonjs/DatadogProvider/DatadogProvider.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +0 -1
- package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js.map +0 -1
- package/lib/module/DatadogProvider/DatadogProvider.js.map +0 -1
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +0 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +0 -1
- package/src/__tests__/DdRumWrapper.test.tsx +0 -74
- package/src/__tests__/foundation.test.ts +0 -88
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { DdRum } from '
|
|
7
|
+
import { DdRum } from '../../../../DdRum';
|
|
8
8
|
import type { RUMResource } from '../../domain/interfaces/RumResource';
|
|
9
9
|
|
|
10
10
|
import { createTimings } from './resourceTiming';
|
|
@@ -74,6 +74,7 @@ const reportResource = async (resource: RUMResource) => {
|
|
|
74
74
|
resource.request.kind,
|
|
75
75
|
resource.response.size,
|
|
76
76
|
formatResourceStopContext(resource.timings),
|
|
77
|
-
resource.timings.stopTime
|
|
77
|
+
resource.timings.stopTime,
|
|
78
|
+
resource.resourceContext
|
|
78
79
|
);
|
|
79
80
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { NativeModules } from 'react-native';
|
|
8
8
|
|
|
9
|
-
import { BufferSingleton } from '../../../../../../DatadogProvider/Buffer/BufferSingleton';
|
|
9
|
+
import { BufferSingleton } from '../../../../../../sdk/DatadogProvider/Buffer/BufferSingleton';
|
|
10
10
|
import type { RUMResource } from '../../../domain/interfaces/RumResource';
|
|
11
11
|
import { ResourceReporter } from '../ResourceReporter';
|
|
12
12
|
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import { Platform, NativeModules } from 'react-native';
|
|
8
8
|
|
|
9
|
-
import { BufferSingleton } from '../../../../../DatadogProvider/Buffer/BufferSingleton';
|
|
10
9
|
import { InternalLog } from '../../../../../InternalLog';
|
|
11
10
|
import { SdkVerbosity } from '../../../../../SdkVerbosity';
|
|
11
|
+
import { BufferSingleton } from '../../../../../sdk/DatadogProvider/Buffer/BufferSingleton';
|
|
12
|
+
import { DdRum } from '../../../../DdRum';
|
|
12
13
|
import { XMLHttpRequestMock } from '../../__tests__/__utils__/XMLHttpRequestMock';
|
|
13
14
|
import { firstPartyHostsRegexBuilder } from '../../domain/firstPartyHosts';
|
|
14
15
|
import { ResourceReporter } from '../DatadogRumResource/ResourceReporter';
|
|
@@ -32,7 +33,7 @@ const mockedInternalLog = (InternalLog as unknown) as {
|
|
|
32
33
|
};
|
|
33
34
|
jest.spyOn(global.Math, 'random');
|
|
34
35
|
|
|
35
|
-
const
|
|
36
|
+
const DdNativeRum = NativeModules.DdRum;
|
|
36
37
|
|
|
37
38
|
function randomInt(max: number): number {
|
|
38
39
|
return Math.floor(Math.random() * max);
|
|
@@ -42,8 +43,8 @@ const flushPromises = () => new Promise(setImmediate);
|
|
|
42
43
|
let xhrProxy;
|
|
43
44
|
|
|
44
45
|
beforeEach(() => {
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
DdNativeRum.startResource.mockClear();
|
|
47
|
+
DdNativeRum.stopResource.mockClear();
|
|
47
48
|
BufferSingleton.onInitialization();
|
|
48
49
|
|
|
49
50
|
xhrProxy = new XHRProxy({
|
|
@@ -66,6 +67,7 @@ afterEach(() => {
|
|
|
66
67
|
xhrProxy.onTrackingStop();
|
|
67
68
|
(Date.now as jest.MockedFunction<typeof Date.now>).mockClear();
|
|
68
69
|
jest.spyOn(global.Math, 'random').mockRestore();
|
|
70
|
+
DdRum.unregisterResourceEventMapper();
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
describe('XHRPr', () => {
|
|
@@ -88,17 +90,19 @@ describe('XHRPr', () => {
|
|
|
88
90
|
await flushPromises();
|
|
89
91
|
|
|
90
92
|
// THEN
|
|
91
|
-
expect(
|
|
92
|
-
expect(
|
|
93
|
-
expect(
|
|
93
|
+
expect(DdNativeRum.startResource.mock.calls.length).toBe(1);
|
|
94
|
+
expect(DdNativeRum.startResource.mock.calls[0][1]).toBe(method);
|
|
95
|
+
expect(DdNativeRum.startResource.mock.calls[0][2]).toBe(url);
|
|
94
96
|
|
|
95
|
-
expect(
|
|
96
|
-
expect(
|
|
97
|
-
|
|
97
|
+
expect(DdNativeRum.stopResource.mock.calls.length).toBe(1);
|
|
98
|
+
expect(DdNativeRum.stopResource.mock.calls[0][0]).toBe(
|
|
99
|
+
DdNativeRum.startResource.mock.calls[0][0]
|
|
100
|
+
);
|
|
101
|
+
expect(DdNativeRum.stopResource.mock.calls[0][1]).toBe(200);
|
|
102
|
+
expect(DdNativeRum.stopResource.mock.calls[0][2]).toBe('xhr');
|
|
103
|
+
expect(DdNativeRum.stopResource.mock.calls[0][3]).toBeGreaterThan(
|
|
104
|
+
0
|
|
98
105
|
);
|
|
99
|
-
expect(DdRum.stopResource.mock.calls[0][1]).toBe(200);
|
|
100
|
-
expect(DdRum.stopResource.mock.calls[0][2]).toBe('xhr');
|
|
101
|
-
expect(DdRum.stopResource.mock.calls[0][3]).toBeGreaterThan(0);
|
|
102
106
|
|
|
103
107
|
expect(xhr.originalOpenCalled).toBe(true);
|
|
104
108
|
expect(xhr.originalSendCalled).toBe(true);
|
|
@@ -123,17 +127,19 @@ describe('XHRPr', () => {
|
|
|
123
127
|
await flushPromises();
|
|
124
128
|
|
|
125
129
|
// THEN
|
|
126
|
-
expect(
|
|
127
|
-
expect(
|
|
128
|
-
expect(
|
|
130
|
+
expect(DdNativeRum.startResource.mock.calls.length).toBe(1);
|
|
131
|
+
expect(DdNativeRum.startResource.mock.calls[0][1]).toBe(method);
|
|
132
|
+
expect(DdNativeRum.startResource.mock.calls[0][2]).toBe(url);
|
|
129
133
|
|
|
130
|
-
expect(
|
|
131
|
-
expect(
|
|
132
|
-
|
|
134
|
+
expect(DdNativeRum.stopResource.mock.calls.length).toBe(1);
|
|
135
|
+
expect(DdNativeRum.stopResource.mock.calls[0][0]).toBe(
|
|
136
|
+
DdNativeRum.startResource.mock.calls[0][0]
|
|
137
|
+
);
|
|
138
|
+
expect(DdNativeRum.stopResource.mock.calls[0][1]).toBe(500);
|
|
139
|
+
expect(DdNativeRum.stopResource.mock.calls[0][2]).toBe('xhr');
|
|
140
|
+
expect(DdNativeRum.stopResource.mock.calls[0][3]).toBeGreaterThan(
|
|
141
|
+
0
|
|
133
142
|
);
|
|
134
|
-
expect(DdRum.stopResource.mock.calls[0][1]).toBe(500);
|
|
135
|
-
expect(DdRum.stopResource.mock.calls[0][2]).toBe('xhr');
|
|
136
|
-
expect(DdRum.stopResource.mock.calls[0][3]).toBeGreaterThan(0);
|
|
137
143
|
|
|
138
144
|
expect(xhr.originalOpenCalled).toBe(true);
|
|
139
145
|
expect(xhr.originalSendCalled).toBe(true);
|
|
@@ -158,17 +164,17 @@ describe('XHRPr', () => {
|
|
|
158
164
|
await flushPromises();
|
|
159
165
|
|
|
160
166
|
// THEN
|
|
161
|
-
expect(
|
|
162
|
-
expect(
|
|
163
|
-
expect(
|
|
167
|
+
expect(DdNativeRum.startResource.mock.calls.length).toBe(1);
|
|
168
|
+
expect(DdNativeRum.startResource.mock.calls[0][1]).toBe(method);
|
|
169
|
+
expect(DdNativeRum.startResource.mock.calls[0][2]).toBe(url);
|
|
164
170
|
|
|
165
|
-
expect(
|
|
166
|
-
expect(
|
|
167
|
-
|
|
171
|
+
expect(DdNativeRum.stopResource.mock.calls.length).toBe(1);
|
|
172
|
+
expect(DdNativeRum.stopResource.mock.calls[0][0]).toBe(
|
|
173
|
+
DdNativeRum.startResource.mock.calls[0][0]
|
|
168
174
|
);
|
|
169
|
-
expect(
|
|
170
|
-
expect(
|
|
171
|
-
expect(
|
|
175
|
+
expect(DdNativeRum.stopResource.mock.calls[0][1]).toBe(0);
|
|
176
|
+
expect(DdNativeRum.stopResource.mock.calls[0][2]).toBe('xhr');
|
|
177
|
+
expect(DdNativeRum.stopResource.mock.calls[0][3]).toBe(-1);
|
|
172
178
|
|
|
173
179
|
expect(xhr.originalOpenCalled).toBe(true);
|
|
174
180
|
expect(xhr.originalSendCalled).toBe(true);
|
|
@@ -439,17 +445,18 @@ describe('XHRPr', () => {
|
|
|
439
445
|
await flushPromises();
|
|
440
446
|
|
|
441
447
|
// THEN
|
|
442
|
-
const spanId =
|
|
448
|
+
const spanId =
|
|
449
|
+
DdNativeRum.startResource.mock.calls[0][3]['_dd.span_id'];
|
|
443
450
|
expect(spanId).toBeDefined();
|
|
444
451
|
expect(spanId).toMatch(/[1-9].+/);
|
|
445
452
|
|
|
446
453
|
const traceId =
|
|
447
|
-
|
|
454
|
+
DdNativeRum.startResource.mock.calls[0][3]['_dd.trace_id'];
|
|
448
455
|
expect(traceId).toBeDefined();
|
|
449
456
|
expect(traceId).toMatch(/[1-9].+/);
|
|
450
457
|
|
|
451
458
|
const rulePsr =
|
|
452
|
-
|
|
459
|
+
DdNativeRum.startResource.mock.calls[0][3]['_dd.rule_psr'];
|
|
453
460
|
expect(rulePsr).toBe(1);
|
|
454
461
|
|
|
455
462
|
// Check traceId and spanId are different
|
|
@@ -477,7 +484,7 @@ describe('XHRPr', () => {
|
|
|
477
484
|
await flushPromises();
|
|
478
485
|
|
|
479
486
|
// THEN
|
|
480
|
-
expect(
|
|
487
|
+
expect(DdNativeRum.startResource).not.toHaveBeenCalledWith(
|
|
481
488
|
expect.anything(),
|
|
482
489
|
expect.anything(),
|
|
483
490
|
expect.anything(),
|
|
@@ -488,7 +495,9 @@ describe('XHRPr', () => {
|
|
|
488
495
|
}),
|
|
489
496
|
expect.anything()
|
|
490
497
|
);
|
|
491
|
-
expect(
|
|
498
|
+
expect(DdNativeRum.startResource.mock.calls[0][3]).toStrictEqual(
|
|
499
|
+
{}
|
|
500
|
+
);
|
|
492
501
|
});
|
|
493
502
|
});
|
|
494
503
|
|
|
@@ -516,7 +525,9 @@ describe('XHRPr', () => {
|
|
|
516
525
|
|
|
517
526
|
// THEN
|
|
518
527
|
const timings =
|
|
519
|
-
|
|
528
|
+
DdNativeRum.stopResource.mock.calls[0][4][
|
|
529
|
+
'_dd.resource_timings'
|
|
530
|
+
];
|
|
520
531
|
|
|
521
532
|
if (Platform.OS === 'ios') {
|
|
522
533
|
expect(timings['firstByte']['startTime']).toBeGreaterThan(0);
|
|
@@ -560,7 +571,9 @@ describe('XHRPr', () => {
|
|
|
560
571
|
|
|
561
572
|
// THEN
|
|
562
573
|
const timings =
|
|
563
|
-
|
|
574
|
+
DdNativeRum.stopResource.mock.calls[0][4][
|
|
575
|
+
'_dd.resource_timings'
|
|
576
|
+
];
|
|
564
577
|
|
|
565
578
|
if (Platform.OS === 'ios') {
|
|
566
579
|
expect(timings['firstByte']['startTime']).toBeGreaterThan(0);
|
|
@@ -600,10 +613,41 @@ describe('XHRPr', () => {
|
|
|
600
613
|
await flushPromises();
|
|
601
614
|
|
|
602
615
|
// THEN
|
|
603
|
-
const attributes =
|
|
616
|
+
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
604
617
|
|
|
605
618
|
expect(attributes['_dd.resource_timings']).toBeNull();
|
|
606
619
|
});
|
|
620
|
+
|
|
621
|
+
it('attaches the XMLHttpRequest object containing response to the event mapper', async () => {
|
|
622
|
+
// GIVEN
|
|
623
|
+
const method = 'GET';
|
|
624
|
+
const url = 'https://api.example.com/v2/user';
|
|
625
|
+
xhrProxy.onTrackingStart({
|
|
626
|
+
tracingSamplingRate: 100,
|
|
627
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
628
|
+
});
|
|
629
|
+
DdRum.registerResourceEventMapper(event => {
|
|
630
|
+
event.context['body'] = JSON.parse(
|
|
631
|
+
event.resourceContext?.response
|
|
632
|
+
);
|
|
633
|
+
return event;
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
// WHEN
|
|
637
|
+
const xhr = new XMLHttpRequestMock();
|
|
638
|
+
xhr.open(method, url);
|
|
639
|
+
xhr.send();
|
|
640
|
+
xhr.abort();
|
|
641
|
+
xhr.complete(200, JSON.stringify({ body: 'content' }));
|
|
642
|
+
await flushPromises();
|
|
643
|
+
|
|
644
|
+
// THEN
|
|
645
|
+
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
646
|
+
|
|
647
|
+
expect(attributes['body']).toEqual({
|
|
648
|
+
body: 'content'
|
|
649
|
+
});
|
|
650
|
+
});
|
|
607
651
|
});
|
|
608
652
|
|
|
609
653
|
describe.each(
|
package/src/rum/types.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The entry point to use Datadog's RUM feature.
|
|
9
|
+
*/
|
|
10
|
+
export type DdRumType = {
|
|
11
|
+
/**
|
|
12
|
+
* Start tracking a RUM View.
|
|
13
|
+
* @param key: The view unique key identifier.
|
|
14
|
+
* @param name: The view name.
|
|
15
|
+
* @param context: The additional context to send.
|
|
16
|
+
* @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
|
|
17
|
+
*/
|
|
18
|
+
startView(
|
|
19
|
+
key: string,
|
|
20
|
+
name: string,
|
|
21
|
+
context?: object,
|
|
22
|
+
timestampMs?: number
|
|
23
|
+
): Promise<void>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Stop tracking a RUM View.
|
|
27
|
+
* @param key: The view unique key identifier.
|
|
28
|
+
* @param context: The additional context to send.
|
|
29
|
+
* @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
30
|
+
*/
|
|
31
|
+
stopView(
|
|
32
|
+
key: string,
|
|
33
|
+
context?: object,
|
|
34
|
+
timestampMs?: number
|
|
35
|
+
): Promise<void>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Start tracking a RUM Action.
|
|
39
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
40
|
+
* @param name: The action name.
|
|
41
|
+
* @param context: The additional context to send.
|
|
42
|
+
* @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
43
|
+
*/
|
|
44
|
+
startAction(
|
|
45
|
+
type: RumActionType,
|
|
46
|
+
name: string,
|
|
47
|
+
context?: object,
|
|
48
|
+
timestampMs?: number
|
|
49
|
+
): Promise<void>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Stop tracking the ongoing RUM Action.
|
|
53
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
54
|
+
* @param name: The action name.
|
|
55
|
+
* @param context: The additional context to send.
|
|
56
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
57
|
+
*/
|
|
58
|
+
stopAction(
|
|
59
|
+
type: RumActionType,
|
|
60
|
+
name: string,
|
|
61
|
+
context?: object,
|
|
62
|
+
timestampMs?: number
|
|
63
|
+
): Promise<void>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Stop tracking the ongoing RUM Action.
|
|
67
|
+
*
|
|
68
|
+
* Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.
|
|
69
|
+
*
|
|
70
|
+
* @deprecated add the `type` and `name` of the action as first two arguments.
|
|
71
|
+
* @param context: The additional context to send.
|
|
72
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
73
|
+
*/
|
|
74
|
+
stopAction(context?: object, timestampMs?: number): Promise<void>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Add a RUM Action.
|
|
78
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
79
|
+
* @param name: The action name.
|
|
80
|
+
* @param context: The additional context to send.
|
|
81
|
+
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
82
|
+
*/
|
|
83
|
+
addAction(
|
|
84
|
+
type: RumActionType,
|
|
85
|
+
name: string,
|
|
86
|
+
context?: object,
|
|
87
|
+
timestampMs?: number
|
|
88
|
+
): Promise<void>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Start tracking a RUM Resource.
|
|
92
|
+
* @param key: The resource unique key identifier.
|
|
93
|
+
* @param method: The resource method (GET, POST, …).
|
|
94
|
+
* @param url: The resource url.
|
|
95
|
+
* @param context: The additional context to send.
|
|
96
|
+
* @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
|
|
97
|
+
*/
|
|
98
|
+
startResource(
|
|
99
|
+
key: string,
|
|
100
|
+
method: string,
|
|
101
|
+
url: string,
|
|
102
|
+
context?: object,
|
|
103
|
+
timestampMs?: number
|
|
104
|
+
): Promise<void>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Stop tracking a RUM Resource.
|
|
108
|
+
* @param key: The resource unique key identifier.
|
|
109
|
+
* @param statusCode: The resource status code.
|
|
110
|
+
* @param kind: The resource's kind (xhr, document, image, css, font, …).
|
|
111
|
+
* @param size: The resource size in bytes. If size is unknown, use -1.
|
|
112
|
+
* @param context: The additional context to send.
|
|
113
|
+
* @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
114
|
+
*/
|
|
115
|
+
stopResource(
|
|
116
|
+
key: string,
|
|
117
|
+
statusCode: number,
|
|
118
|
+
kind: ResourceKind,
|
|
119
|
+
size?: number,
|
|
120
|
+
context?: object,
|
|
121
|
+
timestampMs?: number
|
|
122
|
+
): Promise<void>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Add a RUM Error.
|
|
126
|
+
* @param message: The error message.
|
|
127
|
+
* @param source: The error source (network, source, console, webview, custom).
|
|
128
|
+
* @param stacktrace: The error stacktrace.
|
|
129
|
+
* @param context: The additional context to send.
|
|
130
|
+
* @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
131
|
+
*/
|
|
132
|
+
addError(
|
|
133
|
+
message: string,
|
|
134
|
+
source: ErrorSource,
|
|
135
|
+
stacktrace: string,
|
|
136
|
+
context?: object,
|
|
137
|
+
timestampMs?: number
|
|
138
|
+
): Promise<void>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
|
|
142
|
+
* @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
|
|
143
|
+
*/
|
|
144
|
+
addTiming(name: string): Promise<void>;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Describe the type of a RUM Action.
|
|
149
|
+
*/
|
|
150
|
+
export enum RumActionType {
|
|
151
|
+
/** User tapped on a widget. */
|
|
152
|
+
TAP = 'TAP',
|
|
153
|
+
/** User scrolled a view. */
|
|
154
|
+
SCROLL = 'SCROLL',
|
|
155
|
+
/** User swiped on a view. */
|
|
156
|
+
SWIPE = 'SWIPE',
|
|
157
|
+
/** User pressed hardware back button (Android only). */
|
|
158
|
+
BACK = 'BACK',
|
|
159
|
+
/** A custom action. */
|
|
160
|
+
CUSTOM = 'CUSTOM'
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export type ResourceKind =
|
|
164
|
+
| 'image'
|
|
165
|
+
| 'xhr'
|
|
166
|
+
| 'beacon'
|
|
167
|
+
| 'css'
|
|
168
|
+
| 'document'
|
|
169
|
+
| 'fetch'
|
|
170
|
+
| 'font'
|
|
171
|
+
| 'js'
|
|
172
|
+
| 'media'
|
|
173
|
+
| 'other'
|
|
174
|
+
| 'native';
|
|
175
|
+
|
|
176
|
+
export enum ErrorSource {
|
|
177
|
+
NETWORK = 'NETWORK',
|
|
178
|
+
SOURCE = 'SOURCE',
|
|
179
|
+
CONSOLE = 'CONSOLE',
|
|
180
|
+
WEBVIEW = 'WEBVIEW',
|
|
181
|
+
CUSTOM = 'CUSTOM'
|
|
182
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 type { Attributes } from './types';
|
|
8
|
+
|
|
9
|
+
class AttributesProvider {
|
|
10
|
+
private attributes: Attributes = {};
|
|
11
|
+
|
|
12
|
+
setAttributes = (attributes: Attributes) => {
|
|
13
|
+
this.attributes = {
|
|
14
|
+
...this.attributes,
|
|
15
|
+
...attributes
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
getAttributes = (): Attributes => {
|
|
20
|
+
return this.attributes;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class AttributesSingleton {
|
|
25
|
+
private static attributesProvider = new AttributesProvider();
|
|
26
|
+
|
|
27
|
+
static getInstance = (): AttributesProvider => {
|
|
28
|
+
return AttributesSingleton.attributesProvider;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
static reset = () => {
|
|
32
|
+
AttributesSingleton.attributesProvider = new AttributesProvider();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { AttributesSingleton } from '../AttributesSingleton';
|
|
8
|
+
|
|
9
|
+
describe('AttributesSingleton', () => {
|
|
10
|
+
it('adds, returns and resets the user info', () => {
|
|
11
|
+
// Adding first attributes
|
|
12
|
+
AttributesSingleton.getInstance().setAttributes({
|
|
13
|
+
appType: 'student',
|
|
14
|
+
extraInfo: {
|
|
15
|
+
loggedIn: true
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(AttributesSingleton.getInstance().getAttributes()).toEqual({
|
|
20
|
+
appType: 'student',
|
|
21
|
+
extraInfo: {
|
|
22
|
+
loggedIn: true
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Removing and adding new attributes
|
|
27
|
+
AttributesSingleton.getInstance().setAttributes({
|
|
28
|
+
appType: undefined,
|
|
29
|
+
newAttribute: false
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(AttributesSingleton.getInstance().getAttributes()).toEqual({
|
|
33
|
+
newAttribute: false,
|
|
34
|
+
extraInfo: {
|
|
35
|
+
loggedIn: true
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Resetting attributes
|
|
40
|
+
AttributesSingleton.reset();
|
|
41
|
+
|
|
42
|
+
expect(AttributesSingleton.getInstance().getAttributes()).toEqual({});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export type Attributes = {
|
|
8
|
+
readonly [key: string]: unknown;
|
|
9
|
+
};
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { InternalLog } from '
|
|
8
|
-
import { SdkVerbosity } from '
|
|
9
|
-
import { getErrorStackTrace } from '
|
|
10
|
-
import { DdSdk } from '
|
|
7
|
+
import { InternalLog } from '../../../InternalLog';
|
|
8
|
+
import { SdkVerbosity } from '../../../SdkVerbosity';
|
|
9
|
+
import { getErrorStackTrace } from '../../../errorUtils';
|
|
10
|
+
import { DdSdk } from '../../../foundation';
|
|
11
11
|
|
|
12
12
|
import { DatadogBuffer } from './DatadogBuffer';
|
|
13
13
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { InternalLog } from '
|
|
8
|
-
import { DdSdk } from '
|
|
7
|
+
import { InternalLog } from '../../../../InternalLog';
|
|
8
|
+
import { DdSdk } from '../../../../foundation';
|
|
9
9
|
import { BoundedBuffer } from '../BoundedBuffer';
|
|
10
10
|
|
|
11
11
|
describe('BoundedBuffer', () => {
|
package/src/{DatadogProvider → sdk/DatadogProvider}/Buffer/__tests__/BufferSingleton.test.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -9,14 +9,14 @@ import type { PropsWithChildren } from 'react';
|
|
|
9
9
|
import {
|
|
10
10
|
DatadogProviderConfiguration,
|
|
11
11
|
DdSdkReactNativeConfiguration
|
|
12
|
-
} from '
|
|
12
|
+
} from '../../DdSdkReactNativeConfiguration';
|
|
13
13
|
import type {
|
|
14
14
|
PartialInitializationConfiguration,
|
|
15
15
|
AutoInstrumentationConfiguration
|
|
16
|
-
} from '
|
|
17
|
-
import { DdSdkReactNative } from '
|
|
18
|
-
import { InternalLog } from '
|
|
19
|
-
import { SdkVerbosity } from '
|
|
16
|
+
} from '../../DdSdkReactNativeConfiguration';
|
|
17
|
+
import { DdSdkReactNative } from '../../DdSdkReactNative';
|
|
18
|
+
import { InternalLog } from '../../InternalLog';
|
|
19
|
+
import { SdkVerbosity } from '../../SdkVerbosity';
|
|
20
20
|
|
|
21
21
|
let isInitialized = false;
|
|
22
22
|
|
package/src/{DatadogProvider → sdk/DatadogProvider}/__tests__/__utils__/renderWithProvider.tsx
RENAMED
|
@@ -8,8 +8,8 @@ import { render } from '@testing-library/react-native';
|
|
|
8
8
|
import { Animated, Button, InteractionManager, Text, View } from 'react-native';
|
|
9
9
|
import React, { useState } from 'react';
|
|
10
10
|
|
|
11
|
-
import type { AutoInstrumentationConfiguration } from '
|
|
12
|
-
import { DatadogProviderConfiguration } from '
|
|
11
|
+
import type { AutoInstrumentationConfiguration } from '../../../../DdSdkReactNativeConfiguration';
|
|
12
|
+
import { DatadogProviderConfiguration } from '../../../../DdSdkReactNativeConfiguration';
|
|
13
13
|
import { DatadogProvider } from '../../DatadogProvider';
|
|
14
14
|
|
|
15
15
|
const DefaultTestApp = () => {
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
import { NativeModules } from 'react-native';
|
|
8
8
|
|
|
9
|
-
import { InitializationMode } from '
|
|
10
|
-
import { DdSdkReactNative } from '
|
|
11
|
-
import { TimeProvider } from '
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
9
|
+
import { InitializationMode } from '../../../DdSdkReactNativeConfiguration';
|
|
10
|
+
import { DdSdkReactNative } from '../../../DdSdkReactNative';
|
|
11
|
+
import { TimeProvider } from '../../../TimeProvider';
|
|
12
|
+
import { DdTrace } from '../../../foundation';
|
|
13
|
+
import { DdRum } from '../../../rum/DdRum';
|
|
14
|
+
import { RumActionType } from '../../../rum/types';
|
|
14
15
|
import { BufferSingleton } from '../Buffer/BufferSingleton';
|
|
15
16
|
import {
|
|
16
17
|
DatadogProvider,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
renderWithProvider
|
|
24
25
|
} from './__utils__/renderWithProvider';
|
|
25
26
|
|
|
26
|
-
jest.mock('
|
|
27
|
+
jest.mock('../../../TimeProvider', () => {
|
|
27
28
|
const now = jest.fn();
|
|
28
29
|
return {
|
|
29
30
|
TimeProvider: jest.fn().mockImplementation(() => {
|
|
@@ -60,6 +61,7 @@ describe('DatadogProvider', () => {
|
|
|
60
61
|
DdSdkConfiguration {
|
|
61
62
|
"additionalConfig": Object {
|
|
62
63
|
"_dd.first_party_hosts": Array [],
|
|
64
|
+
"_dd.native_interaction_tracking": false,
|
|
63
65
|
"_dd.native_view_tracking": false,
|
|
64
66
|
"_dd.source": "react-native",
|
|
65
67
|
},
|