@datadog/mobile-react-native 1.9.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +8 -2
- package/android/build.gradle +7 -5
- package/android/gradle.properties +4 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -13
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +36 -9
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +1 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +37 -17
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +1 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +3 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +71 -70
- package/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +10 -2
- package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +2 -1
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +1 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +48 -30
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +648 -641
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +122 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +0 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ActionEventForgeryFactory.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +3 -3
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ResourceEventForgeryFactory.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +4 -0
- package/ios/Sources/DdLogsImplementation.swift +10 -38
- package/ios/Sources/DdRumImplementation.swift +26 -39
- package/ios/Sources/DdSdkConfiguration.swift +55 -8
- package/ios/Sources/DdSdkImplementation.swift +141 -143
- package/ios/Sources/DdTraceImplementation.swift +2 -2
- package/ios/Sources/RNDdSdkConfiguration.swift +4 -2
- package/ios/Sources/RUMMonitorInternalProtocol.swift +40 -0
- package/lib/commonjs/DdSdkReactNative.js +2 -2
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +2 -2
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +10 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +19 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js +26 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +30 -10
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +37 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/commonjs/trace/DdTrace.js +2 -2
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/utils/jsUtils.js +26 -0
- package/lib/commonjs/utils/jsUtils.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +1 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/DdRum.js +1 -1
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +8 -3
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +17 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js +13 -0
- package/lib/module/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +30 -10
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +36 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/module/trace/DdTrace.js +1 -1
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/utils/jsUtils.js +17 -0
- package/lib/module/utils/jsUtils.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +6 -0
- package/lib/typescript/utils/jsUtils.d.ts +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +11 -3
- package/src/DdSdkReactNative.tsx +1 -1
- package/src/DdSdkReactNativeConfiguration.tsx +4 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +16 -4
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +2 -0
- package/src/index.tsx +9 -1
- package/src/rum/DdRum.ts +1 -1
- package/src/rum/__tests__/DdRum.test.ts +1 -1
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +13 -4
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +1 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +35 -10
- package/src/rum/instrumentation/resourceTracking/graphql/__tests__/graphqlHeaders.test.ts +28 -0
- package/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.ts +15 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.ts +35 -20
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +48 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +252 -5
- package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.ts +7 -0
- package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +1 -1
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +2 -2
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +8 -3
- package/src/trace/DdTrace.ts +1 -1
- package/src/utils/__mocks__/jsUtils.ts +21 -0
- package/src/utils/jsUtils.ts +20 -0
- package/src/version.ts +1 -1
- /package/lib/commonjs/{TimeProvider.js → utils/TimeProvider.js} +0 -0
- /package/lib/commonjs/{TimeProvider.js.map → utils/TimeProvider.js.map} +0 -0
- /package/lib/commonjs/{Timer.js → utils/Timer.js} +0 -0
- /package/lib/commonjs/{Timer.js.map → utils/Timer.js.map} +0 -0
- /package/lib/commonjs/{errorUtils.js → utils/errorUtils.js} +0 -0
- /package/lib/commonjs/{errorUtils.js.map → utils/errorUtils.js.map} +0 -0
- /package/lib/commonjs/{longTasksUtils.js → utils/longTasksUtils.js} +0 -0
- /package/lib/commonjs/{longTasksUtils.js.map → utils/longTasksUtils.js.map} +0 -0
- /package/lib/module/{TimeProvider.js → utils/TimeProvider.js} +0 -0
- /package/lib/module/{TimeProvider.js.map → utils/TimeProvider.js.map} +0 -0
- /package/lib/module/{Timer.js → utils/Timer.js} +0 -0
- /package/lib/module/{Timer.js.map → utils/Timer.js.map} +0 -0
- /package/lib/module/{errorUtils.js → utils/errorUtils.js} +0 -0
- /package/lib/module/{errorUtils.js.map → utils/errorUtils.js.map} +0 -0
- /package/lib/module/{longTasksUtils.js → utils/longTasksUtils.js} +0 -0
- /package/lib/module/{longTasksUtils.js.map → utils/longTasksUtils.js.map} +0 -0
- /package/lib/typescript/{TimeProvider.d.ts → utils/TimeProvider.d.ts} +0 -0
- /package/lib/typescript/{Timer.d.ts → utils/Timer.d.ts} +0 -0
- /package/lib/typescript/{errorUtils.d.ts → utils/errorUtils.d.ts} +0 -0
- /package/lib/typescript/{longTasksUtils.d.ts → utils/longTasksUtils.d.ts} +0 -0
- /package/src/{TimeProvider.tsx → utils/TimeProvider.tsx} +0 -0
- /package/src/{Timer.ts → utils/Timer.ts} +0 -0
- /package/src/{__tests__ → utils/__tests__}/TimeProvider.test.tsx +0 -0
- /package/src/{__tests__ → utils/__tests__}/Timer.test.ts +0 -0
- /package/src/{__tests__ → utils/__tests__}/errorUtils.test.ts +0 -0
- /package/src/{__tests__ → utils/__tests__}/longTasksUtils.test.ts +0 -0
- /package/src/{errorUtils.ts → utils/errorUtils.ts} +0 -0
- /package/src/{longTasksUtils.ts → utils/longTasksUtils.ts} +0 -0
package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts
CHANGED
|
@@ -24,6 +24,7 @@ export const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
|
|
|
24
24
|
* OTel headers
|
|
25
25
|
*/
|
|
26
26
|
export const TRACECONTEXT_HEADER_KEY = 'traceparent';
|
|
27
|
+
export const TRACESTATE_HEADER_KEY = 'tracestate';
|
|
27
28
|
export const B3_HEADER_KEY = 'b3';
|
|
28
29
|
export const B3_MULTI_TRACE_ID_HEADER_KEY = 'X-B3-TraceId';
|
|
29
30
|
export const B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';
|
|
@@ -60,16 +61,26 @@ export const getTracingHeaders = (
|
|
|
60
61
|
break;
|
|
61
62
|
}
|
|
62
63
|
case PropagatorType.TRACECONTEXT: {
|
|
63
|
-
headers.push(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
headers.push(
|
|
65
|
+
{
|
|
66
|
+
header: TRACECONTEXT_HEADER_KEY,
|
|
67
|
+
value: generateTraceContextHeader({
|
|
68
|
+
version: '00',
|
|
69
|
+
traceId: tracingAttributes.traceId,
|
|
70
|
+
parentId: tracingAttributes.spanId,
|
|
71
|
+
isSampled:
|
|
72
|
+
tracingAttributes.samplingPriorityHeader === '1'
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
header: TRACESTATE_HEADER_KEY,
|
|
77
|
+
value: generateTraceStateHeader({
|
|
78
|
+
parentId: tracingAttributes.spanId,
|
|
79
|
+
isSampled:
|
|
80
|
+
tracingAttributes.samplingPriorityHeader === '1'
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
);
|
|
73
84
|
break;
|
|
74
85
|
}
|
|
75
86
|
case PropagatorType.B3: {
|
|
@@ -124,6 +135,20 @@ const generateTraceContextHeader = ({
|
|
|
124
135
|
)}-${parentId.toPaddedString(16, 16)}-${flags}`;
|
|
125
136
|
};
|
|
126
137
|
|
|
138
|
+
const generateTraceStateHeader = ({
|
|
139
|
+
parentId,
|
|
140
|
+
isSampled
|
|
141
|
+
}: {
|
|
142
|
+
parentId: SpanId;
|
|
143
|
+
isSampled: boolean;
|
|
144
|
+
}) => {
|
|
145
|
+
const sampled = `s:${isSampled ? '1' : '0'}`;
|
|
146
|
+
const origin = 'o:rum';
|
|
147
|
+
const parent = `p:${parentId.toPaddedString(16, 16)}`;
|
|
148
|
+
|
|
149
|
+
return `dd=${sampled};${origin};${parent}`;
|
|
150
|
+
};
|
|
151
|
+
|
|
127
152
|
const generateB3Header = ({
|
|
128
153
|
traceId,
|
|
129
154
|
spanId,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,
|
|
9
|
+
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,
|
|
10
|
+
DATADOG_GRAPH_QL_VARIABLES_HEADER,
|
|
11
|
+
isDatadogCustomHeader
|
|
12
|
+
} from '../graphqlHeaders';
|
|
13
|
+
|
|
14
|
+
describe('GraphQL custom headers', () => {
|
|
15
|
+
it.each([
|
|
16
|
+
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,
|
|
17
|
+
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,
|
|
18
|
+
DATADOG_GRAPH_QL_VARIABLES_HEADER
|
|
19
|
+
])('%s matches the custom header pattern', header => {
|
|
20
|
+
expect(isDatadogCustomHeader(header)).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('isDatadogCustomHeader', () => {
|
|
24
|
+
it('returns false for non-custom headers', () => {
|
|
25
|
+
expect(isDatadogCustomHeader('non-custom-header')).toBeFalsy();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
const DATADOG_CUSTOM_HEADER_PREFIX = '_dd-custom-header';
|
|
8
|
+
|
|
9
|
+
export const DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-name`;
|
|
10
|
+
export const DATADOG_GRAPH_QL_VARIABLES_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-variables`;
|
|
11
|
+
export const DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-type`;
|
|
12
|
+
|
|
13
|
+
export const isDatadogCustomHeader = (header: string) => {
|
|
14
|
+
return header.match(new RegExp(`^${DATADOG_CUSTOM_HEADER_PREFIX}`));
|
|
15
|
+
};
|
|
@@ -34,29 +34,44 @@ export class ResourceReporter {
|
|
|
34
34
|
|
|
35
35
|
const formatResourceStartContext = (
|
|
36
36
|
tracingAttributes: RUMResource['tracingAttributes']
|
|
37
|
-
): Record<string, string | number>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
): Record<string, string | number> => {
|
|
38
|
+
const attributes: Record<string, string | number> = {};
|
|
39
|
+
if (tracingAttributes.samplingPriorityHeader !== '0') {
|
|
40
|
+
attributes['_dd.span_id'] = tracingAttributes.spanId.toString(10);
|
|
41
|
+
attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(10);
|
|
42
|
+
attributes['_dd.rule_psr'] = tracingAttributes.rulePsr;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return attributes;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
const formatResourceStopContext = (
|
|
48
|
-
timings: RUMResource['timings']
|
|
49
|
+
timings: RUMResource['timings'],
|
|
50
|
+
graphqlAttributes: RUMResource['graphqlAttributes']
|
|
49
51
|
): Record<string, unknown> => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
const attributes: Record<string, unknown> = {};
|
|
53
|
+
|
|
54
|
+
if (timings.responseStartTime !== undefined) {
|
|
55
|
+
attributes['_dd.resource_timings'] = createTimings(
|
|
56
|
+
timings.startTime,
|
|
57
|
+
timings.responseStartTime,
|
|
58
|
+
timings.stopTime
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (graphqlAttributes?.operationType) {
|
|
63
|
+
attributes['_dd.graphql.operation_type'] =
|
|
64
|
+
graphqlAttributes.operationType;
|
|
65
|
+
if (graphqlAttributes.operationName) {
|
|
66
|
+
attributes['_dd.graphql.operation_name'] =
|
|
67
|
+
graphqlAttributes.operationName;
|
|
68
|
+
}
|
|
69
|
+
if (graphqlAttributes.variables) {
|
|
70
|
+
attributes['_dd.graphql.variables'] = graphqlAttributes.variables;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return attributes;
|
|
60
75
|
};
|
|
61
76
|
|
|
62
77
|
const reportResource = async (resource: RUMResource) => {
|
|
@@ -73,7 +88,7 @@ const reportResource = async (resource: RUMResource) => {
|
|
|
73
88
|
resource.response.statusCode,
|
|
74
89
|
resource.request.kind,
|
|
75
90
|
resource.response.size,
|
|
76
|
-
formatResourceStopContext(resource.timings),
|
|
91
|
+
formatResourceStopContext(resource.timings, resource.graphqlAttributes),
|
|
77
92
|
resource.timings.stopTime,
|
|
78
93
|
resource.resourceContext
|
|
79
94
|
);
|
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import Timer from '../../../../../Timer';
|
|
7
|
+
import Timer from '../../../../../utils/Timer';
|
|
8
8
|
import { getTracingHeaders } from '../../distributedTracing/distributedTracingHeaders';
|
|
9
9
|
import type { DdRumResourceTracingAttributes } from '../../distributedTracing/distributedTracing';
|
|
10
10
|
import { getTracingAttributes } from '../../distributedTracing/distributedTracing';
|
|
11
|
+
import {
|
|
12
|
+
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,
|
|
13
|
+
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,
|
|
14
|
+
DATADOG_GRAPH_QL_VARIABLES_HEADER,
|
|
15
|
+
isDatadogCustomHeader
|
|
16
|
+
} from '../../graphql/graphqlHeaders';
|
|
11
17
|
import type { RequestProxyOptions } from '../interfaces/RequestProxy';
|
|
12
18
|
import { RequestProxy } from '../interfaces/RequestProxy';
|
|
13
19
|
|
|
@@ -22,6 +28,11 @@ interface DdRumXhr extends XMLHttpRequest {
|
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
interface DdRumXhrContext {
|
|
31
|
+
graphql: {
|
|
32
|
+
operationType?: string;
|
|
33
|
+
operationName?: string;
|
|
34
|
+
variables?: string;
|
|
35
|
+
};
|
|
25
36
|
method: string;
|
|
26
37
|
url: string;
|
|
27
38
|
reported: boolean;
|
|
@@ -41,6 +52,7 @@ export class XHRProxy extends RequestProxy {
|
|
|
41
52
|
private providers: XHRProxyProviders;
|
|
42
53
|
private static originalXhrOpen: typeof XMLHttpRequest.prototype.open;
|
|
43
54
|
private static originalXhrSend: typeof XMLHttpRequest.prototype.send;
|
|
55
|
+
private static originalXhrSetRequestHeader: typeof XMLHttpRequest.prototype.setRequestHeader;
|
|
44
56
|
|
|
45
57
|
constructor(providers: XHRProxyProviders) {
|
|
46
58
|
super();
|
|
@@ -50,12 +62,15 @@ export class XHRProxy extends RequestProxy {
|
|
|
50
62
|
onTrackingStart = (context: RequestProxyOptions) => {
|
|
51
63
|
XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;
|
|
52
64
|
XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;
|
|
65
|
+
XHRProxy.originalXhrSetRequestHeader = this.providers.xhrType.prototype.setRequestHeader;
|
|
53
66
|
proxyRequests(this.providers, context);
|
|
54
67
|
};
|
|
55
68
|
|
|
56
69
|
onTrackingStop = () => {
|
|
57
70
|
this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;
|
|
58
71
|
this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;
|
|
72
|
+
this.providers.xhrType.prototype.setRequestHeader =
|
|
73
|
+
XHRProxy.originalXhrSetRequestHeader;
|
|
59
74
|
};
|
|
60
75
|
}
|
|
61
76
|
|
|
@@ -65,6 +80,7 @@ const proxyRequests = (
|
|
|
65
80
|
): void => {
|
|
66
81
|
proxyOpen(providers, context);
|
|
67
82
|
proxySend(providers);
|
|
83
|
+
proxySetRequestHeader(providers);
|
|
68
84
|
};
|
|
69
85
|
|
|
70
86
|
const proxyOpen = (
|
|
@@ -88,6 +104,7 @@ const proxyOpen = (
|
|
|
88
104
|
url,
|
|
89
105
|
reported: false,
|
|
90
106
|
timer: new Timer(),
|
|
107
|
+
graphql: {},
|
|
91
108
|
tracingAttributes: getTracingAttributes({
|
|
92
109
|
hostname,
|
|
93
110
|
firstPartyHostsRegexMap,
|
|
@@ -166,6 +183,7 @@ const reportXhr = async (
|
|
|
166
183
|
url: context.url,
|
|
167
184
|
kind: 'xhr'
|
|
168
185
|
},
|
|
186
|
+
graphqlAttributes: context.graphql,
|
|
169
187
|
tracingAttributes: context.tracingAttributes,
|
|
170
188
|
response: {
|
|
171
189
|
statusCode: xhrProxy.status,
|
|
@@ -181,3 +199,32 @@ const reportXhr = async (
|
|
|
181
199
|
resourceContext: xhrProxy
|
|
182
200
|
});
|
|
183
201
|
};
|
|
202
|
+
|
|
203
|
+
const proxySetRequestHeader = (providers: XHRProxyProviders): void => {
|
|
204
|
+
const xhrType = providers.xhrType;
|
|
205
|
+
const originalXhrSetRequestHeader = xhrType.prototype.setRequestHeader;
|
|
206
|
+
|
|
207
|
+
xhrType.prototype.setRequestHeader = function (
|
|
208
|
+
this: DdRumXhr,
|
|
209
|
+
header: string,
|
|
210
|
+
value: string
|
|
211
|
+
) {
|
|
212
|
+
if (isDatadogCustomHeader(header)) {
|
|
213
|
+
if (header === DATADOG_GRAPH_QL_OPERATION_NAME_HEADER) {
|
|
214
|
+
this._datadog_xhr.graphql.operationName = value;
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (header === DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER) {
|
|
218
|
+
this._datadog_xhr.graphql.operationType = value;
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (header === DATADOG_GRAPH_QL_VARIABLES_HEADER) {
|
|
222
|
+
this._datadog_xhr.graphql.variables = value;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// eslint-disable-next-line prefer-rest-params
|
|
228
|
+
return originalXhrSetRequestHeader.apply(this, arguments as any);
|
|
229
|
+
};
|
|
230
|
+
};
|
package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts
CHANGED
|
@@ -22,9 +22,15 @@ import {
|
|
|
22
22
|
B3_MULTI_SPAN_ID_HEADER_KEY,
|
|
23
23
|
B3_MULTI_SAMPLED_HEADER_KEY,
|
|
24
24
|
ORIGIN_RUM,
|
|
25
|
-
ORIGIN_HEADER_KEY
|
|
25
|
+
ORIGIN_HEADER_KEY,
|
|
26
|
+
TRACESTATE_HEADER_KEY
|
|
26
27
|
} from '../../../distributedTracing/distributedTracingHeaders';
|
|
27
28
|
import { firstPartyHostsRegexMapBuilder } from '../../../distributedTracing/firstPartyHosts';
|
|
29
|
+
import {
|
|
30
|
+
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,
|
|
31
|
+
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,
|
|
32
|
+
DATADOG_GRAPH_QL_VARIABLES_HEADER
|
|
33
|
+
} from '../../../graphql/graphqlHeaders';
|
|
28
34
|
import { ResourceReporter } from '../DatadogRumResource/ResourceReporter';
|
|
29
35
|
import { XHRProxy } from '../XHRProxy';
|
|
30
36
|
import {
|
|
@@ -49,6 +55,10 @@ const flushPromises = () =>
|
|
|
49
55
|
new Promise(jest.requireActual('timers').setImmediate);
|
|
50
56
|
let xhrProxy;
|
|
51
57
|
|
|
58
|
+
const hexToDecimal = (hex: string): string => {
|
|
59
|
+
return BigInt(`0x${hex}`).toString(10);
|
|
60
|
+
};
|
|
61
|
+
|
|
52
62
|
beforeEach(() => {
|
|
53
63
|
DdNativeRum.startResource.mockClear();
|
|
54
64
|
DdNativeRum.stopResource.mockClear();
|
|
@@ -77,7 +87,7 @@ afterEach(() => {
|
|
|
77
87
|
DdRum.unregisterResourceEventMapper();
|
|
78
88
|
});
|
|
79
89
|
|
|
80
|
-
describe('
|
|
90
|
+
describe('XHRProxy', () => {
|
|
81
91
|
describe('resource interception', () => {
|
|
82
92
|
it('intercepts XHR request when startTracking() + XHR.open() + XHR.send()', async () => {
|
|
83
93
|
// GIVEN
|
|
@@ -439,8 +449,74 @@ describe('XHRPr', () => {
|
|
|
439
449
|
await flushPromises();
|
|
440
450
|
|
|
441
451
|
// THEN
|
|
442
|
-
const
|
|
443
|
-
expect(
|
|
452
|
+
const contextHeader = xhr.requestHeaders[TRACECONTEXT_HEADER_KEY];
|
|
453
|
+
expect(contextHeader).toMatch(/^00-[0-9a-f]{32}-[0-9a-f]{16}-01$/);
|
|
454
|
+
|
|
455
|
+
// Parent value of the context header is the 3rd part of it
|
|
456
|
+
const parentValue = contextHeader.split('-')[2];
|
|
457
|
+
const stateHeader = xhr.requestHeaders[TRACESTATE_HEADER_KEY];
|
|
458
|
+
expect(stateHeader).toBe(`dd=s:1;o:rum;p:${parentValue}`);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it('adds tracing headers with matching value when all headers are added', async () => {
|
|
462
|
+
// GIVEN
|
|
463
|
+
const method = 'GET';
|
|
464
|
+
const url = 'https://api.example.com:443/v2/user';
|
|
465
|
+
xhrProxy.onTrackingStart({
|
|
466
|
+
tracingSamplingRate: 100,
|
|
467
|
+
firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder([
|
|
468
|
+
{
|
|
469
|
+
match: 'example.com',
|
|
470
|
+
propagatorTypes: [PropagatorType.DATADOG]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
match: 'example.com',
|
|
474
|
+
propagatorTypes: [PropagatorType.TRACECONTEXT]
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
match: 'example.com',
|
|
478
|
+
propagatorTypes: [PropagatorType.B3]
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
match: 'example.com',
|
|
482
|
+
propagatorTypes: [PropagatorType.B3MULTI]
|
|
483
|
+
}
|
|
484
|
+
])
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
// WHEN
|
|
488
|
+
const xhr = new XMLHttpRequestMock();
|
|
489
|
+
xhr.open(method, url);
|
|
490
|
+
xhr.send();
|
|
491
|
+
xhr.notifyResponseArrived();
|
|
492
|
+
xhr.complete(200, 'ok');
|
|
493
|
+
await flushPromises();
|
|
494
|
+
|
|
495
|
+
// THEN
|
|
496
|
+
const datadogTraceValue = xhr.requestHeaders[TRACE_ID_HEADER_KEY];
|
|
497
|
+
const datadogParentValue = xhr.requestHeaders[PARENT_ID_HEADER_KEY];
|
|
498
|
+
|
|
499
|
+
const contextHeader = xhr.requestHeaders[TRACECONTEXT_HEADER_KEY];
|
|
500
|
+
const traceContextValue = contextHeader.split('-')[1];
|
|
501
|
+
const parentContextValue = contextHeader.split('-')[2];
|
|
502
|
+
|
|
503
|
+
const b3MultiTraceHeader =
|
|
504
|
+
xhr.requestHeaders[B3_MULTI_TRACE_ID_HEADER_KEY];
|
|
505
|
+
const b3MultiParentHeader =
|
|
506
|
+
xhr.requestHeaders[B3_MULTI_SPAN_ID_HEADER_KEY];
|
|
507
|
+
|
|
508
|
+
const b3Header = xhr.requestHeaders[B3_HEADER_KEY];
|
|
509
|
+
const traceB3Value = b3Header.split('-')[0];
|
|
510
|
+
const parentB3Value = b3Header.split('-')[1];
|
|
511
|
+
|
|
512
|
+
expect(hexToDecimal(traceContextValue)).toBe(datadogTraceValue);
|
|
513
|
+
expect(hexToDecimal(parentContextValue)).toBe(datadogParentValue);
|
|
514
|
+
|
|
515
|
+
expect(hexToDecimal(b3MultiTraceHeader)).toBe(datadogTraceValue);
|
|
516
|
+
expect(hexToDecimal(b3MultiParentHeader)).toBe(datadogParentValue);
|
|
517
|
+
|
|
518
|
+
expect(hexToDecimal(traceB3Value)).toBe(datadogTraceValue);
|
|
519
|
+
expect(hexToDecimal(parentB3Value)).toBe(datadogParentValue);
|
|
444
520
|
});
|
|
445
521
|
|
|
446
522
|
it('adds tracecontext request headers when the host is instrumented with tracecontext and request is sampled', async () => {
|
|
@@ -798,7 +874,7 @@ describe('XHRPr', () => {
|
|
|
798
874
|
// THEN
|
|
799
875
|
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
800
876
|
|
|
801
|
-
expect(attributes['_dd.resource_timings']).
|
|
877
|
+
expect(attributes['_dd.resource_timings']).toBeUndefined();
|
|
802
878
|
});
|
|
803
879
|
|
|
804
880
|
it('attaches the XMLHttpRequest object containing response to the event mapper', async () => {
|
|
@@ -1045,4 +1121,175 @@ describe('XHRPr', () => {
|
|
|
1045
1121
|
expect(size).toEqual(-1);
|
|
1046
1122
|
});
|
|
1047
1123
|
});
|
|
1124
|
+
|
|
1125
|
+
describe('setRequestHeader', () => {
|
|
1126
|
+
it('sets graphql attributes and drops corresponding headers', async () => {
|
|
1127
|
+
// GIVEN
|
|
1128
|
+
const method = 'POST';
|
|
1129
|
+
const url = 'https://api.example.com/graphql';
|
|
1130
|
+
xhrProxy.onTrackingStart({
|
|
1131
|
+
tracingSamplingRate: 100,
|
|
1132
|
+
firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder([])
|
|
1133
|
+
});
|
|
1134
|
+
|
|
1135
|
+
// WHEN
|
|
1136
|
+
const xhr = new XMLHttpRequestMock();
|
|
1137
|
+
xhr.open(method, url);
|
|
1138
|
+
xhr.setRequestHeader(
|
|
1139
|
+
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,
|
|
1140
|
+
'query'
|
|
1141
|
+
);
|
|
1142
|
+
xhr.setRequestHeader(
|
|
1143
|
+
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,
|
|
1144
|
+
'cats'
|
|
1145
|
+
);
|
|
1146
|
+
xhr.setRequestHeader(DATADOG_GRAPH_QL_VARIABLES_HEADER, '{}');
|
|
1147
|
+
xhr.send();
|
|
1148
|
+
xhr.abort();
|
|
1149
|
+
xhr.complete(0, undefined);
|
|
1150
|
+
await flushPromises();
|
|
1151
|
+
|
|
1152
|
+
// THEN
|
|
1153
|
+
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
1154
|
+
expect(attributes['_dd.graphql.operation_type']).toEqual('query');
|
|
1155
|
+
expect(attributes['_dd.graphql.operation_name']).toEqual('cats');
|
|
1156
|
+
expect(attributes['_dd.graphql.variables']).toEqual('{}');
|
|
1157
|
+
|
|
1158
|
+
expect(
|
|
1159
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER]
|
|
1160
|
+
).not.toBeDefined();
|
|
1161
|
+
expect(
|
|
1162
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_OPERATION_NAME_HEADER]
|
|
1163
|
+
).not.toBeDefined();
|
|
1164
|
+
expect(
|
|
1165
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_VARIABLES_HEADER]
|
|
1166
|
+
).not.toBeDefined();
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
it('sets graphql attributes and drops corresponding headers when operation name and variables are missing', async () => {
|
|
1170
|
+
// GIVEN
|
|
1171
|
+
const method = 'POST';
|
|
1172
|
+
const url = 'https://api.example.com/graphql';
|
|
1173
|
+
xhrProxy.onTrackingStart({
|
|
1174
|
+
tracingSamplingRate: 100,
|
|
1175
|
+
firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder([])
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
// WHEN
|
|
1179
|
+
const xhr = new XMLHttpRequestMock();
|
|
1180
|
+
xhr.open(method, url);
|
|
1181
|
+
xhr.setRequestHeader(
|
|
1182
|
+
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,
|
|
1183
|
+
'query'
|
|
1184
|
+
);
|
|
1185
|
+
xhr.send();
|
|
1186
|
+
xhr.abort();
|
|
1187
|
+
xhr.complete(0, undefined);
|
|
1188
|
+
await flushPromises();
|
|
1189
|
+
|
|
1190
|
+
// THEN
|
|
1191
|
+
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
1192
|
+
expect(attributes['_dd.graphql.operation_type']).toEqual('query');
|
|
1193
|
+
expect(attributes['_dd.graphql.operation_name']).not.toBeDefined();
|
|
1194
|
+
expect(attributes['_dd.graphql.variables']).not.toBeDefined();
|
|
1195
|
+
|
|
1196
|
+
expect(
|
|
1197
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER]
|
|
1198
|
+
).not.toBeDefined();
|
|
1199
|
+
expect(
|
|
1200
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_OPERATION_NAME_HEADER]
|
|
1201
|
+
).not.toBeDefined();
|
|
1202
|
+
expect(
|
|
1203
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_VARIABLES_HEADER]
|
|
1204
|
+
).not.toBeDefined();
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
it('does not set graphql attributes but drops corresponding headers when operation type is missing', async () => {
|
|
1208
|
+
// GIVEN
|
|
1209
|
+
const method = 'POST';
|
|
1210
|
+
const url = 'https://api.example.com/graphql';
|
|
1211
|
+
xhrProxy.onTrackingStart({
|
|
1212
|
+
tracingSamplingRate: 100,
|
|
1213
|
+
firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder([])
|
|
1214
|
+
});
|
|
1215
|
+
|
|
1216
|
+
// WHEN
|
|
1217
|
+
const xhr = new XMLHttpRequestMock();
|
|
1218
|
+
xhr.open(method, url);
|
|
1219
|
+
xhr.setRequestHeader(
|
|
1220
|
+
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,
|
|
1221
|
+
'cats'
|
|
1222
|
+
);
|
|
1223
|
+
xhr.setRequestHeader(DATADOG_GRAPH_QL_VARIABLES_HEADER, '{}');
|
|
1224
|
+
xhr.send();
|
|
1225
|
+
xhr.abort();
|
|
1226
|
+
xhr.complete(0, undefined);
|
|
1227
|
+
await flushPromises();
|
|
1228
|
+
|
|
1229
|
+
// THEN
|
|
1230
|
+
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
1231
|
+
expect(attributes['_dd.graphql.operation_type']).not.toBeDefined();
|
|
1232
|
+
expect(attributes['_dd.graphql.operation_name']).not.toBeDefined();
|
|
1233
|
+
expect(attributes['_dd.graphql.variables']).not.toBeDefined();
|
|
1234
|
+
|
|
1235
|
+
expect(
|
|
1236
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER]
|
|
1237
|
+
).not.toBeDefined();
|
|
1238
|
+
expect(
|
|
1239
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_OPERATION_NAME_HEADER]
|
|
1240
|
+
).not.toBeDefined();
|
|
1241
|
+
expect(
|
|
1242
|
+
xhr.requestHeaders[DATADOG_GRAPH_QL_VARIABLES_HEADER]
|
|
1243
|
+
).not.toBeDefined();
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
it('enables mapper to edit graphql variables to remove sensitive information', async () => {
|
|
1247
|
+
// GIVEN
|
|
1248
|
+
const method = 'POST';
|
|
1249
|
+
const url = 'https://api.example.com/graphql';
|
|
1250
|
+
xhrProxy.onTrackingStart({
|
|
1251
|
+
tracingSamplingRate: 100,
|
|
1252
|
+
firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder([])
|
|
1253
|
+
});
|
|
1254
|
+
DdRum.registerResourceEventMapper(event => {
|
|
1255
|
+
if (event.context['_dd.graphql.variables']) {
|
|
1256
|
+
const variables = JSON.parse(
|
|
1257
|
+
event.context['_dd.graphql.variables']
|
|
1258
|
+
);
|
|
1259
|
+
if (variables.password) {
|
|
1260
|
+
variables.password = '***';
|
|
1261
|
+
}
|
|
1262
|
+
event.context['_dd.graphql.variables'] = JSON.stringify(
|
|
1263
|
+
variables
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
return event;
|
|
1268
|
+
});
|
|
1269
|
+
|
|
1270
|
+
// WHEN
|
|
1271
|
+
const xhr = new XMLHttpRequestMock();
|
|
1272
|
+
xhr.open(method, url);
|
|
1273
|
+
xhr.setRequestHeader(
|
|
1274
|
+
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,
|
|
1275
|
+
'query'
|
|
1276
|
+
);
|
|
1277
|
+
xhr.setRequestHeader(
|
|
1278
|
+
DATADOG_GRAPH_QL_VARIABLES_HEADER,
|
|
1279
|
+
JSON.stringify({ password: 'SECRET' })
|
|
1280
|
+
);
|
|
1281
|
+
xhr.send();
|
|
1282
|
+
xhr.abort();
|
|
1283
|
+
xhr.complete(0, undefined);
|
|
1284
|
+
await flushPromises();
|
|
1285
|
+
|
|
1286
|
+
// THEN
|
|
1287
|
+
const attributes = DdNativeRum.stopResource.mock.calls[0][4];
|
|
1288
|
+
expect(attributes['_dd.graphql.operation_type']).toBe('query');
|
|
1289
|
+
expect(attributes['_dd.graphql.operation_name']).not.toBeDefined();
|
|
1290
|
+
expect(attributes['_dd.graphql.variables']).toBe(
|
|
1291
|
+
'{"password":"***"}'
|
|
1292
|
+
);
|
|
1293
|
+
});
|
|
1294
|
+
});
|
|
1048
1295
|
});
|
|
@@ -15,6 +15,7 @@ export interface RUMResource {
|
|
|
15
15
|
kind: ResourceKind;
|
|
16
16
|
};
|
|
17
17
|
tracingAttributes: DdRumResourceTracingAttributes;
|
|
18
|
+
graphqlAttributes?: DdRumResourceGraphqlAttributes;
|
|
18
19
|
response: {
|
|
19
20
|
statusCode: number;
|
|
20
21
|
size: number;
|
|
@@ -26,3 +27,9 @@ export interface RUMResource {
|
|
|
26
27
|
};
|
|
27
28
|
resourceContext?: XMLHttpRequest;
|
|
28
29
|
}
|
|
30
|
+
|
|
31
|
+
export type DdRumResourceGraphqlAttributes = {
|
|
32
|
+
operationType?: string;
|
|
33
|
+
operationName?: string;
|
|
34
|
+
variables?: string;
|
|
35
|
+
};
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { InternalLog } from '../../../InternalLog';
|
|
8
8
|
import { SdkVerbosity } from '../../../SdkVerbosity';
|
|
9
|
-
import { getErrorStackTrace } from '../../../errorUtils';
|
|
10
9
|
import { DdSdk } from '../../../sdk/DdSdk';
|
|
10
|
+
import { getErrorStackTrace } from '../../../utils/errorUtils';
|
|
11
11
|
|
|
12
12
|
import { DatadogBuffer } from './DatadogBuffer';
|
|
13
13
|
|
|
@@ -8,10 +8,10 @@ import { NativeModules } from 'react-native';
|
|
|
8
8
|
|
|
9
9
|
import { InitializationMode } from '../../../DdSdkReactNativeConfiguration';
|
|
10
10
|
import { DdSdkReactNative } from '../../../DdSdkReactNative';
|
|
11
|
-
import { TimeProvider } from '../../../TimeProvider';
|
|
12
11
|
import { DdRum } from '../../../rum/DdRum';
|
|
13
12
|
import { RumActionType } from '../../../rum/types';
|
|
14
13
|
import { DdTrace } from '../../../trace/DdTrace';
|
|
14
|
+
import { TimeProvider } from '../../../utils/TimeProvider';
|
|
15
15
|
import { BufferSingleton } from '../Buffer/BufferSingleton';
|
|
16
16
|
import {
|
|
17
17
|
DatadogProvider,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
renderWithProvider
|
|
25
25
|
} from './__utils__/renderWithProvider';
|
|
26
26
|
|
|
27
|
-
jest.mock('../../../TimeProvider', () => {
|
|
27
|
+
jest.mock('../../../utils/TimeProvider', () => {
|
|
28
28
|
const now = jest.fn();
|
|
29
29
|
return {
|
|
30
30
|
TimeProvider: jest.fn().mockImplementation(() => {
|
|
@@ -9,9 +9,9 @@ import { NativeModules } from 'react-native';
|
|
|
9
9
|
|
|
10
10
|
import { InitializationMode } from '../../../DdSdkReactNativeConfiguration';
|
|
11
11
|
import { DdSdkReactNative } from '../../../DdSdkReactNative';
|
|
12
|
-
import { TimeProvider } from '../../../TimeProvider';
|
|
13
12
|
import { DdRumUserInteractionTracking } from '../../../rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';
|
|
14
13
|
import { XMLHttpRequestMock } from '../../../rum/instrumentation/resourceTracking/__tests__/__utils__/XMLHttpRequestMock';
|
|
14
|
+
import { TimeProvider } from '../../../utils/TimeProvider';
|
|
15
15
|
import { BufferSingleton } from '../Buffer/BufferSingleton';
|
|
16
16
|
import {
|
|
17
17
|
DatadogProvider,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
renderWithProviderAndAnimation
|
|
26
26
|
} from './__utils__/renderWithProvider';
|
|
27
27
|
|
|
28
|
-
jest.mock('../../../TimeProvider', () => {
|
|
28
|
+
jest.mock('../../../utils/TimeProvider', () => {
|
|
29
29
|
const now = jest.fn();
|
|
30
30
|
return {
|
|
31
31
|
TimeProvider: jest.fn().mockImplementation(() => {
|
|
@@ -171,7 +171,12 @@ describe('DatadogProvider', () => {
|
|
|
171
171
|
expect(
|
|
172
172
|
NativeModules.DdSdk.initialize.mock.calls[0][0]
|
|
173
173
|
.additionalConfig['_dd.first_party_hosts']
|
|
174
|
-
).toEqual([
|
|
174
|
+
).toEqual([
|
|
175
|
+
{
|
|
176
|
+
match: 'api.com',
|
|
177
|
+
propagatorTypes: ['datadog', 'tracecontext']
|
|
178
|
+
}
|
|
179
|
+
]);
|
|
175
180
|
expect(NativeModules.DdRum.addAction).toHaveBeenCalledTimes(1);
|
|
176
181
|
});
|
|
177
182
|
});
|