@datadog/mobile-react-native 1.2.1 → 1.3.1
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 +2 -2
- package/android/build.gradle +58 -64
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +31 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +242 -14
- 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} +13 -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} +13 -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 +24 -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} +1 -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 +2 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +0 -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 +29 -7
- 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 +3 -2
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +135 -117
- 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} +12 -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 +3 -2
- 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 +3 -2
- package/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.ts +2 -1
- package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +89 -40
- 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 +2 -1
- 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 +13 -10
- package/src/{DatadogProvider → sdk/DatadogProvider}/__tests__/initializationModes.test.tsx +10 -6
- 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
|
@@ -6,14 +6,15 @@
|
|
|
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 { DdRumResourceTracking } from '../DdRumResourceTracking';
|
|
11
11
|
|
|
12
12
|
import { XMLHttpRequestMock } from './__utils__/XMLHttpRequestMock';
|
|
13
13
|
|
|
14
14
|
const DdRum = NativeModules.DdRum;
|
|
15
15
|
|
|
16
|
-
const flushPromises = () =>
|
|
16
|
+
const flushPromises = () =>
|
|
17
|
+
new Promise(jest.requireActual('timers').setImmediate);
|
|
17
18
|
|
|
18
19
|
beforeEach(() => {
|
|
19
20
|
DdRum.startResource.mockClear();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { ResourceKind } from '
|
|
7
|
+
import type { ResourceKind } from '../../../../types';
|
|
8
8
|
import type { DdRumResourceTracingAttributes } from '../distributedTracing';
|
|
9
9
|
|
|
10
10
|
export interface RUMResource {
|
|
@@ -24,4 +24,5 @@ export interface RUMResource {
|
|
|
24
24
|
stopTime: number;
|
|
25
25
|
responseStartTime?: number;
|
|
26
26
|
};
|
|
27
|
+
resourceContext?: XMLHttpRequest;
|
|
27
28
|
}
|
|
@@ -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
|
|
|
@@ -14,7 +14,8 @@ import { ResourceMockFactory } from './__utils__/ResourceMockFactory';
|
|
|
14
14
|
|
|
15
15
|
const resourceMockFactory = new ResourceMockFactory();
|
|
16
16
|
const DdRum = NativeModules.DdRum;
|
|
17
|
-
const flushPromises = () =>
|
|
17
|
+
const flushPromises = () =>
|
|
18
|
+
new Promise(jest.requireActual('timers').setImmediate);
|
|
18
19
|
|
|
19
20
|
beforeEach(() => {
|
|
20
21
|
DdRum.startResource.mockClear();
|
|
@@ -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,18 +33,19 @@ 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);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
const flushPromises = () =>
|
|
42
|
+
const flushPromises = () =>
|
|
43
|
+
new Promise(jest.requireActual('timers').setImmediate);
|
|
42
44
|
let xhrProxy;
|
|
43
45
|
|
|
44
46
|
beforeEach(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
DdNativeRum.startResource.mockClear();
|
|
48
|
+
DdNativeRum.stopResource.mockClear();
|
|
47
49
|
BufferSingleton.onInitialization();
|
|
48
50
|
|
|
49
51
|
xhrProxy = new XHRProxy({
|
|
@@ -66,6 +68,7 @@ afterEach(() => {
|
|
|
66
68
|
xhrProxy.onTrackingStop();
|
|
67
69
|
(Date.now as jest.MockedFunction<typeof Date.now>).mockClear();
|
|
68
70
|
jest.spyOn(global.Math, 'random').mockRestore();
|
|
71
|
+
DdRum.unregisterResourceEventMapper();
|
|
69
72
|
});
|
|
70
73
|
|
|
71
74
|
describe('XHRPr', () => {
|
|
@@ -88,17 +91,19 @@ describe('XHRPr', () => {
|
|
|
88
91
|
await flushPromises();
|
|
89
92
|
|
|
90
93
|
// THEN
|
|
91
|
-
expect(
|
|
92
|
-
expect(
|
|
93
|
-
expect(
|
|
94
|
+
expect(DdNativeRum.startResource.mock.calls.length).toBe(1);
|
|
95
|
+
expect(DdNativeRum.startResource.mock.calls[0][1]).toBe(method);
|
|
96
|
+
expect(DdNativeRum.startResource.mock.calls[0][2]).toBe(url);
|
|
94
97
|
|
|
95
|
-
expect(
|
|
96
|
-
expect(
|
|
97
|
-
|
|
98
|
+
expect(DdNativeRum.stopResource.mock.calls.length).toBe(1);
|
|
99
|
+
expect(DdNativeRum.stopResource.mock.calls[0][0]).toBe(
|
|
100
|
+
DdNativeRum.startResource.mock.calls[0][0]
|
|
101
|
+
);
|
|
102
|
+
expect(DdNativeRum.stopResource.mock.calls[0][1]).toBe(200);
|
|
103
|
+
expect(DdNativeRum.stopResource.mock.calls[0][2]).toBe('xhr');
|
|
104
|
+
expect(DdNativeRum.stopResource.mock.calls[0][3]).toBeGreaterThan(
|
|
105
|
+
0
|
|
98
106
|
);
|
|
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
107
|
|
|
103
108
|
expect(xhr.originalOpenCalled).toBe(true);
|
|
104
109
|
expect(xhr.originalSendCalled).toBe(true);
|
|
@@ -123,17 +128,19 @@ describe('XHRPr', () => {
|
|
|
123
128
|
await flushPromises();
|
|
124
129
|
|
|
125
130
|
// THEN
|
|
126
|
-
expect(
|
|
127
|
-
expect(
|
|
128
|
-
expect(
|
|
131
|
+
expect(DdNativeRum.startResource.mock.calls.length).toBe(1);
|
|
132
|
+
expect(DdNativeRum.startResource.mock.calls[0][1]).toBe(method);
|
|
133
|
+
expect(DdNativeRum.startResource.mock.calls[0][2]).toBe(url);
|
|
129
134
|
|
|
130
|
-
expect(
|
|
131
|
-
expect(
|
|
132
|
-
|
|
135
|
+
expect(DdNativeRum.stopResource.mock.calls.length).toBe(1);
|
|
136
|
+
expect(DdNativeRum.stopResource.mock.calls[0][0]).toBe(
|
|
137
|
+
DdNativeRum.startResource.mock.calls[0][0]
|
|
138
|
+
);
|
|
139
|
+
expect(DdNativeRum.stopResource.mock.calls[0][1]).toBe(500);
|
|
140
|
+
expect(DdNativeRum.stopResource.mock.calls[0][2]).toBe('xhr');
|
|
141
|
+
expect(DdNativeRum.stopResource.mock.calls[0][3]).toBeGreaterThan(
|
|
142
|
+
0
|
|
133
143
|
);
|
|
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
144
|
|
|
138
145
|
expect(xhr.originalOpenCalled).toBe(true);
|
|
139
146
|
expect(xhr.originalSendCalled).toBe(true);
|
|
@@ -158,17 +165,17 @@ describe('XHRPr', () => {
|
|
|
158
165
|
await flushPromises();
|
|
159
166
|
|
|
160
167
|
// THEN
|
|
161
|
-
expect(
|
|
162
|
-
expect(
|
|
163
|
-
expect(
|
|
168
|
+
expect(DdNativeRum.startResource.mock.calls.length).toBe(1);
|
|
169
|
+
expect(DdNativeRum.startResource.mock.calls[0][1]).toBe(method);
|
|
170
|
+
expect(DdNativeRum.startResource.mock.calls[0][2]).toBe(url);
|
|
164
171
|
|
|
165
|
-
expect(
|
|
166
|
-
expect(
|
|
167
|
-
|
|
172
|
+
expect(DdNativeRum.stopResource.mock.calls.length).toBe(1);
|
|
173
|
+
expect(DdNativeRum.stopResource.mock.calls[0][0]).toBe(
|
|
174
|
+
DdNativeRum.startResource.mock.calls[0][0]
|
|
168
175
|
);
|
|
169
|
-
expect(
|
|
170
|
-
expect(
|
|
171
|
-
expect(
|
|
176
|
+
expect(DdNativeRum.stopResource.mock.calls[0][1]).toBe(0);
|
|
177
|
+
expect(DdNativeRum.stopResource.mock.calls[0][2]).toBe('xhr');
|
|
178
|
+
expect(DdNativeRum.stopResource.mock.calls[0][3]).toBe(-1);
|
|
172
179
|
|
|
173
180
|
expect(xhr.originalOpenCalled).toBe(true);
|
|
174
181
|
expect(xhr.originalSendCalled).toBe(true);
|
|
@@ -439,17 +446,18 @@ describe('XHRPr', () => {
|
|
|
439
446
|
await flushPromises();
|
|
440
447
|
|
|
441
448
|
// THEN
|
|
442
|
-
const spanId =
|
|
449
|
+
const spanId =
|
|
450
|
+
DdNativeRum.startResource.mock.calls[0][3]['_dd.span_id'];
|
|
443
451
|
expect(spanId).toBeDefined();
|
|
444
452
|
expect(spanId).toMatch(/[1-9].+/);
|
|
445
453
|
|
|
446
454
|
const traceId =
|
|
447
|
-
|
|
455
|
+
DdNativeRum.startResource.mock.calls[0][3]['_dd.trace_id'];
|
|
448
456
|
expect(traceId).toBeDefined();
|
|
449
457
|
expect(traceId).toMatch(/[1-9].+/);
|
|
450
458
|
|
|
451
459
|
const rulePsr =
|
|
452
|
-
|
|
460
|
+
DdNativeRum.startResource.mock.calls[0][3]['_dd.rule_psr'];
|
|
453
461
|
expect(rulePsr).toBe(1);
|
|
454
462
|
|
|
455
463
|
// Check traceId and spanId are different
|
|
@@ -477,7 +485,7 @@ describe('XHRPr', () => {
|
|
|
477
485
|
await flushPromises();
|
|
478
486
|
|
|
479
487
|
// THEN
|
|
480
|
-
expect(
|
|
488
|
+
expect(DdNativeRum.startResource).not.toHaveBeenCalledWith(
|
|
481
489
|
expect.anything(),
|
|
482
490
|
expect.anything(),
|
|
483
491
|
expect.anything(),
|
|
@@ -488,7 +496,9 @@ describe('XHRPr', () => {
|
|
|
488
496
|
}),
|
|
489
497
|
expect.anything()
|
|
490
498
|
);
|
|
491
|
-
expect(
|
|
499
|
+
expect(DdNativeRum.startResource.mock.calls[0][3]).toStrictEqual(
|
|
500
|
+
{}
|
|
501
|
+
);
|
|
492
502
|
});
|
|
493
503
|
});
|
|
494
504
|
|
|
@@ -510,13 +520,17 @@ describe('XHRPr', () => {
|
|
|
510
520
|
const xhr = new XMLHttpRequestMock();
|
|
511
521
|
xhr.open(method, url);
|
|
512
522
|
xhr.send();
|
|
523
|
+
jest.advanceTimersByTime(50);
|
|
513
524
|
xhr.notifyResponseArrived();
|
|
525
|
+
jest.advanceTimersByTime(50);
|
|
514
526
|
xhr.complete(200, 'ok');
|
|
515
527
|
await flushPromises();
|
|
516
528
|
|
|
517
529
|
// THEN
|
|
518
530
|
const timings =
|
|
519
|
-
|
|
531
|
+
DdNativeRum.stopResource.mock.calls[0][4][
|
|
532
|
+
'_dd.resource_timings'
|
|
533
|
+
];
|
|
520
534
|
|
|
521
535
|
if (Platform.OS === 'ios') {
|
|
522
536
|
expect(timings['firstByte']['startTime']).toBeGreaterThan(0);
|
|
@@ -553,14 +567,18 @@ describe('XHRPr', () => {
|
|
|
553
567
|
const xhr = new XMLHttpRequestMock();
|
|
554
568
|
xhr.open(method, url);
|
|
555
569
|
xhr.send();
|
|
570
|
+
jest.advanceTimersByTime(50);
|
|
556
571
|
xhr.notifyResponseArrived();
|
|
572
|
+
jest.advanceTimersByTime(50);
|
|
557
573
|
xhr.abort();
|
|
558
574
|
xhr.complete(0, undefined);
|
|
559
575
|
await flushPromises();
|
|
560
576
|
|
|
561
577
|
// THEN
|
|
562
578
|
const timings =
|
|
563
|
-
|
|
579
|
+
DdNativeRum.stopResource.mock.calls[0][4][
|
|
580
|
+
'_dd.resource_timings'
|
|
581
|
+
];
|
|
564
582
|
|
|
565
583
|
if (Platform.OS === 'ios') {
|
|
566
584
|
expect(timings['firstByte']['startTime']).toBeGreaterThan(0);
|
|
@@ -600,10 +618,41 @@ describe('XHRPr', () => {
|
|
|
600
618
|
await flushPromises();
|
|
601
619
|
|
|
602
620
|
// THEN
|
|
603
|
-
const attributes =
|
|
621
|
+
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
604
622
|
|
|
605
623
|
expect(attributes['_dd.resource_timings']).toBeNull();
|
|
606
624
|
});
|
|
625
|
+
|
|
626
|
+
it('attaches the XMLHttpRequest object containing response to the event mapper', async () => {
|
|
627
|
+
// GIVEN
|
|
628
|
+
const method = 'GET';
|
|
629
|
+
const url = 'https://api.example.com/v2/user';
|
|
630
|
+
xhrProxy.onTrackingStart({
|
|
631
|
+
tracingSamplingRate: 100,
|
|
632
|
+
firstPartyHostsRegex: firstPartyHostsRegexBuilder([])
|
|
633
|
+
});
|
|
634
|
+
DdRum.registerResourceEventMapper(event => {
|
|
635
|
+
event.context['body'] = JSON.parse(
|
|
636
|
+
event.resourceContext?.response
|
|
637
|
+
);
|
|
638
|
+
return event;
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
// WHEN
|
|
642
|
+
const xhr = new XMLHttpRequestMock();
|
|
643
|
+
xhr.open(method, url);
|
|
644
|
+
xhr.send();
|
|
645
|
+
xhr.abort();
|
|
646
|
+
xhr.complete(200, JSON.stringify({ body: 'content' }));
|
|
647
|
+
await flushPromises();
|
|
648
|
+
|
|
649
|
+
// THEN
|
|
650
|
+
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
651
|
+
|
|
652
|
+
expect(attributes['body']).toEqual({
|
|
653
|
+
body: 'content'
|
|
654
|
+
});
|
|
655
|
+
});
|
|
607
656
|
});
|
|
608
657
|
|
|
609
658
|
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
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { BufferSingleton } from '../BufferSingleton';
|
|
8
8
|
|
|
9
|
-
const flushPromises = () =>
|
|
9
|
+
const flushPromises = () =>
|
|
10
|
+
new Promise<void>(jest.requireActual('timers').setImmediate);
|
|
10
11
|
|
|
11
12
|
describe('BufferSingleton', () => {
|
|
12
13
|
afterEach(() => {
|
|
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
|
|