@datadog/mobile-react-native 2.3.6 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +7 -7
- package/android/build.gradle +4 -4
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +2 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +15 -0
- package/android/src/test/resources/input/complete-configuration.json +5 -1
- package/datadog-configuration.schema.json +54 -9
- package/ios/Sources/DatadogSDKWrapper.swift +3 -3
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +6 -12
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +7 -4
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +2 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/polyfills.js +31 -0
- package/lib/commonjs/polyfills.js.map +1 -0
- package/lib/commonjs/rum/DdRum.js +3 -3
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +14 -9
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -6
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +182 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +10 -57
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +18 -10
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +4 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/commonjs/sdk/GlobalState/GlobalState.js +38 -0
- package/lib/commonjs/sdk/GlobalState/GlobalState.js.map +1 -0
- package/lib/commonjs/specs/NativeDdLogs.js +1 -0
- package/lib/commonjs/specs/NativeDdLogs.js.map +1 -1
- package/lib/commonjs/specs/NativeDdRum.js +1 -0
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
- package/lib/commonjs/specs/NativeDdSdk.js +1 -0
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
- package/lib/commonjs/specs/NativeDdTrace.js +1 -0
- package/lib/commonjs/specs/NativeDdTrace.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +5 -12
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +7 -4
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/polyfills.js +28 -0
- package/lib/module/polyfills.js.map +1 -0
- package/lib/module/rum/DdRum.js +2 -2
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +14 -9
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -6
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +169 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +3 -54
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +13 -8
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +3 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/sdk/GlobalState/GlobalState.js +29 -0
- package/lib/module/sdk/GlobalState/GlobalState.js.map +1 -0
- package/lib/module/specs/NativeDdLogs.js +1 -0
- package/lib/module/specs/NativeDdLogs.js.map +1 -1
- package/lib/module/specs/NativeDdRum.js +1 -0
- package/lib/module/specs/NativeDdRum.js.map +1 -1
- package/lib/module/specs/NativeDdSdk.js +1 -0
- package/lib/module/specs/NativeDdSdk.js.map +1 -1
- package/lib/module/specs/NativeDdTrace.js +1 -0
- package/lib/module/specs/NativeDdTrace.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +0 -5
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +5 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +12 -3
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +2 -3
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts +111 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +1 -24
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +2 -0
- package/lib/typescript/sdk/GlobalState/GlobalState.d.ts +12 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +7 -11
- package/src/DdSdkReactNativeConfiguration.tsx +10 -4
- package/src/__tests__/DdSdkReactNative.test.tsx +3 -2
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -2
- package/src/__tests__/mock.test.ts +0 -1
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +32 -0
- package/src/index.tsx +4 -0
- package/src/polyfills.js +37 -0
- package/src/rum/DdRum.ts +2 -2
- package/src/rum/__tests__/DdRum.test.ts +3 -3
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +23 -7
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +3 -4
- package/src/rum/instrumentation/resourceTracking/__tests__/__utils__/XMLHttpRequestMock.ts +1 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.tsx +227 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/__utils__/TracingIdentifierUtils.ts +64 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +314 -42
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +4 -59
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +33 -19
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.ts +7 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +134 -11
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +2 -2
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +3 -2
- package/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +3 -0
- package/src/sdk/GlobalState/GlobalState.tsx +26 -0
- package/src/specs/NativeDdLogs.ts +1 -0
- package/src/specs/NativeDdRum.ts +1 -0
- package/src/specs/NativeDdSdk.ts +1 -0
- package/src/specs/NativeDdTrace.ts +1 -0
- package/src/version.ts +1 -1
package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js
CHANGED
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getTracingAttributes = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _TracingIdentifier = require("./TracingIdentifier");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var _firstPartyHosts = require("./firstPartyHosts");
|
|
11
11
|
|
|
12
|
+
/*
|
|
13
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
14
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
15
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
16
|
+
*/
|
|
12
17
|
const DISCARDED_TRACE_ATTRIBUTES = {
|
|
13
18
|
samplingPriorityHeader: '0',
|
|
14
19
|
tracingStrategy: 'DISCARD'
|
|
@@ -37,8 +42,8 @@ exports.getTracingAttributes = getTracingAttributes;
|
|
|
37
42
|
const generateTracingAttributesWithSampling = (tracingSamplingRate, propagatorTypes) => {
|
|
38
43
|
const isSampled = Math.random() * 100 <= tracingSamplingRate;
|
|
39
44
|
const tracingAttributes = {
|
|
40
|
-
traceId:
|
|
41
|
-
spanId:
|
|
45
|
+
traceId: _TracingIdentifier.TracingIdentifier.createTraceId(),
|
|
46
|
+
spanId: _TracingIdentifier.TracingIdentifier.createSpanId(),
|
|
42
47
|
samplingPriorityHeader: isSampled ? '1' : '0',
|
|
43
48
|
tracingStrategy: 'KEEP',
|
|
44
49
|
rulePsr: tracingSamplingRate / 100,
|
|
@@ -46,56 +51,4 @@ const generateTracingAttributesWithSampling = (tracingSamplingRate, propagatorTy
|
|
|
46
51
|
};
|
|
47
52
|
return tracingAttributes;
|
|
48
53
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Using branded types will ensure we don't accidentally use
|
|
51
|
-
* traceId for spanId when generating headers.
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/*
|
|
56
|
-
* This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/0e9722d5b06f6d49264bc82cd254a207d647d66c/packages/rum-core/src/domain/tracing/tracer.ts#L190)
|
|
57
|
-
*/
|
|
58
|
-
const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1
|
|
59
|
-
|
|
60
|
-
const MAX_31_BITS_NUMBER = 2147483647; // 2^31-1
|
|
61
|
-
|
|
62
|
-
class TraceIdentifier {
|
|
63
|
-
constructor() {
|
|
64
|
-
_defineProperty(this, "low", void 0);
|
|
65
|
-
|
|
66
|
-
_defineProperty(this, "high", void 0);
|
|
67
|
-
|
|
68
|
-
_defineProperty(this, "toString", radix => {
|
|
69
|
-
let low = this.low;
|
|
70
|
-
let high = this.high;
|
|
71
|
-
let str = '';
|
|
72
|
-
|
|
73
|
-
while (high > 0 || low > 0) {
|
|
74
|
-
const mod = high % radix * (MAX_32_BITS_NUMBER + 1) + low;
|
|
75
|
-
high = Math.floor(high / radix);
|
|
76
|
-
low = Math.floor(mod / radix);
|
|
77
|
-
str = (mod % radix).toString(radix) + str;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return str;
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
_defineProperty(this, "toPaddedString", (radix, length) => {
|
|
84
|
-
const traceId = this.toString(radix);
|
|
85
|
-
|
|
86
|
-
if (traceId.length > length) {
|
|
87
|
-
return traceId;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return Array(length - traceId.length + 1).join('0') + traceId;
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// We need to have a 63 bits number max
|
|
94
|
-
this.high = Math.floor(Math.random() * MAX_31_BITS_NUMBER);
|
|
95
|
-
this.low = Math.floor(Math.random() * MAX_32_BITS_NUMBER);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
exports.TraceIdentifier = TraceIdentifier;
|
|
101
54
|
//# sourceMappingURL=distributedTracing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["distributedTracing.tsx"],"names":["DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegexMap","tracingSamplingRate","propagatorsForHost","generateTracingAttributesWithSampling","propagatorTypes","isSampled","Math","random","tracingAttributes","traceId","
|
|
1
|
+
{"version":3,"sources":["distributedTracing.tsx"],"names":["DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegexMap","tracingSamplingRate","propagatorsForHost","generateTracingAttributesWithSampling","propagatorTypes","isSampled","Math","random","tracingAttributes","traceId","TracingIdentifier","createTraceId","spanId","createSpanId","rulePsr"],"mappings":";;;;;;;AASA;;AAGA;;AAZA;AACA;AACA;AACA;AACA;AA0BA,MAAMA,0BAA0D,GAAG;AAC/DC,EAAAA,sBAAsB,EAAE,GADuC;AAE/DC,EAAAA,eAAe,EAAE;AAF8C,CAAnE;;AAKO,MAAMC,oBAAoB,GAAG,CAAC;AACjCC,EAAAA,QADiC;AAEjCC,EAAAA,uBAFiC;AAGjCC,EAAAA;AAHiC,CAAD,KAQE;AAClC,MAAIF,QAAQ,KAAK,IAAjB,EAAuB;AACnB,WAAOJ,0BAAP;AACH;;AACD,QAAMO,kBAAkB,GAAG,4CACvBH,QADuB,EAEvBC,uBAFuB,CAA3B;;AAIA,MAAIE,kBAAJ,EAAwB;AACpB,WAAOC,qCAAqC,CACxCF,mBADwC,EAExCC,kBAFwC,CAA5C;AAIH;;AACD,SAAOP,0BAAP;AACH,CAvBM;;;;AAyBP,MAAMQ,qCAAqC,GAAG,CAC1CF,mBAD0C,EAE1CG,eAF0C,KAGT;AACjC,QAAMC,SAAS,GAAGC,IAAI,CAACC,MAAL,KAAgB,GAAhB,IAAuBN,mBAAzC;AACA,QAAMO,iBAAiD,GAAG;AACtDC,IAAAA,OAAO,EAAEC,qCAAkBC,aAAlB,EAD6C;AAEtDC,IAAAA,MAAM,EAAEF,qCAAkBG,YAAlB,EAF8C;AAGtDjB,IAAAA,sBAAsB,EAAES,SAAS,GAAG,GAAH,GAAS,GAHY;AAItDR,IAAAA,eAAe,EAAE,MAJqC;AAKtDiB,IAAAA,OAAO,EAAEb,mBAAmB,GAAG,GALuB;AAMtDG,IAAAA;AANsD,GAA1D;AASA,SAAOI,iBAAP;AACH,CAfD","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';\nimport type { RegexMap } from '../requestProxy/interfaces/RequestProxy';\n\nimport { TracingIdentifier } from './TracingIdentifier';\nimport type { SpanId, TraceId } from './TracingIdentifier';\nimport type { Hostname } from './firstPartyHosts';\nimport { getPropagatorsForHost } from './firstPartyHosts';\n\nexport type DdRumResourceTracingAttributes =\n | {\n tracingStrategy: 'KEEP';\n traceId: TraceId;\n spanId: SpanId;\n samplingPriorityHeader: '1' | '0';\n rulePsr: number;\n propagatorTypes: PropagatorType[];\n }\n | {\n tracingStrategy: 'DISCARD';\n traceId?: void;\n spanId?: void;\n samplingPriorityHeader: '0';\n };\n\nconst DISCARDED_TRACE_ATTRIBUTES: DdRumResourceTracingAttributes = {\n samplingPriorityHeader: '0',\n tracingStrategy: 'DISCARD'\n};\n\nexport const getTracingAttributes = ({\n hostname,\n firstPartyHostsRegexMap,\n tracingSamplingRate\n}: {\n hostname: Hostname | null;\n firstPartyHostsRegexMap: RegexMap;\n tracingSamplingRate: number;\n}): DdRumResourceTracingAttributes => {\n if (hostname === null) {\n return DISCARDED_TRACE_ATTRIBUTES;\n }\n const propagatorsForHost = getPropagatorsForHost(\n hostname,\n firstPartyHostsRegexMap\n );\n if (propagatorsForHost) {\n return generateTracingAttributesWithSampling(\n tracingSamplingRate,\n propagatorsForHost\n );\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\nconst generateTracingAttributesWithSampling = (\n tracingSamplingRate: number,\n propagatorTypes: PropagatorType[]\n): DdRumResourceTracingAttributes => {\n const isSampled = Math.random() * 100 <= tracingSamplingRate;\n const tracingAttributes: DdRumResourceTracingAttributes = {\n traceId: TracingIdentifier.createTraceId(),\n spanId: TracingIdentifier.createSpanId(),\n samplingPriorityHeader: isSampled ? '1' : '0',\n tracingStrategy: 'KEEP',\n rulePsr: tracingSamplingRate / 100,\n propagatorTypes\n };\n\n return tracingAttributes;\n};\n"]}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getTracingHeaders = exports.B3_MULTI_SAMPLED_HEADER_KEY = exports.B3_MULTI_SPAN_ID_HEADER_KEY = exports.B3_MULTI_TRACE_ID_HEADER_KEY = exports.B3_HEADER_KEY = exports.TRACESTATE_HEADER_KEY = exports.TRACECONTEXT_HEADER_KEY = exports.PARENT_ID_HEADER_KEY = exports.TRACE_ID_HEADER_KEY = exports.ORIGIN_RUM = exports.ORIGIN_HEADER_KEY = exports.SAMPLING_PRIORITY_HEADER_KEY = void 0;
|
|
6
|
+
exports.getTracingHeaders = exports.B3_MULTI_SAMPLED_HEADER_KEY = exports.B3_MULTI_SPAN_ID_HEADER_KEY = exports.B3_MULTI_TRACE_ID_HEADER_KEY = exports.B3_HEADER_KEY = exports.TRACESTATE_HEADER_KEY = exports.TRACECONTEXT_HEADER_KEY = exports.DD_TRACE_ID_TAG = exports.TAGS_HEADER_KEY = exports.PARENT_ID_HEADER_KEY = exports.TRACE_ID_HEADER_KEY = exports.ORIGIN_RUM = exports.ORIGIN_HEADER_KEY = exports.SAMPLING_PRIORITY_HEADER_KEY = void 0;
|
|
7
7
|
|
|
8
8
|
var _types = require("../../../types");
|
|
9
9
|
|
|
10
|
+
var _TracingIdentifier = require("./TracingIdentifier");
|
|
11
|
+
|
|
10
12
|
/*
|
|
11
13
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
14
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
@@ -25,11 +27,15 @@ exports.ORIGIN_RUM = ORIGIN_RUM;
|
|
|
25
27
|
const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
|
|
26
28
|
exports.TRACE_ID_HEADER_KEY = TRACE_ID_HEADER_KEY;
|
|
27
29
|
const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
|
|
30
|
+
exports.PARENT_ID_HEADER_KEY = PARENT_ID_HEADER_KEY;
|
|
31
|
+
const TAGS_HEADER_KEY = 'x-datadog-tags';
|
|
32
|
+
exports.TAGS_HEADER_KEY = TAGS_HEADER_KEY;
|
|
33
|
+
const DD_TRACE_ID_TAG = '_dd.p.tid';
|
|
28
34
|
/**
|
|
29
35
|
* OTel headers
|
|
30
36
|
*/
|
|
31
37
|
|
|
32
|
-
exports.
|
|
38
|
+
exports.DD_TRACE_ID_TAG = DD_TRACE_ID_TAG;
|
|
33
39
|
const TRACECONTEXT_HEADER_KEY = 'traceparent';
|
|
34
40
|
exports.TRACECONTEXT_HEADER_KEY = TRACECONTEXT_HEADER_KEY;
|
|
35
41
|
const TRACESTATE_HEADER_KEY = 'tracestate';
|
|
@@ -62,10 +68,13 @@ const getTracingHeaders = tracingAttributes => {
|
|
|
62
68
|
value: tracingAttributes.samplingPriorityHeader
|
|
63
69
|
}, {
|
|
64
70
|
header: TRACE_ID_HEADER_KEY,
|
|
65
|
-
value: tracingAttributes.traceId.toString(
|
|
71
|
+
value: tracingAttributes.traceId.toString(_TracingIdentifier.TracingIdFormat.lowDecimal)
|
|
66
72
|
}, {
|
|
67
73
|
header: PARENT_ID_HEADER_KEY,
|
|
68
|
-
value: tracingAttributes.spanId.toString(
|
|
74
|
+
value: tracingAttributes.spanId.toString(_TracingIdentifier.TracingIdFormat.decimal)
|
|
75
|
+
}, {
|
|
76
|
+
header: TAGS_HEADER_KEY,
|
|
77
|
+
value: `${DD_TRACE_ID_TAG}=${tracingAttributes.traceId.toString(_TracingIdentifier.TracingIdFormat.paddedHighHex)}`
|
|
69
78
|
});
|
|
70
79
|
break;
|
|
71
80
|
}
|
|
@@ -107,10 +116,10 @@ const getTracingHeaders = tracingAttributes => {
|
|
|
107
116
|
{
|
|
108
117
|
headers.push({
|
|
109
118
|
header: B3_MULTI_TRACE_ID_HEADER_KEY,
|
|
110
|
-
value: tracingAttributes.traceId.
|
|
119
|
+
value: tracingAttributes.traceId.toString(_TracingIdentifier.TracingIdFormat.paddedHex)
|
|
111
120
|
}, {
|
|
112
121
|
header: B3_MULTI_SPAN_ID_HEADER_KEY,
|
|
113
|
-
value: tracingAttributes.spanId.
|
|
122
|
+
value: tracingAttributes.spanId.toString(_TracingIdentifier.TracingIdFormat.paddedHex)
|
|
114
123
|
}, {
|
|
115
124
|
header: B3_MULTI_SAMPLED_HEADER_KEY,
|
|
116
125
|
value: tracingAttributes.samplingPriorityHeader
|
|
@@ -130,7 +139,7 @@ const generateTraceContextHeader = ({
|
|
|
130
139
|
isSampled
|
|
131
140
|
}) => {
|
|
132
141
|
const flags = isSampled ? '01' : '00';
|
|
133
|
-
return `${version}-${traceId.
|
|
142
|
+
return `${version}-${traceId.toString(_TracingIdentifier.TracingIdFormat.paddedHex)}-${parentId.toString(_TracingIdentifier.TracingIdFormat.paddedHex)}-${flags}`;
|
|
134
143
|
};
|
|
135
144
|
|
|
136
145
|
const generateTraceStateHeader = ({
|
|
@@ -139,7 +148,7 @@ const generateTraceStateHeader = ({
|
|
|
139
148
|
}) => {
|
|
140
149
|
const sampled = `s:${isSampled ? '1' : '0'}`;
|
|
141
150
|
const origin = 'o:rum';
|
|
142
|
-
const parent = `p:${parentId.
|
|
151
|
+
const parent = `p:${parentId.toString(_TracingIdentifier.TracingIdFormat.paddedHex)}`;
|
|
143
152
|
return `dd=${sampled};${origin};${parent}`;
|
|
144
153
|
};
|
|
145
154
|
|
|
@@ -148,7 +157,6 @@ const generateB3Header = ({
|
|
|
148
157
|
spanId,
|
|
149
158
|
isSampled
|
|
150
159
|
}) => {
|
|
151
|
-
|
|
152
|
-
return `${traceId.toPaddedString(16, 32)}-${spanId.toPaddedString(16, 16)}-${flags}`;
|
|
160
|
+
return [traceId.toString(_TracingIdentifier.TracingIdFormat.paddedHex), spanId.toString(_TracingIdentifier.TracingIdFormat.paddedHex), isSampled ? '1' : '0'].join('-');
|
|
153
161
|
};
|
|
154
162
|
//# sourceMappingURL=distributedTracingHeaders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["distributedTracingHeaders.ts"],"names":["SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_HEADER_KEY","ORIGIN_RUM","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","TRACECONTEXT_HEADER_KEY","TRACESTATE_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","PropagatorType","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","spanId","TRACECONTEXT","generateTraceContextHeader","version","parentId","isSampled","generateTraceStateHeader","B3","generateB3Header","B3MULTI","toPaddedString","flags","sampled","origin","parent"],"mappings":";;;;;;;AAMA;;AANA;AACA;AACA;AACA;AACA;AAUO,MAAMA,4BAA4B,GAAG,6BAArC;AACP;AACA;AACA;;;AACO,MAAMC,iBAAiB,GAAG,kBAA1B;;AACA,MAAMC,UA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F7B,WATJ;AAcH;AAxEL;AA0EH,GA3ED;AA6EA,SAAOV,OAAP;AACH,CArFM;;;;AAuFP,MAAMe,0BAA0B,GAAG,CAAC;AAChCC,EAAAA,OADgC;AAEhCL,EAAAA,OAFgC;AAGhCM,EAAAA,QAHgC;AAIhCC,EAAAA;AAJgC,CAAD,KAU7B;AACF,QAAMM,KAAK,GAAGN,SAAS,GAAG,IAAH,GAAU,IAAjC;AACA,SAAQ,GAAEF,OAAQ,IAAGL,OAAO,CAACY,cAAR,CACjB,EADiB,EAEjB,EAFiB,CAGnB,IAAGN,QAAQ,CAACM,cAAT,CAAwB,EAAxB,EAA4B,EAA5B,CAAgC,IAAGC,KAAM,EAH9C;AAIH,CAhBD;;AAkBA,MAAML,wBAAwB,GAAG,CAAC;AAC9BF,EAAAA,QAD8B;AAE9BC,EAAAA;AAF8B,CAAD,KAM3B;AACF,QAAMO,OAAO,GAAI,KAAIP,SAAS,GAAG,GAAH,GAAS,GAAI,EAA3C;AACA,QAAMQ,MAAM,GAAG,OAAf;AACA,QAAMC,MAAM,GAAI,KAAIV,QAAQ,CAACM,cAAT,CAAwB,EAAxB,EAA4B,EAA5B,CAAgC,EAApD;AAEA,SAAQ,MAAKE,OAAQ,IAAGC,MAAO,IAAGC,MAAO,EAAzC;AACH,CAZD;;AAcA,MAAMN,gBAAgB,GAAG,CAAC;AACtBV,EAAAA,OADsB;AAEtBE,EAAAA,MAFsB;AAGtBK,EAAAA;AAHsB,CAAD,KAQnB;AACF,QAAMM,KAAK,GAAGN,SAAS,GAAG,GAAH,GAAS,GAAhC;AACA,SAAQ,GAAEP,OAAO,CAACY,cAAR,CAAuB,EAAvB,EAA2B,EAA3B,CAA+B,IAAGV,MAAM,CAACU,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 TRACESTATE_HEADER_KEY = 'tracestate';\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 {\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 {\n header: TRACESTATE_HEADER_KEY,\n value: generateTraceStateHeader({\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\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 generateTraceStateHeader = ({\n parentId,\n isSampled\n}: {\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const sampled = `s:${isSampled ? '1' : '0'}`;\n const origin = 'o:rum';\n const parent = `p:${parentId.toPaddedString(16, 16)}`;\n\n return `dd=${sampled};${origin};${parent}`;\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"]}
|
|
1
|
+
{"version":3,"sources":["distributedTracingHeaders.ts"],"names":["SAMPLING_PRIORITY_HEADER_KEY","ORIGIN_HEADER_KEY","ORIGIN_RUM","TRACE_ID_HEADER_KEY","PARENT_ID_HEADER_KEY","TAGS_HEADER_KEY","DD_TRACE_ID_TAG","TRACECONTEXT_HEADER_KEY","TRACESTATE_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","PropagatorType","DATADOG","push","header","value","samplingPriorityHeader","traceId","toString","TracingIdFormat","lowDecimal","spanId","decimal","paddedHighHex","TRACECONTEXT","generateTraceContextHeader","version","parentId","isSampled","generateTraceStateHeader","B3","generateB3Header","B3MULTI","paddedHex","flags","sampled","origin","parent","join"],"mappings":";;;;;;;AAMA;;AAEA;;AARA;AACA;AACA;AACA;AACA;AAQO,MAAMA,4BAA4B,GAAG,6BAArC;AACP;AACA;AACA;;;AACO,MAAMC,iBAAiB,GAAG,kBAA1B;;AACA,MAAMC,UAAU,GAAG,KAAnB;;AACA,MAAMC,mBAAmB,GAAG,oBAA5B;;AACA,MAAMC,oBAAoB,GAAG,qBAA7B;;AACA,MAAMC,eAAe,GAAG,gBAAxB;;AACA,MAAMC,eAAe,GAAG,WAAxB;AAEP;AACA;AACA;;;AACO,MAAMC,uBAAuB,GAAG,aAAhC;;AACA,MAAMC,qBAAqB,GAAG,YAA9B;;AACA,MAAMC,aAAa,GAAG,IAAtB;;AACA,MAAMC,4BAA4B,GAAG,cAArC;;AACA,MAAMC,2BAA2B,GAAG,aAApC;;AACA,MAAMC,2BAA2B,GAAG,cAApC;;;AAEA,MAAMC,iBAAiB,GAC1BC,iBAD6B,IAES;AACtC,QAAMC,OAA4C,GAAG,EAArD;;AACA,MAAID,iBAAiB,CAACE,eAAlB,KAAsC,SAA1C,EAAqD;AACjD,WAAOD,OAAP;AACH;;AACDD,EAAAA,iBAAiB,CAACG,eAAlB,CAAkCC,OAAlC,CAA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,SADC,CAEnB,IAAGN,QAAQ,CAACT,QAAT,CAAkBC,mCAAgBc,SAAlC,CAA6C,IAAGC,KAAM,EAF3D;AAGH,CAfD;;AAiBA,MAAML,wBAAwB,GAAG,CAAC;AAC9BF,EAAAA,QAD8B;AAE9BC,EAAAA;AAF8B,CAAD,KAM3B;AACF,QAAMO,OAAO,GAAI,KAAIP,SAAS,GAAG,GAAH,GAAS,GAAI,EAA3C;AACA,QAAMQ,MAAM,GAAG,OAAf;AACA,QAAMC,MAAM,GAAI,KAAIV,QAAQ,CAACT,QAAT,CAAkBC,mCAAgBc,SAAlC,CAA6C,EAAjE;AAEA,SAAQ,MAAKE,OAAQ,IAAGC,MAAO,IAAGC,MAAO,EAAzC;AACH,CAZD;;AAcA,MAAMN,gBAAgB,GAAG,CAAC;AACtBd,EAAAA,OADsB;AAEtBI,EAAAA,MAFsB;AAGtBO,EAAAA;AAHsB,CAAD,KAQnB;AACF,SAAO,CACHX,OAAO,CAACC,QAAR,CAAiBC,mCAAgBc,SAAjC,CADG,EAEHZ,MAAM,CAACH,QAAP,CAAgBC,mCAAgBc,SAAhC,CAFG,EAGHL,SAAS,GAAG,GAAH,GAAS,GAHf,EAILU,IAJK,CAIA,GAJA,CAAP;AAKH,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 { TracingIdFormat } from './TracingIdentifier';\nimport type { TraceId, SpanId } from './TracingIdentifier';\nimport type { DdRumResourceTracingAttributes } 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';\nexport const TAGS_HEADER_KEY = 'x-datadog-tags';\nexport const DD_TRACE_ID_TAG = '_dd.p.tid';\n\n/**\n * OTel headers\n */\nexport const TRACECONTEXT_HEADER_KEY = 'traceparent';\nexport const TRACESTATE_HEADER_KEY = 'tracestate';\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(\n TracingIdFormat.lowDecimal\n )\n },\n {\n header: PARENT_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toString(\n TracingIdFormat.decimal\n )\n },\n {\n header: TAGS_HEADER_KEY,\n value: `${DD_TRACE_ID_TAG}=${tracingAttributes.traceId.toString(\n TracingIdFormat.paddedHighHex\n )}`\n }\n );\n break;\n }\n case PropagatorType.TRACECONTEXT: {\n headers.push(\n {\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 {\n header: TRACESTATE_HEADER_KEY,\n value: generateTraceStateHeader({\n parentId: tracingAttributes.spanId,\n isSampled:\n tracingAttributes.samplingPriorityHeader === '1'\n })\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.toString(\n TracingIdFormat.paddedHex\n )\n },\n {\n header: B3_MULTI_SPAN_ID_HEADER_KEY,\n value: tracingAttributes.spanId.toString(\n TracingIdFormat.paddedHex\n )\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.toString(\n TracingIdFormat.paddedHex\n )}-${parentId.toString(TracingIdFormat.paddedHex)}-${flags}`;\n};\n\nconst generateTraceStateHeader = ({\n parentId,\n isSampled\n}: {\n parentId: SpanId;\n isSampled: boolean;\n}) => {\n const sampled = `s:${isSampled ? '1' : '0'}`;\n const origin = 'o:rum';\n const parent = `p:${parentId.toString(TracingIdFormat.paddedHex)}`;\n\n return `dd=${sampled};${origin};${parent}`;\n};\n\nconst generateB3Header = ({\n traceId,\n spanId,\n isSampled\n}: {\n traceId: TraceId;\n spanId: SpanId;\n isSampled: boolean;\n}) => {\n return [\n traceId.toString(TracingIdFormat.paddedHex),\n spanId.toString(TracingIdFormat.paddedHex),\n isSampled ? '1' : '0'\n ].join('-');\n};\n"]}
|
|
@@ -7,6 +7,8 @@ exports.ResourceReporter = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _DdRum = require("../../../../../DdRum");
|
|
9
9
|
|
|
10
|
+
var _TracingIdentifier = require("../../../distributedTracing/TracingIdentifier");
|
|
11
|
+
|
|
10
12
|
var _resourceTiming = require("./resourceTiming");
|
|
11
13
|
|
|
12
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -40,8 +42,8 @@ const formatResourceStartContext = tracingAttributes => {
|
|
|
40
42
|
const attributes = {};
|
|
41
43
|
|
|
42
44
|
if (tracingAttributes.samplingPriorityHeader !== '0') {
|
|
43
|
-
attributes['_dd.span_id'] = tracingAttributes.spanId.toString(
|
|
44
|
-
attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(
|
|
45
|
+
attributes['_dd.span_id'] = tracingAttributes.spanId.toString(_TracingIdentifier.TracingIdFormat.decimal);
|
|
46
|
+
attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(_TracingIdentifier.TracingIdFormat.paddedHex);
|
|
45
47
|
attributes['_dd.rule_psr'] = tracingAttributes.rulePsr;
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ResourceReporter.ts"],"names":["ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","attributes","samplingPriorityHeader","spanId","toString","traceId","rulePsr","formatResourceStopContext","timings","graphqlAttributes","responseStartTime","undefined","startTime","stopTime","operationType","operationName","variables","DdRum","startResource","key","request","method","url","stopResource","response","statusCode","kind","size","resourceContext"],"mappings":";;;;;;;AAMA;;AAGA;;;;AAIO,MAAMA,gBAAN,CAAuB;AAG1BC,EAAAA,WAAW,CAACC,eAAD,EAAoC;AAAA;;AAAA,4CAI7BC,QAAD,IAA2B;AACxC,UAAIC,gBAAoC,GAAGD,QAA3C;;AAEA,WAAK,MAAME,MAAX,IAAqB,KAAKC,OAA1B,EAAmC;AAC/BF,QAAAA,gBAAgB,GAAGC,MAAM,CAACF,QAAD,CAAzB;;AACA,YAAIC,gBAAgB,KAAK,IAAzB,EAA+B;AAC3B;AACH;AACJ;;AAEDG,MAAAA,cAAc,CAACH,gBAAD,CAAd;AACH,KAf8C;;AAC3C,SAAKE,OAAL,GAAeJ,eAAf;AACH;;AALyB;;;;AAqB9B,MAAMM,0BAA0B,GAC5BC,iBAD+B,IAEG;AAClC,QAAMC,UAA2C,GAAG,EAApD;;AACA,MAAID,iBAAiB,CAACE,sBAAlB,KAA6C,GAAjD,EAAsD;AAClDD,IAAAA,UAAU,CAAC,aAAD,CAAV,GAA4BD,iBAAiB,CAACG,MAAlB,CAAyBC,QAAzB,
|
|
1
|
+
{"version":3,"sources":["ResourceReporter.ts"],"names":["ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","attributes","samplingPriorityHeader","spanId","toString","TracingIdFormat","decimal","traceId","paddedHex","rulePsr","formatResourceStopContext","timings","graphqlAttributes","responseStartTime","undefined","startTime","stopTime","operationType","operationName","variables","DdRum","startResource","key","request","method","url","stopResource","response","statusCode","kind","size","resourceContext"],"mappings":";;;;;;;AAMA;;AACA;;AAGA;;;;AAIO,MAAMA,gBAAN,CAAuB;AAG1BC,EAAAA,WAAW,CAACC,eAAD,EAAoC;AAAA;;AAAA,4CAI7BC,QAAD,IAA2B;AACxC,UAAIC,gBAAoC,GAAGD,QAA3C;;AAEA,WAAK,MAAME,MAAX,IAAqB,KAAKC,OAA1B,EAAmC;AAC/BF,QAAAA,gBAAgB,GAAGC,MAAM,CAACF,QAAD,CAAzB;;AACA,YAAIC,gBAAgB,KAAK,IAAzB,EAA+B;AAC3B;AACH;AACJ;;AAEDG,MAAAA,cAAc,CAACH,gBAAD,CAAd;AACH,KAf8C;;AAC3C,SAAKE,OAAL,GAAeJ,eAAf;AACH;;AALyB;;;;AAqB9B,MAAMM,0BAA0B,GAC5BC,iBAD+B,IAEG;AAClC,QAAMC,UAA2C,GAAG,EAApD;;AACA,MAAID,iBAAiB,CAACE,sBAAlB,K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AQ,CAAC6B,OAAT,CAAiBE,GAHf,EAIF1B,0BAA0B,CAACL,QAAQ,CAACM,iBAAV,CAJxB,EAKFN,QAAQ,CAACiB,OAAT,CAAiBI,SALf,CAAN;;AAQAK,eAAMM,YAAN,CACIhC,QAAQ,CAAC4B,GADb,EAEI5B,QAAQ,CAACiC,QAAT,CAAkBC,UAFtB,EAGIlC,QAAQ,CAAC6B,OAAT,CAAiBM,IAHrB,EAIInC,QAAQ,CAACiC,QAAT,CAAkBG,IAJtB,EAKIpB,yBAAyB,CAAChB,QAAQ,CAACiB,OAAV,EAAmBjB,QAAQ,CAACkB,iBAA5B,CAL7B,EAMIlB,QAAQ,CAACiB,OAAT,CAAiBK,QANrB,EAOItB,QAAQ,CAACqC,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 { TracingIdFormat } from '../../../distributedTracing/TracingIdentifier';\nimport type { RUMResource } from '../../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> => {\n const attributes: Record<string, string | number> = {};\n if (tracingAttributes.samplingPriorityHeader !== '0') {\n attributes['_dd.span_id'] = tracingAttributes.spanId.toString(\n TracingIdFormat.decimal\n );\n attributes['_dd.trace_id'] = tracingAttributes.traceId.toString(\n TracingIdFormat.paddedHex\n );\n attributes['_dd.rule_psr'] = tracingAttributes.rulePsr;\n }\n\n return attributes;\n};\n\nconst formatResourceStopContext = (\n timings: RUMResource['timings'],\n graphqlAttributes: RUMResource['graphqlAttributes']\n): Record<string, unknown> => {\n const attributes: Record<string, unknown> = {};\n\n if (timings.responseStartTime !== undefined) {\n attributes['_dd.resource_timings'] = createTimings(\n timings.startTime,\n timings.responseStartTime,\n timings.stopTime\n );\n }\n\n if (graphqlAttributes?.operationType) {\n attributes['_dd.graphql.operation_type'] =\n graphqlAttributes.operationType;\n if (graphqlAttributes.operationName) {\n attributes['_dd.graphql.operation_name'] =\n graphqlAttributes.operationName;\n }\n if (graphqlAttributes.variables) {\n attributes['_dd.graphql.variables'] = graphqlAttributes.variables;\n }\n }\n\n return attributes;\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, resource.graphqlAttributes),\n resource.timings.stopTime,\n resource.resourceContext\n );\n};\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GlobalState = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A singleton container for attributes that are shared internally across all
|
|
18
|
+
* the SDK classes.
|
|
19
|
+
*/
|
|
20
|
+
class GlobalState {
|
|
21
|
+
constructor() {
|
|
22
|
+
_defineProperty(this, "isInitialized", false);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static get instance() {
|
|
26
|
+
if (this._instance === undefined) {
|
|
27
|
+
this._instance = new GlobalState();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return this._instance;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.GlobalState = GlobalState;
|
|
36
|
+
|
|
37
|
+
_defineProperty(GlobalState, "_instance", undefined);
|
|
38
|
+
//# sourceMappingURL=GlobalState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["GlobalState.tsx"],"names":["GlobalState","instance","_instance","undefined"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,WAAN,CAAkB;AAAA;AAAA,2CAIE,KAJF;AAAA;;AAQK,aAARC,QAAQ,GAAgB;AACtC,QAAI,KAAKC,SAAL,KAAmBC,SAAvB,EAAkC;AAC9B,WAAKD,SAAL,GAAiB,IAAIF,WAAJ,EAAjB;AACH;;AAED,WAAO,KAAKE,SAAZ;AACH;;AAdoB;;;;gBAAZF,W,eAO2CG,S","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 * A singleton container for attributes that are shared internally across all\n * the SDK classes.\n */\nexport class GlobalState {\n /**\n * `true` if the SDK is initialized, `false` otherwise.\n */\n public isInitialized = false;\n\n // Singleton implementation\n private static _instance: GlobalState | undefined = undefined;\n public static get instance(): GlobalState {\n if (this._instance === undefined) {\n this._instance = new GlobalState();\n }\n\n return this._instance;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeDdLogs.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;
|
|
1
|
+
{"version":3,"sources":["NativeDdLogs.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;AAuGA;eACeA,iCAAoBC,GAApB,CAA8B,QAA9B,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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeLogsType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Send a log with DEBUG level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n readonly debug: (message: string, context: Object) => Promise<void>;\n\n /**\n * Send a log with INFO level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n readonly info: (message: string, context: Object) => Promise<void>;\n\n /**\n * Send a log with WARN level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n readonly warn: (message: string, context: Object) => Promise<void>;\n\n /**\n * Send a log with ERROR level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n readonly error: (message: string, context: Object) => Promise<void>;\n\n /**\n * Send a log containing an error with DEBUG level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n readonly debugWithError: (\n message: string,\n errorKind: string,\n errorMessage: string,\n stacktrace: string,\n context: Object\n ) => Promise<void>;\n\n /**\n * Send a log containing an error with INFO level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n readonly infoWithError: (\n message: string,\n errorKind: string,\n errorMessage: string,\n stacktrace: string,\n context: Object\n ) => Promise<void>;\n\n /**\n * Send a log containing an error with WARN level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n readonly warnWithError: (\n message: string,\n errorKind: string,\n errorMessage: string,\n stacktrace: string,\n context: Object\n ) => Promise<void>;\n\n /**\n * Send a log containing an error with ERROR level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n readonly errorWithError: (\n message: string,\n errorKind: string,\n errorMessage: string,\n stacktrace: string,\n context: Object\n ) => Promise<void>;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default TurboModuleRegistry.get<Spec>('DdLogs');\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeDdRum.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;
|
|
1
|
+
{"version":3,"sources":["NativeDdRum.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;AAqJA;eACeA,iCAAoBC,GAApB,CAA8B,OAA9B,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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeRumType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\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(key: string, context: Object, timestampMs: number): 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: string,\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: string,\n name: string,\n context: Object,\n timestampMs: number\n ): 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: string,\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: string,\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: string,\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 * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n\n /**\n * Adds the result of evaluating a feature flag with a given name and value to the view.\n * Feature flag evaluations are local to the active view and are cleared when the view is stopped.\n * @param name: The name of the feature flag\n * @param value: The value of the feature flag, encapsulated in an Object to accept all types\n */\n addFeatureFlagEvaluation(name: string, value: Object): Promise<void>;\n\n /**\n * Get current Session ID, or `undefined` if not available.\n */\n getCurrentSessionId(): Promise<string | undefined>;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default TurboModuleRegistry.get<Spec>('DdRum');\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeDdSdk.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;
|
|
1
|
+
{"version":3,"sources":["NativeDdSdk.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;AA4DA;eACeA,iCAAoBC,GAApB,CAA8B,OAA9B,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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeSdkType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: Object): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: Object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: Object): Promise<Object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n\n /**\n * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: string): Promise<void>;\n\n /**\n * Clears all data that has not already been sent to Datadog servers\n */\n clearAllData(): Promise<void>;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default TurboModuleRegistry.get<Spec>('DdSdk');\n"]}
|
|
@@ -14,6 +14,7 @@ var _reactNative = require("react-native");
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
17
|
+
// eslint-disable-next-line import/no-default-export
|
|
17
18
|
var _default = _reactNative.TurboModuleRegistry.get('DdTrace');
|
|
18
19
|
|
|
19
20
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeDdTrace.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;
|
|
1
|
+
{"version":3,"sources":["NativeDdTrace.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;AAmCA;eACeA,iCAAoBC,GAApB,CAA8B,SAA9B,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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeTraceType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context: Object,\n timestampMs: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default TurboModuleRegistry.get<Spec>('DdTrace');\n"]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.4.1';\n"]}
|
|
@@ -18,6 +18,7 @@ import { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSinglet
|
|
|
18
18
|
import { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';
|
|
19
19
|
import { DdSdk } from './sdk/DdSdk';
|
|
20
20
|
import { FileBasedConfiguration } from './sdk/FileBasedConfiguration/FileBasedConfiguration';
|
|
21
|
+
import { GlobalState } from './sdk/GlobalState/GlobalState';
|
|
21
22
|
import { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';
|
|
22
23
|
import { DdSdkConfiguration } from './types';
|
|
23
24
|
import { adaptLongTaskThreshold } from './utils/longTasksUtils';
|
|
@@ -80,13 +81,6 @@ export class DdSdkReactNative {
|
|
|
80
81
|
*/
|
|
81
82
|
|
|
82
83
|
|
|
83
|
-
/**
|
|
84
|
-
* Returns `true` if the SDK was initialized, `false` otherwise.
|
|
85
|
-
*/
|
|
86
|
-
static isInitialized() {
|
|
87
|
-
return DdSdkReactNative._isInitialized;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
84
|
static enableFeatures(configuration) {
|
|
91
85
|
if (DdSdkReactNative.wasAutoInstrumented) {
|
|
92
86
|
InternalLog.log("Can't auto instrument Datadog, SDK was already instrumented", SdkVerbosity.WARN);
|
|
@@ -95,7 +89,8 @@ export class DdSdkReactNative {
|
|
|
95
89
|
|
|
96
90
|
if (configuration.trackInteractions) {
|
|
97
91
|
DdRumUserInteractionTracking.startTracking({
|
|
98
|
-
actionNameAttribute: configuration.actionNameAttribute
|
|
92
|
+
actionNameAttribute: configuration.actionNameAttribute,
|
|
93
|
+
useAccessibilityLabel: configuration.useAccessibilityLabel
|
|
99
94
|
});
|
|
100
95
|
}
|
|
101
96
|
|
|
@@ -143,8 +138,6 @@ _defineProperty(DdSdkReactNative, "wasAutoInstrumented", false);
|
|
|
143
138
|
|
|
144
139
|
_defineProperty(DdSdkReactNative, "features", void 0);
|
|
145
140
|
|
|
146
|
-
_defineProperty(DdSdkReactNative, "_isInitialized", false);
|
|
147
|
-
|
|
148
141
|
_defineProperty(DdSdkReactNative, "initialize", async configuration => {
|
|
149
142
|
await DdSdkReactNative.initializeNativeSDK(configuration, {
|
|
150
143
|
initializationModeForTelemetry: 'LEGACY'
|
|
@@ -153,7 +146,7 @@ _defineProperty(DdSdkReactNative, "initialize", async configuration => {
|
|
|
153
146
|
});
|
|
154
147
|
|
|
155
148
|
_defineProperty(DdSdkReactNative, "initializeNativeSDK", async (configuration, params) => {
|
|
156
|
-
if (
|
|
149
|
+
if (GlobalState.instance.isInitialized) {
|
|
157
150
|
InternalLog.log("Can't initialize Datadog, SDK was already initialized", SdkVerbosity.WARN);
|
|
158
151
|
|
|
159
152
|
if (!__DEV__) {
|
|
@@ -166,7 +159,7 @@ _defineProperty(DdSdkReactNative, "initializeNativeSDK", async (configuration, p
|
|
|
166
159
|
InternalLog.verbosity = configuration.verbosity;
|
|
167
160
|
await DdSdk.initialize(DdSdkReactNative.buildConfiguration(configuration, params));
|
|
168
161
|
InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);
|
|
169
|
-
|
|
162
|
+
GlobalState.instance.isInitialized = true;
|
|
170
163
|
BufferSingleton.onInitialization();
|
|
171
164
|
});
|
|
172
165
|
|