@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
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
/*
|
|
3
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
4
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
5
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { NativeModules } from 'react-native';
|
|
9
|
+
|
|
10
|
+
import { DdSdk } from '../../foundation';
|
|
11
|
+
import { BufferSingleton } from '../../sdk/DatadogProvider/Buffer/BufferSingleton';
|
|
12
|
+
import { DdRum } from '../DdRum';
|
|
13
|
+
import type { ActionEventMapper } from '../eventMappers/actionEventMapper';
|
|
14
|
+
import type { ErrorEventMapper } from '../eventMappers/errorEventMapper';
|
|
15
|
+
import type { ResourceEventMapper } from '../eventMappers/resourceEventMapper';
|
|
16
|
+
import { ErrorSource, RumActionType } from '../types';
|
|
17
|
+
|
|
18
|
+
jest.mock('../../TimeProvider', () => {
|
|
19
|
+
return {
|
|
20
|
+
TimeProvider: jest.fn().mockImplementation(() => {
|
|
21
|
+
return { now: jest.fn().mockReturnValue(456) };
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('DdRum', () => {
|
|
27
|
+
describe('DdRum.stopAction', () => {
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
jest.clearAllMocks();
|
|
30
|
+
BufferSingleton.onInitialization();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('calls the native SDK when called with new API', async () => {
|
|
34
|
+
await DdRum.stopAction('scroll', 'page', { user: 'me' }, 123);
|
|
35
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
36
|
+
'scroll',
|
|
37
|
+
'page',
|
|
38
|
+
{ user: 'me' },
|
|
39
|
+
123
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('calls the native SDK when called with new API with default values', async () => {
|
|
44
|
+
await DdRum.stopAction('scroll', 'page');
|
|
45
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
46
|
+
'scroll',
|
|
47
|
+
'page',
|
|
48
|
+
{},
|
|
49
|
+
456
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('does not call the native SDK when startAction has not been called before and using old API', async () => {
|
|
54
|
+
await DdRum.stopAction({ user: 'me' }, 789);
|
|
55
|
+
expect(NativeModules.DdRum.stopAction).not.toHaveBeenCalled();
|
|
56
|
+
expect(DdSdk.telemetryDebug).not.toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('calls the native SDK when called with old API', async () => {
|
|
60
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
61
|
+
await DdRum.stopAction({ user: 'me' }, 789);
|
|
62
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
63
|
+
'scroll',
|
|
64
|
+
'page_old_api',
|
|
65
|
+
{ user: 'me' },
|
|
66
|
+
789
|
|
67
|
+
);
|
|
68
|
+
expect(DdSdk.telemetryDebug).toHaveBeenCalledWith(
|
|
69
|
+
'DDdRum.stopAction called with the old signature'
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('calls the native SDK when called with old API with default values', async () => {
|
|
74
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
75
|
+
await DdRum.stopAction();
|
|
76
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
77
|
+
'scroll',
|
|
78
|
+
'page_old_api',
|
|
79
|
+
{},
|
|
80
|
+
456
|
|
81
|
+
);
|
|
82
|
+
expect(DdSdk.telemetryDebug).toHaveBeenCalledWith(
|
|
83
|
+
'DDdRum.stopAction called with the old signature'
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('cleans the action data when stopAction is called', async () => {
|
|
88
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
89
|
+
await DdRum.stopAction();
|
|
90
|
+
await DdRum.stopAction();
|
|
91
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledTimes(1);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('DdRumWrapper', () => {
|
|
96
|
+
beforeEach(() => {
|
|
97
|
+
jest.clearAllMocks();
|
|
98
|
+
BufferSingleton.onInitialization();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('M add error source type W addError()', async () => {
|
|
102
|
+
// Given
|
|
103
|
+
const message = 'Oops I did it again!';
|
|
104
|
+
const source = 'SOURCE';
|
|
105
|
+
const stacktrace = 'doSomething() at ./path/to/file.js:67:3';
|
|
106
|
+
|
|
107
|
+
// When
|
|
108
|
+
DdRum.addError(message, source, stacktrace);
|
|
109
|
+
|
|
110
|
+
// Then
|
|
111
|
+
expect(NativeModules.DdRum.addError.mock.calls.length).toBe(1);
|
|
112
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][0]).toBe(message);
|
|
113
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][1]).toBe(source);
|
|
114
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][2]).toBe(
|
|
115
|
+
stacktrace
|
|
116
|
+
);
|
|
117
|
+
const context = NativeModules.DdRum.addError.mock.calls[0][3];
|
|
118
|
+
expect(context['_dd.error.source_type']).toStrictEqual(
|
|
119
|
+
'react-native'
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('M add error source type W addError() {with custom attributes}', async () => {
|
|
124
|
+
// Given
|
|
125
|
+
const message = 'Oops I did it again!';
|
|
126
|
+
const source = 'SOURCE';
|
|
127
|
+
const stacktrace = 'doSomething() at ./path/to/file.js:67:3';
|
|
128
|
+
const random = Math.random();
|
|
129
|
+
const attributes = {
|
|
130
|
+
foo: 'bar',
|
|
131
|
+
spam: random
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// When
|
|
135
|
+
DdRum.addError(message, source, stacktrace, attributes);
|
|
136
|
+
|
|
137
|
+
// Then
|
|
138
|
+
expect(NativeModules.DdRum.addError.mock.calls.length).toBe(1);
|
|
139
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][0]).toBe(message);
|
|
140
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][1]).toBe(source);
|
|
141
|
+
expect(NativeModules.DdRum.addError.mock.calls[0][2]).toBe(
|
|
142
|
+
stacktrace
|
|
143
|
+
);
|
|
144
|
+
const context = NativeModules.DdRum.addError.mock.calls[0][3];
|
|
145
|
+
expect(context['_dd.error.source_type']).toStrictEqual(
|
|
146
|
+
'react-native'
|
|
147
|
+
);
|
|
148
|
+
expect(context['foo']).toStrictEqual('bar');
|
|
149
|
+
expect(context['spam']).toStrictEqual(random);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('DdRum.addError', () => {
|
|
154
|
+
beforeEach(() => {
|
|
155
|
+
jest.clearAllMocks();
|
|
156
|
+
DdRum.unregisterErrorEventMapper();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('registers event mapper and maps error', async () => {
|
|
160
|
+
const errorEventMapper: ErrorEventMapper = error => {
|
|
161
|
+
error.message = 'New message';
|
|
162
|
+
error.context = {
|
|
163
|
+
isFatal: true
|
|
164
|
+
};
|
|
165
|
+
return error;
|
|
166
|
+
};
|
|
167
|
+
DdRum.registerErrorEventMapper(errorEventMapper);
|
|
168
|
+
|
|
169
|
+
await DdRum.addError('Old message', ErrorSource.CUSTOM, 'stack', {
|
|
170
|
+
isFatal: false
|
|
171
|
+
});
|
|
172
|
+
expect(NativeModules.DdRum.addError).toHaveBeenCalledWith(
|
|
173
|
+
'New message',
|
|
174
|
+
'CUSTOM',
|
|
175
|
+
'stack',
|
|
176
|
+
{
|
|
177
|
+
'_dd.error.source_type': 'react-native',
|
|
178
|
+
isFatal: true
|
|
179
|
+
},
|
|
180
|
+
456
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('drops the event if the mapper returns null', async () => {
|
|
185
|
+
const errorEventMapper: ErrorEventMapper = error => {
|
|
186
|
+
return null;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
DdRum.registerErrorEventMapper(errorEventMapper);
|
|
190
|
+
|
|
191
|
+
await DdRum.addError('Old message', ErrorSource.CUSTOM, 'stack', {
|
|
192
|
+
isFatal: false
|
|
193
|
+
});
|
|
194
|
+
expect(NativeModules.DdRum.addError).not.toHaveBeenCalled();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('DdRum.stopResource', () => {
|
|
199
|
+
beforeEach(() => {
|
|
200
|
+
jest.clearAllMocks();
|
|
201
|
+
DdRum.unregisterResourceEventMapper();
|
|
202
|
+
BufferSingleton.onInitialization();
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('registers event mapper and maps resource', async () => {
|
|
206
|
+
const resourceEventMapper: ResourceEventMapper = resource => {
|
|
207
|
+
resource.context = { retryAttempts: 3 };
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
resource.key = 'bad key';
|
|
210
|
+
// @ts-ignore
|
|
211
|
+
resource.statusCode = 500;
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
resource.kind = 'document';
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
resource.size = 2000;
|
|
216
|
+
return resource;
|
|
217
|
+
};
|
|
218
|
+
DdRum.registerResourceEventMapper(resourceEventMapper);
|
|
219
|
+
|
|
220
|
+
await DdRum.startResource(
|
|
221
|
+
'key',
|
|
222
|
+
'GET',
|
|
223
|
+
'https://my-api.com/',
|
|
224
|
+
{ retry: false },
|
|
225
|
+
234
|
|
226
|
+
);
|
|
227
|
+
await DdRum.stopResource('key', 200, 'xhr', 302, {}, 245);
|
|
228
|
+
expect(NativeModules.DdRum.stopResource).toHaveBeenCalledWith(
|
|
229
|
+
'key',
|
|
230
|
+
200,
|
|
231
|
+
'xhr',
|
|
232
|
+
302,
|
|
233
|
+
{ retryAttempts: 3 },
|
|
234
|
+
245
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('adds the drop context key to the event if the mapper returns null', async () => {
|
|
239
|
+
const resourceEventMapper: ResourceEventMapper = resource => {
|
|
240
|
+
return null;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
DdRum.registerResourceEventMapper(resourceEventMapper);
|
|
244
|
+
|
|
245
|
+
await DdRum.startResource(
|
|
246
|
+
'key',
|
|
247
|
+
'GET',
|
|
248
|
+
'https://my-api.com/',
|
|
249
|
+
{ retry: false },
|
|
250
|
+
234
|
|
251
|
+
);
|
|
252
|
+
await DdRum.stopResource(
|
|
253
|
+
'key',
|
|
254
|
+
200,
|
|
255
|
+
'xhr',
|
|
256
|
+
302,
|
|
257
|
+
{ someLargeUselessObject: {} },
|
|
258
|
+
245
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
expect(NativeModules.DdRum.stopResource).toHaveBeenCalledWith(
|
|
262
|
+
'key',
|
|
263
|
+
200,
|
|
264
|
+
'xhr',
|
|
265
|
+
302,
|
|
266
|
+
{ '_dd.resource.drop_resource': true },
|
|
267
|
+
245
|
|
268
|
+
);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('DdRum.addAction', () => {
|
|
273
|
+
beforeEach(() => {
|
|
274
|
+
jest.clearAllMocks();
|
|
275
|
+
DdRum.unregisterActionEventMapper();
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('registers event mapper and maps action', async () => {
|
|
279
|
+
const actionEventMapper: ActionEventMapper = action => {
|
|
280
|
+
action.context = { frustration: true };
|
|
281
|
+
return action;
|
|
282
|
+
};
|
|
283
|
+
DdRum.registerActionEventMapper(actionEventMapper);
|
|
284
|
+
|
|
285
|
+
await DdRum.addAction(
|
|
286
|
+
RumActionType.CUSTOM,
|
|
287
|
+
'Click on button',
|
|
288
|
+
{},
|
|
289
|
+
123
|
|
290
|
+
);
|
|
291
|
+
expect(NativeModules.DdRum.addAction).toHaveBeenCalledWith(
|
|
292
|
+
'CUSTOM',
|
|
293
|
+
'Click on button',
|
|
294
|
+
{
|
|
295
|
+
frustration: true
|
|
296
|
+
},
|
|
297
|
+
123
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('drops the event if the mapper returns null', async () => {
|
|
302
|
+
const actionEventMapper: ActionEventMapper = action => {
|
|
303
|
+
action.context = { frustration: true };
|
|
304
|
+
return null;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
DdRum.registerActionEventMapper(actionEventMapper);
|
|
308
|
+
|
|
309
|
+
await DdRum.addAction(
|
|
310
|
+
RumActionType.CUSTOM,
|
|
311
|
+
'Click on button',
|
|
312
|
+
{},
|
|
313
|
+
123
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
expect(NativeModules.DdRum.addAction).not.toHaveBeenCalled();
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
describe('DdRum.stopAction', () => {
|
|
321
|
+
beforeEach(() => {
|
|
322
|
+
jest.clearAllMocks();
|
|
323
|
+
DdRum.unregisterActionEventMapper();
|
|
324
|
+
BufferSingleton.onInitialization();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('registers event mapper and maps action', async () => {
|
|
328
|
+
const actionEventMapper: ActionEventMapper = action => {
|
|
329
|
+
action.context = { frustration: true };
|
|
330
|
+
// @ts-ignore
|
|
331
|
+
action.type = 'bad type';
|
|
332
|
+
// @ts-ignore
|
|
333
|
+
action.name = 'bad name';
|
|
334
|
+
return action;
|
|
335
|
+
};
|
|
336
|
+
DdRum.registerActionEventMapper(actionEventMapper);
|
|
337
|
+
|
|
338
|
+
await DdRum.startAction(
|
|
339
|
+
RumActionType.CUSTOM,
|
|
340
|
+
'Click on button',
|
|
341
|
+
{ frustration: false },
|
|
342
|
+
234
|
|
343
|
+
);
|
|
344
|
+
await DdRum.stopAction(
|
|
345
|
+
RumActionType.CUSTOM,
|
|
346
|
+
'Click on button',
|
|
347
|
+
{ frustration: false },
|
|
348
|
+
234
|
|
349
|
+
);
|
|
350
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
351
|
+
'CUSTOM',
|
|
352
|
+
'Click on button',
|
|
353
|
+
{ frustration: true },
|
|
354
|
+
234
|
|
355
|
+
);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('adds the drop context key to the event if the mapper returns null', async () => {
|
|
359
|
+
const actionEventMapper: ActionEventMapper = action => {
|
|
360
|
+
return null;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
DdRum.registerActionEventMapper(actionEventMapper);
|
|
364
|
+
|
|
365
|
+
await DdRum.startAction(
|
|
366
|
+
RumActionType.CUSTOM,
|
|
367
|
+
'Click on button',
|
|
368
|
+
{ frustration: false },
|
|
369
|
+
234
|
|
370
|
+
);
|
|
371
|
+
await DdRum.stopAction(
|
|
372
|
+
RumActionType.CUSTOM,
|
|
373
|
+
'Click on button',
|
|
374
|
+
{ frustration: false },
|
|
375
|
+
234
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
379
|
+
'CUSTOM',
|
|
380
|
+
'Click on button',
|
|
381
|
+
{ '_dd.action.drop_action': true },
|
|
382
|
+
234
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
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 { GestureResponderEvent } from 'react-native';
|
|
8
|
+
|
|
9
|
+
import type { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
|
|
10
|
+
import { EventMapper } from '../../sdk/EventMappers/EventMapper';
|
|
11
|
+
import type { RumActionType } from '../types';
|
|
12
|
+
|
|
13
|
+
type RawAction = {
|
|
14
|
+
readonly type: RumActionType;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
context: object;
|
|
17
|
+
readonly timestampMs: number;
|
|
18
|
+
actionContext?: GestureResponderEvent;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type ActionEvent = RawAction & AdditionalEventDataForMapper;
|
|
22
|
+
|
|
23
|
+
type NativeAction = {
|
|
24
|
+
type: RumActionType;
|
|
25
|
+
name: string;
|
|
26
|
+
context: object;
|
|
27
|
+
timestampMs: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ActionEventMapper = (event: ActionEvent) => ActionEvent | null;
|
|
31
|
+
|
|
32
|
+
export const generateActionEventMapper = (
|
|
33
|
+
eventMapper: ActionEventMapper | undefined
|
|
34
|
+
) =>
|
|
35
|
+
new EventMapper(
|
|
36
|
+
eventMapper,
|
|
37
|
+
formatRawActionToActionEvent,
|
|
38
|
+
formatActionEventToNativeAction,
|
|
39
|
+
formatRawActionToNativeAction
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const formatRawActionToActionEvent = (
|
|
43
|
+
action: RawAction,
|
|
44
|
+
additionalInformation: AdditionalEventDataForMapper
|
|
45
|
+
): ActionEvent => {
|
|
46
|
+
return {
|
|
47
|
+
...action,
|
|
48
|
+
...additionalInformation
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const formatRawActionToNativeAction = (action: RawAction): NativeAction => {
|
|
53
|
+
return action;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const formatActionEventToNativeAction = (
|
|
57
|
+
action: ActionEvent,
|
|
58
|
+
originalEvent: ActionEvent
|
|
59
|
+
): NativeAction => {
|
|
60
|
+
return {
|
|
61
|
+
...action,
|
|
62
|
+
type: originalEvent.type,
|
|
63
|
+
name: originalEvent.name,
|
|
64
|
+
timestampMs: originalEvent.timestampMs
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
|
|
8
|
+
import { EventMapper } from '../../sdk/EventMappers/EventMapper';
|
|
9
|
+
import type { ErrorSource } from '../types';
|
|
10
|
+
|
|
11
|
+
type RawError = {
|
|
12
|
+
message: string;
|
|
13
|
+
source: ErrorSource;
|
|
14
|
+
stacktrace: string;
|
|
15
|
+
context?: object;
|
|
16
|
+
timestampMs?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type ErrorEvent = RawError & AdditionalEventDataForMapper;
|
|
20
|
+
|
|
21
|
+
type NativeError = {
|
|
22
|
+
message: string;
|
|
23
|
+
source: ErrorSource;
|
|
24
|
+
stacktrace: string;
|
|
25
|
+
context?: object;
|
|
26
|
+
timestampMs?: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type ErrorEventMapper = (event: ErrorEvent) => ErrorEvent | null;
|
|
30
|
+
|
|
31
|
+
export const generateErrorEventMapper = (
|
|
32
|
+
eventMapper: ErrorEventMapper | undefined
|
|
33
|
+
) =>
|
|
34
|
+
new EventMapper(
|
|
35
|
+
eventMapper,
|
|
36
|
+
formatRawErrorToErrorEvent,
|
|
37
|
+
formatErrorEventToNativeError,
|
|
38
|
+
formatRawErrorToNativeError
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const formatRawErrorToErrorEvent = (
|
|
42
|
+
error: RawError,
|
|
43
|
+
additionalInformation: AdditionalEventDataForMapper
|
|
44
|
+
): ErrorEvent => {
|
|
45
|
+
return {
|
|
46
|
+
...error,
|
|
47
|
+
...additionalInformation
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const formatRawErrorToNativeError = (error: RawError): NativeError => {
|
|
52
|
+
return error;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const formatErrorEventToNativeError = (error: ErrorEvent): NativeError => {
|
|
56
|
+
return error;
|
|
57
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
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 { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
|
|
8
|
+
import { EventMapper } from '../../sdk/EventMappers/EventMapper';
|
|
9
|
+
import type { ResourceKind } from '../types';
|
|
10
|
+
|
|
11
|
+
type RawResource = {
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly statusCode: number;
|
|
14
|
+
readonly kind: ResourceKind;
|
|
15
|
+
readonly size: number;
|
|
16
|
+
context: object;
|
|
17
|
+
readonly timestampMs: number;
|
|
18
|
+
resourceContext: XMLHttpRequest | undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type ResourceEvent = RawResource & AdditionalEventDataForMapper;
|
|
22
|
+
|
|
23
|
+
type NativeResource = {
|
|
24
|
+
key: string;
|
|
25
|
+
statusCode: number;
|
|
26
|
+
kind: ResourceKind;
|
|
27
|
+
size: number;
|
|
28
|
+
context: object;
|
|
29
|
+
timestampMs: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type ResourceEventMapper = (
|
|
33
|
+
event: ResourceEvent
|
|
34
|
+
) => ResourceEvent | null;
|
|
35
|
+
|
|
36
|
+
export const generateResourceEventMapper = (
|
|
37
|
+
eventMapper: ResourceEventMapper | undefined
|
|
38
|
+
) =>
|
|
39
|
+
new EventMapper(
|
|
40
|
+
eventMapper,
|
|
41
|
+
formatRawResourceToResourceEvent,
|
|
42
|
+
formatResourceEventToNativeResource,
|
|
43
|
+
formatRawResourceToNativeResource
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const formatRawResourceToResourceEvent = (
|
|
47
|
+
error: RawResource,
|
|
48
|
+
additionalInformation: AdditionalEventDataForMapper
|
|
49
|
+
): ResourceEvent => {
|
|
50
|
+
return {
|
|
51
|
+
...error,
|
|
52
|
+
...additionalInformation
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const formatRawResourceToNativeResource = (
|
|
57
|
+
error: RawResource
|
|
58
|
+
): NativeResource => {
|
|
59
|
+
return error;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const formatResourceEventToNativeResource = (
|
|
63
|
+
error: ResourceEvent,
|
|
64
|
+
originalEvent: ResourceEvent
|
|
65
|
+
): NativeResource => {
|
|
66
|
+
return {
|
|
67
|
+
...error,
|
|
68
|
+
key: originalEvent.key,
|
|
69
|
+
statusCode: originalEvent.statusCode,
|
|
70
|
+
kind: originalEvent.kind,
|
|
71
|
+
size: originalEvent.size,
|
|
72
|
+
timestampMs: originalEvent.timestampMs
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
getErrorStackTrace,
|
|
14
14
|
EMPTY_STACK_TRACE
|
|
15
15
|
} from '../../errorUtils';
|
|
16
|
-
import { DdRum } from '
|
|
17
|
-
import { ErrorSource } from '
|
|
16
|
+
import { DdRum } from '../DdRum';
|
|
17
|
+
import { ErrorSource } from '../types';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import {
|
|
7
|
+
import type { GestureResponderEvent } from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { InternalLog } from '../../../InternalLog';
|
|
10
|
+
import { SdkVerbosity } from '../../../SdkVerbosity';
|
|
11
|
+
import { DdRum } from '../../DdRum';
|
|
10
12
|
import { RumActionType } from '../../types';
|
|
11
13
|
|
|
12
14
|
import type EventsInterceptor from './EventsInterceptor';
|
|
@@ -31,7 +33,7 @@ export class DdEventsInterceptor implements EventsInterceptor {
|
|
|
31
33
|
);
|
|
32
34
|
if (timestampDifference > DEBOUNCE_EVENT_THRESHOLD_IN_MS) {
|
|
33
35
|
const targetNode = args[0]._targetInst;
|
|
34
|
-
this.handleTargetEvent(targetNode);
|
|
36
|
+
this.handleTargetEvent(targetNode, args[0]);
|
|
35
37
|
// we add an approximated 1 millisecond for the execution time of the `handleTargetEvent` function
|
|
36
38
|
this.debouncingStartedTimestamp =
|
|
37
39
|
currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;
|
|
@@ -44,10 +46,16 @@ export class DdEventsInterceptor implements EventsInterceptor {
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
private handleTargetEvent(targetNode: any
|
|
49
|
+
private handleTargetEvent(targetNode: any, event: unknown) {
|
|
48
50
|
if (targetNode) {
|
|
49
51
|
const resolvedTargetName = this.resolveTargetName(targetNode);
|
|
50
|
-
DdRum.addAction(
|
|
52
|
+
DdRum.addAction(
|
|
53
|
+
RumActionType.TAP,
|
|
54
|
+
resolvedTargetName,
|
|
55
|
+
{},
|
|
56
|
+
undefined,
|
|
57
|
+
event as GestureResponderEvent
|
|
58
|
+
);
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
|
|
9
|
-
import { InternalLog } from '
|
|
10
|
-
import { SdkVerbosity } from '
|
|
11
|
-
import { getErrorMessage } from '
|
|
12
|
-
import { DdSdk } from '
|
|
9
|
+
import { InternalLog } from '../../../InternalLog';
|
|
10
|
+
import { SdkVerbosity } from '../../../SdkVerbosity';
|
|
11
|
+
import { getErrorMessage } from '../../../errorUtils';
|
|
12
|
+
import { DdSdk } from '../../../foundation';
|
|
13
13
|
|
|
14
14
|
import { DdEventsInterceptor } from './DdEventsInterceptor';
|
|
15
15
|
import type EventsInterceptor from './EventsInterceptor';
|
package/src/rum/instrumentation/{EventsInterceptor.tsx → interactionTracking/EventsInterceptor.tsx}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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 { DdRumResourceTracking } from '../DdRumResourceTracking';
|
|
11
11
|
|
|
12
12
|
import { XMLHttpRequestMock } from './__utils__/XMLHttpRequestMock';
|
|
@@ -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
|
}
|