@datadog/mobile-react-native 1.3.0 → 1.4.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 +2 -2
- package/android/build.gradle +58 -64
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +36 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +14 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +162 -16
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +7 -0
- package/ios/Sources/DdSdk.swift +2 -2
- package/ios/Sources/RNDdSdkConfiguration.swift +42 -0
- package/lib/commonjs/DdSdkReactNative.js +2 -2
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +26 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +9 -0
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js +59 -41
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js +136 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +39 -6
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -1
- 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 +12 -21
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -1
- package/lib/commonjs/rum/types.js +19 -1
- package/lib/commonjs/rum/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 +3 -3
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +22 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +9 -0
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +2 -2
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js +57 -35
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js +115 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +37 -3
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +3 -3
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js +10 -15
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +1 -1
- package/lib/module/rum/types.js +16 -0
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +11 -3
- package/lib/typescript/index.d.ts +3 -3
- package/lib/typescript/rum/eventMappers/resourceEventMapper.d.ts +0 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +2 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +32 -6
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.d.ts +21 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +4 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.d.ts +6 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +0 -6
- package/lib/typescript/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +0 -1
- package/lib/typescript/rum/types.d.ts +17 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +8 -4
- package/src/DdSdkReactNativeConfiguration.tsx +36 -3
- package/src/__tests__/DdSdkReactNative.test.tsx +16 -4
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -6
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +2 -1
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +130 -114
- package/src/index.tsx +6 -3
- package/src/rum/__tests__/DdRum.test.ts +17 -1
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +8 -0
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +6 -3
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +15 -3
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/distributedTracing.test.ts +64 -24
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +19 -7
- package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +82 -40
- package/src/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.ts +141 -0
- package/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.ts +43 -7
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.ts +8 -1
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +4 -4
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -1
- package/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.ts +8 -23
- package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +257 -74
- package/src/rum/types.ts +19 -0
- package/src/sdk/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +2 -1
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +5 -4
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +6 -2
- package/src/version.ts +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
import { PropagatorType } from '../../../types';
|
|
7
|
+
export const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
|
|
8
|
+
/**
|
|
9
|
+
* Datadog headers
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const ORIGIN_HEADER_KEY = 'x-datadog-origin';
|
|
13
|
+
export const ORIGIN_RUM = 'rum';
|
|
14
|
+
export const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
|
|
15
|
+
export const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
|
|
16
|
+
/**
|
|
17
|
+
* OTel headers
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export const TRACECONTEXT_HEADER_KEY = 'traceparent';
|
|
21
|
+
export const B3_HEADER_KEY = 'b3';
|
|
22
|
+
export const B3_MULTI_TRACE_ID_HEADER_KEY = 'X-B3-TraceId';
|
|
23
|
+
export const B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';
|
|
24
|
+
export const B3_MULTI_SAMPLED_HEADER_KEY = 'X-B3-Sampled';
|
|
25
|
+
export const getTracingHeaders = tracingAttributes => {
|
|
26
|
+
const headers = [];
|
|
27
|
+
|
|
28
|
+
if (tracingAttributes.tracingStrategy === 'DISCARD') {
|
|
29
|
+
return headers;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
tracingAttributes.propagatorTypes.forEach(propagator => {
|
|
33
|
+
switch (propagator) {
|
|
34
|
+
case PropagatorType.DATADOG:
|
|
35
|
+
{
|
|
36
|
+
headers.push({
|
|
37
|
+
header: ORIGIN_HEADER_KEY,
|
|
38
|
+
value: ORIGIN_RUM
|
|
39
|
+
}, {
|
|
40
|
+
header: SAMPLING_PRIORITY_HEADER_KEY,
|
|
41
|
+
value: tracingAttributes.samplingPriorityHeader
|
|
42
|
+
}, {
|
|
43
|
+
header: TRACE_ID_HEADER_KEY,
|
|
44
|
+
value: tracingAttributes.traceId.toString(10)
|
|
45
|
+
}, {
|
|
46
|
+
header: PARENT_ID_HEADER_KEY,
|
|
47
|
+
value: tracingAttributes.spanId.toString(10)
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
case PropagatorType.TRACECONTEXT:
|
|
53
|
+
{
|
|
54
|
+
headers.push({
|
|
55
|
+
header: TRACECONTEXT_HEADER_KEY,
|
|
56
|
+
value: generateTraceContextHeader({
|
|
57
|
+
version: '00',
|
|
58
|
+
traceId: tracingAttributes.traceId,
|
|
59
|
+
parentId: tracingAttributes.spanId,
|
|
60
|
+
isSampled: tracingAttributes.samplingPriorityHeader === '1'
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
case PropagatorType.B3:
|
|
67
|
+
{
|
|
68
|
+
headers.push({
|
|
69
|
+
header: B3_HEADER_KEY,
|
|
70
|
+
value: generateB3Header({
|
|
71
|
+
traceId: tracingAttributes.traceId,
|
|
72
|
+
spanId: tracingAttributes.spanId,
|
|
73
|
+
isSampled: tracingAttributes.samplingPriorityHeader === '1'
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
case PropagatorType.B3MULTI:
|
|
80
|
+
{
|
|
81
|
+
headers.push({
|
|
82
|
+
header: B3_MULTI_TRACE_ID_HEADER_KEY,
|
|
83
|
+
value: tracingAttributes.traceId.toPaddedString(16, 32)
|
|
84
|
+
}, {
|
|
85
|
+
header: B3_MULTI_SPAN_ID_HEADER_KEY,
|
|
86
|
+
value: tracingAttributes.spanId.toPaddedString(16, 16)
|
|
87
|
+
}, {
|
|
88
|
+
header: B3_MULTI_SAMPLED_HEADER_KEY,
|
|
89
|
+
value: tracingAttributes.samplingPriorityHeader
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return headers;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const generateTraceContextHeader = ({
|
|
98
|
+
version,
|
|
99
|
+
traceId,
|
|
100
|
+
parentId,
|
|
101
|
+
isSampled
|
|
102
|
+
}) => {
|
|
103
|
+
const flags = isSampled ? '01' : '00';
|
|
104
|
+
return `${version}-${traceId.toPaddedString(16, 32)}-${parentId.toPaddedString(16, 16)}-${flags}`;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const generateB3Header = ({
|
|
108
|
+
traceId,
|
|
109
|
+
spanId,
|
|
110
|
+
isSampled
|
|
111
|
+
}) => {
|
|
112
|
+
const flags = isSampled ? '1' : '0';
|
|
113
|
+
return `${traceId.toPaddedString(16, 32)}-${spanId.toPaddedString(16, 16)}-${flags}`;
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=distributedTracingHeaders.js.map
|
package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["distributedTracingHeaders.ts"],"names":["PropagatorType","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_HEADER_KEY","ORIGIN_RUM","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","TRACECONTEXT_HEADER_KEY","B3_HEADER_KEY","B3_MULTI_TRACE_ID_HEADER_KEY","B3_MULTI_SPAN_ID_HEADER_KEY","B3_MULTI_SAMPLED_HEADER_KEY","getTracingHeaders","tracingAttributes","headers","tracingStrategy","propagatorTypes","forEach","propagator","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","spanId","TRACECONTEXT","generateTraceContextHeader","version","parentId","isSampled","B3","generateB3Header","B3MULTI","toPaddedString","flags"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,cAAT,QAA+B,gBAA/B;AAQA,OAAO,MAAMC,4BAA4B,GAAG,6BAArC;AACP;AACA;AACA;;AACA,OAAO,MAAMC,iBAAiB,GAAG,kBAA1B;AACP,OAAO,MAAMC,UAAU,GAAG,KAAnB;AACP,OAAO,MAAMC,mBAAmB,GAAG,oBAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,qBAA7B;AACP;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB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GnB,IAAGL,QAAQ,CAACK,cAAT,CAAwB,EAAxB,EAA4B,EAA5B,CAAgC,IAAGC,KAAM,EAH9C;AAIH,CAhBD;;AAkBA,MAAMH,gBAAgB,GAAG,CAAC;AACtBT,EAAAA,OADsB;AAEtBE,EAAAA,MAFsB;AAGtBK,EAAAA;AAHsB,CAAD,KAQnB;AACF,QAAMK,KAAK,GAAGL,SAAS,GAAG,GAAH,GAAS,GAAhC;AACA,SAAQ,GAAEP,OAAO,CAACW,cAAR,CAAuB,EAAvB,EAA2B,EAA3B,CAA+B,IAAGT,MAAM,CAACS,cAAP,CACxC,EADwC,EAExC,EAFwC,CAG1C,IAAGC,KAAM,EAHX;AAIH,CAdD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { PropagatorType } from '../../../types';\n\nimport type {\n DdRumResourceTracingAttributes,\n SpanId,\n TraceId\n} from './distributedTracing';\n\nexport const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';\n/**\n * Datadog headers\n */\nexport const ORIGIN_HEADER_KEY = 'x-datadog-origin';\nexport const ORIGIN_RUM = 'rum';\nexport const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';\nexport const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';\n/**\n * OTel headers\n */\nexport const TRACECONTEXT_HEADER_KEY = 'traceparent';\nexport const B3_HEADER_KEY = 'b3';\nexport const B3_MULTI_TRACE_ID_HEADER_KEY = 'X-B3-TraceId';\nexport const B3_MULTI_SPAN_ID_HEADER_KEY = 'X-B3-SpanId';\nexport const B3_MULTI_SAMPLED_HEADER_KEY = 'X-B3-Sampled';\n\nexport const getTracingHeaders = (\n tracingAttributes: DdRumResourceTracingAttributes\n): { header: string; value: string }[] => {\n const headers: { header: string; value: string }[] = [];\n if (tracingAttributes.tracingStrategy === 'DISCARD') {\n return headers;\n }\n tracingAttributes.propagatorTypes.forEach(propagator => {\n switch (propagator) {\n case PropagatorType.DATADOG: {\n headers.push(\n {\n header: ORIGIN_HEADER_KEY,\n value: ORIGIN_RUM\n },\n {\n header: SAMPLING_PRIORITY_HEADER_KEY,\n value: tracingAttributes.samplingPriorityHeader\n },\n {\n header: TRACE_ID_HEADER_KEY,\n value: tracingAttributes.traceId.toString(10)\n },\n {\n header: PARENT_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toString(10)\n }\n );\n break;\n }\n case PropagatorType.TRACECONTEXT: {\n headers.push({\n header: TRACECONTEXT_HEADER_KEY,\n value: generateTraceContextHeader({\n version: '00',\n traceId: tracingAttributes.traceId,\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n });\n break;\n }\n case PropagatorType.B3: {\n headers.push({\n header: B3_HEADER_KEY,\n value: generateB3Header({\n traceId: tracingAttributes.traceId,\n spanId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\n });\n break;\n }\n case PropagatorType.B3MULTI: {\n headers.push(\n {\n header: B3_MULTI_TRACE_ID_HEADER_KEY,\n value: tracingAttributes.traceId.toPaddedString(16, 32)\n },\n {\n header: B3_MULTI_SPAN_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toPaddedString(16, 16)\n },\n {\n header: B3_MULTI_SAMPLED_HEADER_KEY,\n value: tracingAttributes.samplingPriorityHeader\n }\n );\n }\n }\n });\n\n return headers;\n};\n\nconst generateTraceContextHeader = ({\n version,\n traceId,\n parentId,\n isSampled\n}: {\n version: string;\n traceId: TraceId;\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const flags = isSampled ? '01' : '00';\n return `${version}-${traceId.toPaddedString(\n 16,\n 32\n )}-${parentId.toPaddedString(16, 16)}-${flags}`;\n};\n\nconst generateB3Header = ({\n traceId,\n spanId,\n isSampled\n}: {\n traceId: TraceId;\n spanId: SpanId;\n isSampled: boolean;\n}) => {\n const flags = isSampled ? '1' : '0';\n return `${traceId.toPaddedString(16, 32)}-${spanId.toPaddedString(\n 16,\n 16\n )}-${flags}`;\n};\n"]}
|
|
@@ -12,7 +12,31 @@ const escapeRegExp = string => {
|
|
|
12
12
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const firstPartyHostsRegexMapBuilder = firstPartyHosts => {
|
|
16
|
+
const hostsMap = {
|
|
17
|
+
datadog: [],
|
|
18
|
+
tracecontext: [],
|
|
19
|
+
b3: [],
|
|
20
|
+
b3multi: []
|
|
21
|
+
};
|
|
22
|
+
firstPartyHosts.forEach(host => {
|
|
23
|
+
host.propagatorTypes.forEach(propagatorType => {
|
|
24
|
+
hostsMap[propagatorType].push(host.match);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
const regexMap = [];
|
|
28
|
+
Object.entries(hostsMap).forEach(([propagatorType, hosts]) => {
|
|
29
|
+
if (hosts.length > 0) {
|
|
30
|
+
regexMap.push({
|
|
31
|
+
propagatorType: propagatorType,
|
|
32
|
+
regex: firstPartyHostsRegexBuilder(hosts)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return regexMap;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const firstPartyHostsRegexBuilder = firstPartyHosts => {
|
|
16
40
|
if (firstPartyHosts.length === 0) {
|
|
17
41
|
return NO_MATCH_REGEX;
|
|
18
42
|
}
|
|
@@ -28,7 +52,17 @@ export const firstPartyHostsRegexBuilder = firstPartyHosts => {
|
|
|
28
52
|
return NO_MATCH_REGEX;
|
|
29
53
|
}
|
|
30
54
|
};
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
|
|
56
|
+
export const getPropagatorsForHost = (hostname, firstPartyHostsRegexMap) => {
|
|
57
|
+
const matchedPropagatorTypes = [];
|
|
58
|
+
firstPartyHostsRegexMap.forEach(({
|
|
59
|
+
regex,
|
|
60
|
+
propagatorType
|
|
61
|
+
}) => {
|
|
62
|
+
if (regex.test(hostname)) {
|
|
63
|
+
matchedPropagatorTypes.push(propagatorType);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return matchedPropagatorTypes.length > 0 ? matchedPropagatorTypes : null;
|
|
33
67
|
};
|
|
34
68
|
//# sourceMappingURL=firstPartyHosts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["firstPartyHosts.ts"],"names":["InternalLog","SdkVerbosity","NO_MATCH_REGEX","RegExp","escapeRegExp","string","replace","
|
|
1
|
+
{"version":3,"sources":["firstPartyHosts.ts"],"names":["InternalLog","SdkVerbosity","NO_MATCH_REGEX","RegExp","escapeRegExp","string","replace","firstPartyHostsRegexMapBuilder","firstPartyHosts","hostsMap","datadog","tracecontext","b3","b3multi","forEach","host","propagatorTypes","propagatorType","push","match","regexMap","Object","entries","hosts","length","regex","firstPartyHostsRegexBuilder","firstPartyHostsRegex","map","join","test","e","log","JSON","stringify","WARN","getPropagatorsForHost","hostname","firstPartyHostsRegexMap","matchedPropagatorTypes"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,yBAA5B;AACA,SAASC,YAAT,QAA6B,0BAA7B;AAOA;AACA,OAAO,MAAMC,cAAc,GAAG,IAAIC,MAAJ,CAAW,IAAX,CAAvB,C,CAEP;;AACA,MAAMC,YAAY,GAAIC,MAAD,IAAoB;AACrC,SAAOA,MAAM,CAACC,OAAP,CAAe,qBAAf,EAAsC,MAAtC,CAAP,CADqC,CACiB;AACzD,CAFD;;AAIA,OAAO,MAAMC,8BAA8B,GACvCC,eAD0C,IAE/B;AACX,QAAMC,QAA0C,GAAG;AAC/CC,IAAAA,OAAO,EAAE,EADsC;AAE/CC,IAAAA,YAAY,EAAE,EAFiC;AAG/CC,IAAAA,EAAE,EAAE,EAH2C;AAI/CC,IAAAA,OAAO,EAAE;AAJs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AAO,MAAMkC,qBAAqB,GAAG,CACjCC,QADiC,EAEjCC,uBAFiC,KAGP;AAC1B,QAAMC,sBAAwC,GAAG,EAAjD;AACAD,EAAAA,uBAAuB,CAACxB,OAAxB,CAAgC,CAAC;AAAEW,IAAAA,KAAF;AAASR,IAAAA;AAAT,GAAD,KAA+B;AAC3D,QAAIQ,KAAK,CAACK,IAAN,CAAWO,QAAX,CAAJ,EAA0B;AACtBE,MAAAA,sBAAsB,CAACrB,IAAvB,CAA4BD,cAA5B;AACH;AACJ,GAJD;AAKA,SAAOsB,sBAAsB,CAACf,MAAvB,GAAgC,CAAhC,GAAoCe,sBAApC,GAA6D,IAApE;AACH,CAXM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\nimport type { FirstPartyHost, PropagatorType } from '../../../types';\n\nimport type { RegexMap } from './interfaces/RequestProxy';\n\nexport type Hostname = { _type: 'Hostname' } & string;\n\n// This regex does not match anything\nexport const NO_MATCH_REGEX = new RegExp('a^');\n\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\nconst escapeRegExp = (string: string) => {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n};\n\nexport const firstPartyHostsRegexMapBuilder = (\n firstPartyHosts: FirstPartyHost[]\n): RegexMap => {\n const hostsMap: Record<PropagatorType, string[]> = {\n datadog: [],\n tracecontext: [],\n b3: [],\n b3multi: []\n };\n\n firstPartyHosts.forEach(host => {\n host.propagatorTypes.forEach(propagatorType => {\n hostsMap[propagatorType].push(host.match);\n });\n });\n\n const regexMap: { regex: RegExp; propagatorType: PropagatorType }[] = [];\n Object.entries(hostsMap).forEach(([propagatorType, hosts]) => {\n if (hosts.length > 0) {\n regexMap.push({\n propagatorType: propagatorType as PropagatorType,\n regex: firstPartyHostsRegexBuilder(hosts)\n });\n }\n });\n\n return regexMap;\n};\n\nconst firstPartyHostsRegexBuilder = (firstPartyHosts: string[]): RegExp => {\n if (firstPartyHosts.length === 0) {\n return NO_MATCH_REGEX;\n }\n try {\n // A regexp for matching hosts, e.g. when `hosts` is \"example.com\", it will match\n // \"example.com\", \"api.example.com\", but not \"foo.com\".\n const firstPartyHostsRegex = new RegExp(\n `^(.*\\\\.)*(${firstPartyHosts\n .map(host => `${escapeRegExp(host)}$`)\n .join('|')})`\n );\n firstPartyHostsRegex.test('test_the_regex_is_valid');\n return firstPartyHostsRegex;\n } catch (e) {\n InternalLog.log(\n `Invalid first party hosts list ${JSON.stringify(\n firstPartyHosts\n )}. Regular expressions are not allowed.`,\n SdkVerbosity.WARN\n );\n return NO_MATCH_REGEX;\n }\n};\n\nexport const getPropagatorsForHost = (\n hostname: Hostname,\n firstPartyHostsRegexMap: RegexMap\n): PropagatorType[] | null => {\n const matchedPropagatorTypes: PropagatorType[] = [];\n firstPartyHostsRegexMap.forEach(({ regex, propagatorType }) => {\n if (regex.test(hostname)) {\n matchedPropagatorTypes.push(propagatorType);\n }\n });\n return matchedPropagatorTypes.length > 0 ? matchedPropagatorTypes : null;\n};\n"]}
|
package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RequestProxy.ts"],"names":["RequestProxy"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"sources":["RequestProxy.ts"],"names":["RequestProxy"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAcA,OAAO,MAAeA,YAAf,CAA4B;AAAA;AAAA;;AAAA;AAAA;;AAAA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { PropagatorType } from '../../../../types';\n\nexport interface RequestProxyOptions {\n tracingSamplingRate: number;\n firstPartyHostsRegexMap: RegexMap;\n}\n\nexport type RegexMap = {\n regex: RegExp;\n propagatorType: PropagatorType;\n}[];\n\nexport abstract class RequestProxy {\n abstract onTrackingStart: (context: RequestProxyOptions) => void;\n abstract onTrackingStop: () => void;\n}\n"]}
|
|
@@ -31,9 +31,9 @@ export class ResourceReporter {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const formatResourceStartContext = tracingAttributes => {
|
|
34
|
-
return tracingAttributes.
|
|
35
|
-
'_dd.span_id': tracingAttributes.spanId,
|
|
36
|
-
'_dd.trace_id': tracingAttributes.traceId,
|
|
34
|
+
return tracingAttributes.samplingPriorityHeader === '0' ? undefined : {
|
|
35
|
+
'_dd.span_id': tracingAttributes.spanId.toString(10),
|
|
36
|
+
'_dd.trace_id': tracingAttributes.traceId.toString(10),
|
|
37
37
|
'_dd.rule_psr': tracingAttributes.rulePsr
|
|
38
38
|
};
|
|
39
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ResourceReporter.ts"],"names":["DdRum","createTimings","ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","
|
|
1
|
+
{"version":3,"sources":["ResourceReporter.ts"],"names":["DdRum","createTimings","ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","samplingPriorityHeader","undefined","spanId","toString","traceId","rulePsr","formatResourceStopContext","timings","responseStartTime","startTime","stopTime","startResource","key","request","method","url","stopResource","response","statusCode","kind","size","resourceContext"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,QAAsB,mBAAtB;AAGA,SAASC,aAAT,QAA8B,kBAA9B;AAIA,OAAO,MAAMC,gBAAN,CAAuB;AAG1BC,EAAAA,WAAW,CAACC,eAAD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AAQ,CAACmB,GADb,EAEInB,QAAQ,CAACwB,QAAT,CAAkBC,UAFtB,EAGIzB,QAAQ,CAACoB,OAAT,CAAiBM,IAHrB,EAII1B,QAAQ,CAACwB,QAAT,CAAkBG,IAJtB,EAKId,yBAAyB,CAACb,QAAQ,CAACc,OAAV,CAL7B,EAMId,QAAQ,CAACc,OAAT,CAAiBG,QANrB,EAOIjB,QAAQ,CAAC4B,eAPb;AASH,CAlBD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRum } from '../../../../DdRum';\nimport type { RUMResource } from '../../domain/interfaces/RumResource';\n\nimport { createTimings } from './resourceTiming';\n\ntype ResourceMapper = (resource: RUMResource) => RUMResource | null;\n\nexport class ResourceReporter {\n private mappers: ResourceMapper[];\n\n constructor(resourceMappers: ResourceMapper[]) {\n this.mappers = resourceMappers;\n }\n\n reportResource = (resource: RUMResource) => {\n let modifiedResource: RUMResource | null = resource;\n\n for (const mapper of this.mappers) {\n modifiedResource = mapper(resource);\n if (modifiedResource === null) {\n return;\n }\n }\n\n reportResource(modifiedResource);\n };\n}\n\nconst formatResourceStartContext = (\n tracingAttributes: RUMResource['tracingAttributes']\n): Record<string, string | number> | undefined => {\n return tracingAttributes.samplingPriorityHeader === '0'\n ? undefined\n : {\n '_dd.span_id': tracingAttributes.spanId.toString(10),\n '_dd.trace_id': tracingAttributes.traceId.toString(10),\n '_dd.rule_psr': tracingAttributes.rulePsr\n };\n};\n\nconst formatResourceStopContext = (\n timings: RUMResource['timings']\n): Record<string, unknown> => {\n return {\n '_dd.resource_timings':\n timings.responseStartTime !== undefined\n ? createTimings(\n timings.startTime,\n timings.responseStartTime,\n timings.stopTime\n )\n : null\n };\n};\n\nconst reportResource = async (resource: RUMResource) => {\n await DdRum.startResource(\n resource.key,\n resource.request.method,\n resource.request.url,\n formatResourceStartContext(resource.tracingAttributes),\n resource.timings.startTime\n );\n\n DdRum.stopResource(\n resource.key,\n resource.response.statusCode,\n resource.request.kind,\n resource.response.size,\n formatResourceStopContext(resource.timings),\n resource.timings.stopTime,\n resource.resourceContext\n );\n};\n"]}
|
|
@@ -6,15 +6,11 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
* Copyright 2016-Present Datadog, Inc.
|
|
7
7
|
*/
|
|
8
8
|
import Timer from '../../../../Timer';
|
|
9
|
+
import { getTracingHeaders } from '../domain/distributedTracingHeaders';
|
|
9
10
|
import { getTracingAttributes } from '../domain/distributedTracing';
|
|
10
11
|
import { RequestProxy } from '../domain/interfaces/RequestProxy';
|
|
11
12
|
import { URLHostParser } from './URLHostParser';
|
|
12
13
|
import { calculateResponseSize } from './responseSize';
|
|
13
|
-
export const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
|
|
14
|
-
export const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
|
|
15
|
-
export const ORIGIN_HEADER_KEY = 'x-datadog-origin';
|
|
16
|
-
export const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
|
|
17
|
-
export const ORIGIN_RUM = 'rum';
|
|
18
14
|
const RESPONSE_START_LABEL = 'response_start';
|
|
19
15
|
|
|
20
16
|
/**
|
|
@@ -55,7 +51,7 @@ const proxyOpen = ({
|
|
|
55
51
|
xhrType
|
|
56
52
|
}, context) => {
|
|
57
53
|
const originalXhrOpen = xhrType.prototype.open;
|
|
58
|
-
const
|
|
54
|
+
const firstPartyHostsRegexMap = context.firstPartyHostsRegexMap;
|
|
59
55
|
const tracingSamplingRate = context.tracingSamplingRate;
|
|
60
56
|
|
|
61
57
|
xhrType.prototype.open = function (method, url) {
|
|
@@ -69,7 +65,7 @@ const proxyOpen = ({
|
|
|
69
65
|
timer: new Timer(),
|
|
70
66
|
tracingAttributes: getTracingAttributes({
|
|
71
67
|
hostname,
|
|
72
|
-
|
|
68
|
+
firstPartyHostsRegexMap,
|
|
73
69
|
tracingSamplingRate
|
|
74
70
|
})
|
|
75
71
|
}; // eslint-disable-next-line prefer-rest-params
|
|
@@ -87,14 +83,13 @@ const proxySend = providers => {
|
|
|
87
83
|
// keep track of start time
|
|
88
84
|
this._datadog_xhr.timer.start();
|
|
89
85
|
|
|
90
|
-
this.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.setRequestHeader(
|
|
96
|
-
|
|
97
|
-
}
|
|
86
|
+
const tracingHeaders = getTracingHeaders(this._datadog_xhr.tracingAttributes);
|
|
87
|
+
tracingHeaders.forEach(({
|
|
88
|
+
header,
|
|
89
|
+
value
|
|
90
|
+
}) => {
|
|
91
|
+
this.setRequestHeader(header, value);
|
|
92
|
+
});
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
proxyOnReadyStateChange(this, providers); // eslint-disable-next-line prefer-rest-params
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["XHRProxy.ts"],"names":["Timer","getTracingAttributes","RequestProxy","URLHostParser","calculateResponseSize","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","ORIGIN_HEADER_KEY","SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_RUM","RESPONSE_START_LABEL","XHRProxy","constructor","providers","context","originalXhrOpen","xhrType","prototype","open","originalXhrSend","send","proxyRequests","proxyOpen","proxySend","firstPartyHostsRegex","tracingSamplingRate","method","url","hostname","_datadog_xhr","reported","timer","tracingAttributes","apply","arguments","start","setRequestHeader","samplingPriorityHeader","tracingStrategy","traceId","spanId","proxyOnReadyStateChange","xhrProxy","originalOnreadystatechange","onreadystatechange","readyState","DONE","reportXhr","resourceReporter","HEADERS_RECEIVED","recordTick","responseSize","key","startTime","stop","reportResource","request","kind","response","statusCode","status","size","timings","stopTime","responseStartTime","hasTickFor","timeAt","undefined","resourceContext"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP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MAAMa,SAAS,GAAG,OACdL,QADc,EAEdM,gBAFc,KAGE;AAChB,QAAMG,YAAY,GAAG/C,qBAAqB,CAACsC,QAAD,CAA1C;AAEA,QAAM5B,OAAO,GAAG4B,QAAQ,CAACb,YAAzB;AAEA,QAAMuB,GAAG,GAAI,GAAEtC,OAAO,CAACiB,KAAR,CAAcsB,SAAU,IAAGvC,OAAO,CAACY,MAAO,EAAzD;AAEAZ,EAAAA,OAAO,CAACiB,KAAR,CAAcuB,IAAd;AAEAN,EAAAA,gBAAgB,CAACO,cAAjB,CAAgC;AAC5BH,IAAAA,GAD4B;AAE5BI,IAAAA,OAAO,EAAE;AACL9B,MAAAA,MAAM,EAAEZ,OAAO,CAACY,MADX;AAELC,MAAAA,GAAG,EAAEb,OAAO,CAACa,GAFR;AAGL8B,MAAAA,IAAI,EAAE;AAHD,KAFmB;AAO5BzB,IAAAA,iBAAiB,EAAElB,OAAO,CAACkB,iBAPC;AAQ5B0B,IAAAA,QAAQ,EAAE;AACNC,MAAAA,UAAU,EAAEjB,QAAQ,CAACkB,MADf;AAENC,MAAAA,IAAI,EAAEV;AAFA,KARkB;AAY5BW,IAAAA,OAAO,EAAE;AACLT,MAAAA,SAAS,EAAEvC,OAAO,CAACiB,KAAR,CAAcsB,SADpB;AAELU,MAAAA,QAAQ,EAAEjD,OAAO,CAACiB,KAAR,CAAcgC,QAFnB;AAGLC,MAAAA,iBAAiB,EAAElD,OAAO,CAACiB,KAAR,CAAckC,UAAd,CAAyBvD,oBAAzB,IACbI,OAAO,CAACiB,KAAR,CAAcmC,MAAd,CAAqBxD,oBAArB,CADa,GAEbyD;AALD,KAZmB;AAmB5BC,IAAAA,eAAe,EAAE1B;AAnBW,GAAhC;AAqBH,CAjCD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport Timer from '../../../../Timer';\nimport type { DdRumResourceTracingAttributes } from '../domain/distributedTracing';\nimport { getTracingAttributes } from '../domain/distributedTracing';\nimport type { RequestProxyOptions } from '../domain/interfaces/RequestProxy';\nimport { RequestProxy } from '../domain/interfaces/RequestProxy';\n\nimport type { ResourceReporter } from './DatadogRumResource/ResourceReporter';\nimport { URLHostParser } from './URLHostParser';\nimport { calculateResponseSize } from './responseSize';\n\nexport const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';\nexport const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';\nexport const ORIGIN_HEADER_KEY = 'x-datadog-origin';\nexport const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';\nexport const ORIGIN_RUM = 'rum';\n\nconst RESPONSE_START_LABEL = 'response_start';\n\ninterface DdRumXhr extends XMLHttpRequest {\n _datadog_xhr: DdRumXhrContext;\n}\n\ninterface DdRumXhrContext {\n method: string;\n url: string;\n reported: boolean;\n timer: Timer;\n tracingAttributes: DdRumResourceTracingAttributes;\n}\n\ninterface XHRProxyProviders {\n xhrType: typeof XMLHttpRequest;\n resourceReporter: ResourceReporter;\n}\n\n/**\n * Proxies XMLHTTPRequest to track resources.\n */\nexport class XHRProxy extends RequestProxy {\n private providers: XHRProxyProviders;\n private static originalXhrOpen: typeof XMLHttpRequest.prototype.open;\n private static originalXhrSend: typeof XMLHttpRequest.prototype.send;\n\n constructor(providers: XHRProxyProviders) {\n super();\n this.providers = providers;\n }\n\n onTrackingStart = (context: RequestProxyOptions) => {\n XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;\n XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;\n proxyRequests(this.providers, context);\n };\n\n onTrackingStop = () => {\n this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;\n this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;\n };\n}\n\nconst proxyRequests = (\n providers: XHRProxyProviders,\n context: RequestProxyOptions\n): void => {\n proxyOpen(providers, context);\n proxySend(providers);\n};\n\nconst proxyOpen = (\n { xhrType }: XHRProxyProviders,\n context: RequestProxyOptions\n): void => {\n const originalXhrOpen = xhrType.prototype.open;\n const firstPartyHostsRegex = context.firstPartyHostsRegex;\n const tracingSamplingRate = context.tracingSamplingRate;\n\n xhrType.prototype.open = function (\n this: DdRumXhr,\n method: string,\n url: string\n ) {\n const hostname = URLHostParser(url);\n // Keep track of the method and url\n // start time is tracked by the `send` method\n this._datadog_xhr = {\n method,\n url,\n reported: false,\n timer: new Timer(),\n tracingAttributes: getTracingAttributes({\n hostname,\n firstPartyHostsRegex,\n tracingSamplingRate\n })\n };\n // eslint-disable-next-line prefer-rest-params\n return originalXhrOpen.apply(this, arguments as any);\n };\n};\n\nconst proxySend = (providers: XHRProxyProviders): void => {\n const xhrType = providers.xhrType;\n const originalXhrSend = xhrType.prototype.send;\n\n xhrType.prototype.send = function (this: DdRumXhr) {\n if (this._datadog_xhr) {\n // keep track of start time\n this._datadog_xhr.timer.start();\n this.setRequestHeader(ORIGIN_HEADER_KEY, ORIGIN_RUM);\n\n const tracingAttributes = this._datadog_xhr.tracingAttributes;\n this.setRequestHeader(\n SAMPLING_PRIORITY_HEADER_KEY,\n tracingAttributes.samplingPriorityHeader\n );\n if (tracingAttributes.tracingStrategy !== 'DISCARD') {\n this.setRequestHeader(\n TRACE_ID_HEADER_KEY,\n tracingAttributes.traceId\n );\n this.setRequestHeader(\n PARENT_ID_HEADER_KEY,\n tracingAttributes.spanId\n );\n }\n }\n\n proxyOnReadyStateChange(this, providers);\n\n // eslint-disable-next-line prefer-rest-params\n return originalXhrSend.apply(this, arguments as any);\n };\n};\n\nconst proxyOnReadyStateChange = (\n xhrProxy: DdRumXhr,\n providers: XHRProxyProviders\n): void => {\n const xhrType = providers.xhrType;\n const originalOnreadystatechange = xhrProxy.onreadystatechange;\n\n xhrProxy.onreadystatechange = function () {\n if (xhrProxy.readyState === xhrType.DONE) {\n if (!xhrProxy._datadog_xhr.reported) {\n reportXhr(xhrProxy, providers.resourceReporter);\n xhrProxy._datadog_xhr.reported = true;\n }\n } else if (xhrProxy.readyState === xhrType.HEADERS_RECEIVED) {\n xhrProxy._datadog_xhr.timer.recordTick(RESPONSE_START_LABEL);\n }\n\n if (originalOnreadystatechange) {\n // eslint-disable-next-line prefer-rest-params\n originalOnreadystatechange.apply(xhrProxy, arguments as any);\n }\n };\n};\n\nconst reportXhr = async (\n xhrProxy: DdRumXhr,\n resourceReporter: ResourceReporter\n): Promise<void> => {\n const responseSize = calculateResponseSize(xhrProxy);\n\n const context = xhrProxy._datadog_xhr;\n\n const key = `${context.timer.startTime}/${context.method}`;\n\n context.timer.stop();\n\n resourceReporter.reportResource({\n key,\n request: {\n method: context.method,\n url: context.url,\n kind: 'xhr'\n },\n tracingAttributes: context.tracingAttributes,\n response: {\n statusCode: xhrProxy.status,\n size: responseSize\n },\n timings: {\n startTime: context.timer.startTime,\n stopTime: context.timer.stopTime,\n responseStartTime: context.timer.hasTickFor(RESPONSE_START_LABEL)\n ? context.timer.timeAt(RESPONSE_START_LABEL)\n : undefined\n },\n resourceContext: xhrProxy\n });\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["XHRProxy.ts"],"names":["Timer","getTracingHeaders","getTracingAttributes","RequestProxy","URLHostParser","calculateResponseSize","RESPONSE_START_LABEL","XHRProxy","constructor","providers","context","originalXhrOpen","xhrType","prototype","open","originalXhrSend","send","proxyRequests","proxyOpen","proxySend","firstPartyHostsRegexMap","tracingSamplingRate","method","url","hostname","_datadog_xhr","reported","timer","tracingAttributes","apply","arguments","start","tracingHeaders","forEach","header","value","setRequestHeader","proxyOnReadyStateChange","xhrProxy","originalOnreadystatechange","onreadystatechange","readyState","DONE","reportXhr","resourceReporter","HEADERS_RECEIVED","recordTick","responseSize","key","startTime","stop","reportResource","request","kind","response","statusCode","status","size","timings","stopTime","responseStartTime","hasTickFor","timeAt","undefined","resourceContext"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,mBAAlB;AACA,SA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A,gBAAgB,CAACO,cAAjB,CAAgC;AAC5BH,IAAAA,GAD4B;AAE5BI,IAAAA,OAAO,EAAE;AACL9B,MAAAA,MAAM,EAAEZ,OAAO,CAACY,MADX;AAELC,MAAAA,GAAG,EAAEb,OAAO,CAACa,GAFR;AAGL8B,MAAAA,IAAI,EAAE;AAHD,KAFmB;AAO5BzB,IAAAA,iBAAiB,EAAElB,OAAO,CAACkB,iBAPC;AAQ5B0B,IAAAA,QAAQ,EAAE;AACNC,MAAAA,UAAU,EAAEjB,QAAQ,CAACkB,MADf;AAENC,MAAAA,IAAI,EAAEV;AAFA,KARkB;AAY5BW,IAAAA,OAAO,EAAE;AACLT,MAAAA,SAAS,EAAEvC,OAAO,CAACiB,KAAR,CAAcsB,SADpB;AAELU,MAAAA,QAAQ,EAAEjD,OAAO,CAACiB,KAAR,CAAcgC,QAFnB;AAGLC,MAAAA,iBAAiB,EAAElD,OAAO,CAACiB,KAAR,CAAckC,UAAd,CAAyBvD,oBAAzB,IACbI,OAAO,CAACiB,KAAR,CAAcmC,MAAd,CAAqBxD,oBAArB,CADa,GAEbyD;AALD,KAZmB;AAmB5BC,IAAAA,eAAe,EAAE1B;AAnBW,GAAhC;AAqBH,CAjCD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport Timer from '../../../../Timer';\nimport { getTracingHeaders } from '../domain/distributedTracingHeaders';\nimport type { DdRumResourceTracingAttributes } from '../domain/distributedTracing';\nimport { getTracingAttributes } from '../domain/distributedTracing';\nimport type { RequestProxyOptions } from '../domain/interfaces/RequestProxy';\nimport { RequestProxy } from '../domain/interfaces/RequestProxy';\n\nimport type { ResourceReporter } from './DatadogRumResource/ResourceReporter';\nimport { URLHostParser } from './URLHostParser';\nimport { calculateResponseSize } from './responseSize';\n\nconst RESPONSE_START_LABEL = 'response_start';\n\ninterface DdRumXhr extends XMLHttpRequest {\n _datadog_xhr: DdRumXhrContext;\n}\n\ninterface DdRumXhrContext {\n method: string;\n url: string;\n reported: boolean;\n timer: Timer;\n tracingAttributes: DdRumResourceTracingAttributes;\n}\n\ninterface XHRProxyProviders {\n xhrType: typeof XMLHttpRequest;\n resourceReporter: ResourceReporter;\n}\n\n/**\n * Proxies XMLHTTPRequest to track resources.\n */\nexport class XHRProxy extends RequestProxy {\n private providers: XHRProxyProviders;\n private static originalXhrOpen: typeof XMLHttpRequest.prototype.open;\n private static originalXhrSend: typeof XMLHttpRequest.prototype.send;\n\n constructor(providers: XHRProxyProviders) {\n super();\n this.providers = providers;\n }\n\n onTrackingStart = (context: RequestProxyOptions) => {\n XHRProxy.originalXhrOpen = this.providers.xhrType.prototype.open;\n XHRProxy.originalXhrSend = this.providers.xhrType.prototype.send;\n proxyRequests(this.providers, context);\n };\n\n onTrackingStop = () => {\n this.providers.xhrType.prototype.open = XHRProxy.originalXhrOpen;\n this.providers.xhrType.prototype.send = XHRProxy.originalXhrSend;\n };\n}\n\nconst proxyRequests = (\n providers: XHRProxyProviders,\n context: RequestProxyOptions\n): void => {\n proxyOpen(providers, context);\n proxySend(providers);\n};\n\nconst proxyOpen = (\n { xhrType }: XHRProxyProviders,\n context: RequestProxyOptions\n): void => {\n const originalXhrOpen = xhrType.prototype.open;\n const firstPartyHostsRegexMap = context.firstPartyHostsRegexMap;\n const tracingSamplingRate = context.tracingSamplingRate;\n\n xhrType.prototype.open = function (\n this: DdRumXhr,\n method: string,\n url: string\n ) {\n const hostname = URLHostParser(url);\n // Keep track of the method and url\n // start time is tracked by the `send` method\n this._datadog_xhr = {\n method,\n url,\n reported: false,\n timer: new Timer(),\n tracingAttributes: getTracingAttributes({\n hostname,\n firstPartyHostsRegexMap,\n tracingSamplingRate\n })\n };\n // eslint-disable-next-line prefer-rest-params\n return originalXhrOpen.apply(this, arguments as any);\n };\n};\n\nconst proxySend = (providers: XHRProxyProviders): void => {\n const xhrType = providers.xhrType;\n const originalXhrSend = xhrType.prototype.send;\n\n xhrType.prototype.send = function (this: DdRumXhr) {\n if (this._datadog_xhr) {\n // keep track of start time\n this._datadog_xhr.timer.start();\n\n const tracingHeaders = getTracingHeaders(\n this._datadog_xhr.tracingAttributes\n );\n tracingHeaders.forEach(({ header, value }) => {\n this.setRequestHeader(header, value);\n });\n }\n\n proxyOnReadyStateChange(this, providers);\n\n // eslint-disable-next-line prefer-rest-params\n return originalXhrSend.apply(this, arguments as any);\n };\n};\n\nconst proxyOnReadyStateChange = (\n xhrProxy: DdRumXhr,\n providers: XHRProxyProviders\n): void => {\n const xhrType = providers.xhrType;\n const originalOnreadystatechange = xhrProxy.onreadystatechange;\n\n xhrProxy.onreadystatechange = function () {\n if (xhrProxy.readyState === xhrType.DONE) {\n if (!xhrProxy._datadog_xhr.reported) {\n reportXhr(xhrProxy, providers.resourceReporter);\n xhrProxy._datadog_xhr.reported = true;\n }\n } else if (xhrProxy.readyState === xhrType.HEADERS_RECEIVED) {\n xhrProxy._datadog_xhr.timer.recordTick(RESPONSE_START_LABEL);\n }\n\n if (originalOnreadystatechange) {\n // eslint-disable-next-line prefer-rest-params\n originalOnreadystatechange.apply(xhrProxy, arguments as any);\n }\n };\n};\n\nconst reportXhr = async (\n xhrProxy: DdRumXhr,\n resourceReporter: ResourceReporter\n): Promise<void> => {\n const responseSize = calculateResponseSize(xhrProxy);\n\n const context = xhrProxy._datadog_xhr;\n\n const key = `${context.timer.startTime}/${context.method}`;\n\n context.timer.stop();\n\n resourceReporter.reportResource({\n key,\n request: {\n method: context.method,\n url: context.url,\n kind: 'xhr'\n },\n tracingAttributes: context.tracingAttributes,\n response: {\n statusCode: xhrProxy.status,\n size: responseSize\n },\n timings: {\n startTime: context.timer.startTime,\n stopTime: context.timer.stopTime,\n responseStartTime: context.timer.hasTickFor(RESPONSE_START_LABEL)\n ? context.timer.timeAt(RESPONSE_START_LABEL)\n : undefined\n },\n resourceContext: xhrProxy\n });\n};\n"]}
|
package/lib/module/rum/types.js
CHANGED
|
@@ -22,6 +22,13 @@ export let RumActionType;
|
|
|
22
22
|
})(RumActionType || (RumActionType = {}));
|
|
23
23
|
|
|
24
24
|
export let ErrorSource;
|
|
25
|
+
/**
|
|
26
|
+
* Type of instrumentation on the host.
|
|
27
|
+
* - DATADOG: Datadog’s propagator (`x-datadog-*`)
|
|
28
|
+
* - TRACECONTEXT: W3C Trace Context (`traceparent`)
|
|
29
|
+
* - B3: B3 single header (`b3`)
|
|
30
|
+
* - B3MULTI: B3 multiple headers (`X-B3-*`)
|
|
31
|
+
*/
|
|
25
32
|
|
|
26
33
|
(function (ErrorSource) {
|
|
27
34
|
ErrorSource["NETWORK"] = "NETWORK";
|
|
@@ -30,4 +37,13 @@ export let ErrorSource;
|
|
|
30
37
|
ErrorSource["WEBVIEW"] = "WEBVIEW";
|
|
31
38
|
ErrorSource["CUSTOM"] = "CUSTOM";
|
|
32
39
|
})(ErrorSource || (ErrorSource = {}));
|
|
40
|
+
|
|
41
|
+
export let PropagatorType;
|
|
42
|
+
|
|
43
|
+
(function (PropagatorType) {
|
|
44
|
+
PropagatorType["DATADOG"] = "datadog";
|
|
45
|
+
PropagatorType["TRACECONTEXT"] = "tracecontext";
|
|
46
|
+
PropagatorType["B3"] = "b3";
|
|
47
|
+
PropagatorType["B3MULTI"] = "b3multi";
|
|
48
|
+
})(PropagatorType || (PropagatorType = {}));
|
|
33
49
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["types.ts"],"names":["RumActionType","ErrorSource"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AA0IA;AACA;AACA;AACA,WAAYA,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a;;AA0BZ,WAAYC,WAAZ;;
|
|
1
|
+
{"version":3,"sources":["types.ts"],"names":["RumActionType","ErrorSource","PropagatorType"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AA0IA;AACA;AACA;AACA,WAAYA,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a;;AA0BZ,WAAYC,WAAZ;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;WAdYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,W;;AAeZ,WAAYC,cAAZ;;WAAYA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;GAAAA,c,KAAAA,c","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n *\n * Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.\n *\n * @deprecated add the `type` and `name` of the action as first two arguments.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * 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.\n * @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.\n */\n addTiming(name: string): Promise<void>;\n};\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User pressed hardware back button (Android only). */\n BACK = 'BACK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n\nexport type ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\nexport enum ErrorSource {\n NETWORK = 'NETWORK',\n SOURCE = 'SOURCE',\n CONSOLE = 'CONSOLE',\n WEBVIEW = 'WEBVIEW',\n CUSTOM = 'CUSTOM'\n}\n\n/**\n * Type of instrumentation on the host.\n * - DATADOG: Datadog’s propagator (`x-datadog-*`)\n * - TRACECONTEXT: W3C Trace Context (`traceparent`)\n * - B3: B3 single header (`b3`)\n * - B3MULTI: B3 multiple headers (`X-B3-*`)\n */\nexport enum PropagatorType {\n DATADOG = 'datadog',\n TRACECONTEXT = 'tracecontext',\n B3 = 'b3',\n B3MULTI = 'b3multi'\n}\n\nexport type FirstPartyHost = {\n match: string;\n propagatorTypes: PropagatorType[];\n};\n"]}
|
package/lib/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.4.0';\n"]}
|
|
@@ -5,12 +5,20 @@ import type { LogEventMapper } from './logs/types';
|
|
|
5
5
|
import type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';
|
|
6
6
|
import type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';
|
|
7
7
|
import type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';
|
|
8
|
+
import type { FirstPartyHost } from './rum/types';
|
|
8
9
|
export declare enum VitalsUpdateFrequency {
|
|
9
10
|
FREQUENT = "FREQUENT",
|
|
10
11
|
AVERAGE = "AVERAGE",
|
|
11
12
|
RARE = "RARE",
|
|
12
13
|
NEVER = "NEVER"
|
|
13
14
|
}
|
|
15
|
+
export declare type FirstPartyHostsConfiguration = (FirstPartyHost | LegacyFirstPartyHost)[];
|
|
16
|
+
export declare type LegacyFirstPartyHost = string;
|
|
17
|
+
/**
|
|
18
|
+
* Defaults legacy first party hosts format to Datadog first party hosts to keep
|
|
19
|
+
* retro-compatibility before OTel support was introduced.
|
|
20
|
+
*/
|
|
21
|
+
export declare const formatFirstPartyHosts: (firstPartyHosts: FirstPartyHostsConfiguration) => FirstPartyHost[];
|
|
14
22
|
/**
|
|
15
23
|
* The SDK configuration class.
|
|
16
24
|
* It will be used to configure the SDK functionality at initialization.
|
|
@@ -63,7 +71,7 @@ export declare class DdSdkReactNativeConfiguration {
|
|
|
63
71
|
*
|
|
64
72
|
* Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.
|
|
65
73
|
*/
|
|
66
|
-
firstPartyHosts:
|
|
74
|
+
firstPartyHosts: FirstPartyHostsConfiguration;
|
|
67
75
|
/**
|
|
68
76
|
* Overrides the reported version of the app.
|
|
69
77
|
* Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
|
|
@@ -134,7 +142,7 @@ export declare class DdSdkReactNativeConfiguration {
|
|
|
134
142
|
export declare type AutoInstrumentationConfiguration = {
|
|
135
143
|
readonly trackInteractions: boolean;
|
|
136
144
|
readonly trackResources: boolean;
|
|
137
|
-
readonly firstPartyHosts?:
|
|
145
|
+
readonly firstPartyHosts?: FirstPartyHostsConfiguration;
|
|
138
146
|
readonly resourceTracingSamplingRate?: number;
|
|
139
147
|
readonly trackErrors: boolean;
|
|
140
148
|
readonly logEventMapper?: LogEventMapper | null;
|
|
@@ -148,7 +156,7 @@ export declare type AutoInstrumentationConfiguration = {
|
|
|
148
156
|
export declare type AutoInstrumentationParameters = {
|
|
149
157
|
readonly trackInteractions: boolean;
|
|
150
158
|
readonly trackResources: boolean;
|
|
151
|
-
readonly firstPartyHosts:
|
|
159
|
+
readonly firstPartyHosts: FirstPartyHostsConfiguration;
|
|
152
160
|
readonly resourceTracingSamplingRate: number;
|
|
153
161
|
readonly trackErrors: boolean;
|
|
154
162
|
readonly logEventMapper: LogEventMapper | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode } from './DdSdkReactNativeConfiguration';
|
|
1
|
+
import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode, VitalsUpdateFrequency } from './DdSdkReactNativeConfiguration';
|
|
2
2
|
import { DdSdkReactNative } from './DdSdkReactNative';
|
|
3
3
|
import { InternalLog } from './InternalLog';
|
|
4
4
|
import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
|
|
@@ -7,6 +7,6 @@ import { TrackingConsent } from './TrackingConsent';
|
|
|
7
7
|
import { DdTrace } from './foundation';
|
|
8
8
|
import { DdLogs } from './logs/DdLogs';
|
|
9
9
|
import { DdRum } from './rum/DdRum';
|
|
10
|
-
import { RumActionType, ErrorSource } from './rum/types';
|
|
10
|
+
import { RumActionType, ErrorSource, PropagatorType } from './rum/types';
|
|
11
11
|
import { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';
|
|
12
|
-
export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
|
|
12
|
+
export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType };
|
package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class DdRumUserInteractionTracking {
|
|
|
7
7
|
private static eventsInterceptor;
|
|
8
8
|
private static originalCreateElement;
|
|
9
9
|
private static originalMemo;
|
|
10
|
+
private static originalJsx;
|
|
10
11
|
private static patchCreateElementFunction;
|
|
11
12
|
/**
|
|
12
13
|
* Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FirstPartyHost } from '../../types';
|
|
1
2
|
/**
|
|
2
3
|
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
3
4
|
*/
|
|
@@ -9,7 +10,7 @@ export declare class DdRumResourceTracking {
|
|
|
9
10
|
*/
|
|
10
11
|
static startTracking({ tracingSamplingRate, firstPartyHosts }: {
|
|
11
12
|
tracingSamplingRate: number;
|
|
12
|
-
firstPartyHosts:
|
|
13
|
+
firstPartyHosts: FirstPartyHost[];
|
|
13
14
|
}): void;
|
|
14
15
|
static stopTracking(): void;
|
|
15
16
|
}
|
|
@@ -1,19 +1,45 @@
|
|
|
1
|
+
import type { PropagatorType } from '../../../types';
|
|
1
2
|
import type { Hostname } from './firstPartyHosts';
|
|
3
|
+
import type { RegexMap } from './interfaces/RequestProxy';
|
|
2
4
|
export declare type DdRumResourceTracingAttributes = {
|
|
3
5
|
tracingStrategy: 'KEEP';
|
|
4
|
-
traceId:
|
|
5
|
-
spanId:
|
|
6
|
-
samplingPriorityHeader: '1';
|
|
6
|
+
traceId: TraceId;
|
|
7
|
+
spanId: SpanId;
|
|
8
|
+
samplingPriorityHeader: '1' | '0';
|
|
7
9
|
rulePsr: number;
|
|
10
|
+
propagatorTypes: PropagatorType[];
|
|
8
11
|
} | {
|
|
9
12
|
tracingStrategy: 'DISCARD';
|
|
10
13
|
traceId?: void;
|
|
11
14
|
spanId?: void;
|
|
12
15
|
samplingPriorityHeader: '0';
|
|
13
16
|
};
|
|
14
|
-
export declare const getTracingAttributes: ({ hostname,
|
|
17
|
+
export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegexMap, tracingSamplingRate }: {
|
|
15
18
|
hostname: Hostname | null;
|
|
16
|
-
|
|
19
|
+
firstPartyHostsRegexMap: RegexMap;
|
|
17
20
|
tracingSamplingRate: number;
|
|
18
21
|
}) => DdRumResourceTracingAttributes;
|
|
19
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Using branded types will ensure we don't accidentally use
|
|
24
|
+
* traceId for spanId when generating headers.
|
|
25
|
+
*/
|
|
26
|
+
export declare type TraceId = TraceIdentifier & {
|
|
27
|
+
_brand: 'traceId';
|
|
28
|
+
};
|
|
29
|
+
export declare type SpanId = TraceIdentifier & {
|
|
30
|
+
_brand: 'spanId';
|
|
31
|
+
};
|
|
32
|
+
export declare class TraceIdentifier {
|
|
33
|
+
private low;
|
|
34
|
+
private high;
|
|
35
|
+
constructor();
|
|
36
|
+
toString: (radix: number) => string;
|
|
37
|
+
/**
|
|
38
|
+
* This function pads the trace with `0`.
|
|
39
|
+
* It should not be used with a `length` lower than the trace, as we return the full trace in this case.
|
|
40
|
+
* @param radix radix for the trace
|
|
41
|
+
* @param length minimum length
|
|
42
|
+
* @returns padded string
|
|
43
|
+
*/
|
|
44
|
+
toPaddedString: (radix: number, length: number) => string;
|
|
45
|
+
}
|
package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DdRumResourceTracingAttributes } from './distributedTracing';
|
|
2
|
+
export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
|
|
3
|
+
/**
|
|
4
|
+
* Datadog headers
|
|
5
|
+
*/
|
|
6
|
+
export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
|
|
7
|
+
export declare const ORIGIN_RUM = "rum";
|
|
8
|
+
export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
|
|
9
|
+
export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
|
|
10
|
+
/**
|
|
11
|
+
* OTel headers
|
|
12
|
+
*/
|
|
13
|
+
export declare const TRACECONTEXT_HEADER_KEY = "traceparent";
|
|
14
|
+
export declare const B3_HEADER_KEY = "b3";
|
|
15
|
+
export declare const B3_MULTI_TRACE_ID_HEADER_KEY = "X-B3-TraceId";
|
|
16
|
+
export declare const B3_MULTI_SPAN_ID_HEADER_KEY = "X-B3-SpanId";
|
|
17
|
+
export declare const B3_MULTI_SAMPLED_HEADER_KEY = "X-B3-Sampled";
|
|
18
|
+
export declare const getTracingHeaders: (tracingAttributes: DdRumResourceTracingAttributes) => {
|
|
19
|
+
header: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|