@datadog/mobile-react-native 1.1.3 → 1.2.0-beta1
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/README.md +18 -14
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +8 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +10 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +25 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +2 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +52 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +7 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +1 -0
- package/ios/Sources/DdSdk.m +10 -0
- package/ios/Sources/DdSdk.swift +17 -0
- package/ios/Sources/DdSdkConfiguration.swift +4 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +2 -0
- package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js +173 -0
- package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
- package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js +32 -0
- package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
- package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js +29 -0
- package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
- package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js +28 -0
- package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
- package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js +32 -0
- package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
- package/lib/commonjs/DatadogProvider/DatadogProvider.js +101 -0
- package/lib/commonjs/DatadogProvider/DatadogProvider.js.map +1 -0
- package/lib/commonjs/DdSdkReactNative.js +138 -56
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +102 -9
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/errorUtils.js +60 -0
- package/lib/commonjs/errorUtils.js.map +1 -0
- package/lib/commonjs/foundation.js +19 -12
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +8 -45
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +19 -9
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/getJsxRuntime.js +55 -0
- package/lib/commonjs/rum/instrumentation/getJsxRuntime.js.map +1 -0
- package/lib/commonjs/types.js +2 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js +163 -0
- package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
- package/lib/module/DatadogProvider/Buffer/BufferSingleton.js +26 -0
- package/lib/module/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
- package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js +20 -0
- package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
- package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js +23 -0
- package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
- package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js +16 -0
- package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
- package/lib/module/DatadogProvider/DatadogProvider.js +82 -0
- package/lib/module/DatadogProvider/DatadogProvider.js.map +1 -0
- package/lib/module/DdSdkReactNative.js +130 -54
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +91 -8
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/errorUtils.js +45 -0
- package/lib/module/errorUtils.js.map +1 -0
- package/lib/module/foundation.js +18 -12
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +5 -42
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +16 -9
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/getJsxRuntime.js +45 -0
- package/lib/module/rum/instrumentation/getJsxRuntime.js.map +1 -0
- package/lib/module/types.js +2 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
- package/lib/typescript/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
- package/lib/typescript/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
- package/lib/typescript/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
- package/lib/typescript/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
- package/lib/typescript/DatadogProvider/DatadogProvider.d.ts +26 -0
- package/lib/typescript/DdSdkReactNative.d.ts +23 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +63 -0
- package/lib/typescript/errorUtils.d.ts +4 -0
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/nativeModulesTypes.d.ts +12 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +0 -2
- package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -0
- package/lib/typescript/rum/instrumentation/getJsxRuntime.d.ts +1 -0
- package/lib/typescript/types.d.ts +2 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DatadogProvider/Buffer/BoundedBuffer.ts +209 -0
- package/src/DatadogProvider/Buffer/BufferSingleton.ts +26 -0
- package/src/DatadogProvider/Buffer/DatadogBuffer.ts +34 -0
- package/src/DatadogProvider/Buffer/PassThroughBuffer.ts +16 -0
- package/src/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +202 -0
- package/src/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +50 -0
- package/src/DatadogProvider/Buffer/bufferNativeCall.ts +24 -0
- package/src/DatadogProvider/DatadogProvider.tsx +122 -0
- package/src/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +111 -0
- package/src/DatadogProvider/__tests__/initialization.test.tsx +174 -0
- package/src/DatadogProvider/__tests__/initializationModes.test.tsx +174 -0
- package/src/DdSdkReactNative.tsx +205 -105
- package/src/DdSdkReactNativeConfiguration.tsx +160 -8
- package/src/__tests__/DdRumWrapper.test.tsx +3 -27
- package/src/__tests__/DdSdkReactNative.test.tsx +1 -0
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +168 -0
- package/src/__tests__/foundation.test.ts +11 -2
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +18 -4
- package/src/errorUtils.ts +50 -0
- package/src/foundation.tsx +15 -12
- package/src/index.tsx +9 -1
- package/src/nativeModulesTypes.ts +14 -0
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +9 -46
- package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +13 -9
- package/src/rum/instrumentation/getJsxRuntime.ts +43 -0
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -0
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -0
- package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +3 -0
- package/src/types.tsx +2 -1
- package/src/version.ts +1 -1
|
@@ -5,6 +5,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
5
5
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
6
6
|
* Copyright 2016-Present Datadog, Inc.
|
|
7
7
|
*/
|
|
8
|
+
import { InteractionManager } from 'react-native';
|
|
9
|
+
import { BufferSingleton } from './DatadogProvider/Buffer/BufferSingleton';
|
|
10
|
+
import { DdSdkReactNativeConfiguration, buildConfigurationFromPartialConfiguration, addDefaultValuesToAutoInstrumentationConfiguration, InitializationMode } from './DdSdkReactNativeConfiguration';
|
|
8
11
|
import { InternalLog } from './InternalLog';
|
|
9
12
|
import { ProxyType } from './ProxyConfiguration';
|
|
10
13
|
import { SdkVerbosity } from './SdkVerbosity';
|
|
@@ -26,74 +29,53 @@ export class DdSdkReactNative {
|
|
|
26
29
|
* @param configuration the configuration for the SDK library
|
|
27
30
|
* @returns a Promise.
|
|
28
31
|
*/
|
|
29
|
-
static initialize(configuration) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
resolve();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
32
|
+
static async initialize(configuration) {
|
|
33
|
+
await DdSdkReactNative.initializeNativeSDK(configuration);
|
|
34
|
+
DdSdkReactNative.enableFeatures(configuration);
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
/**
|
|
38
|
+
* FOR INTERNAL USE ONLY.
|
|
39
|
+
*/
|
|
40
|
+
static async _initializeFromDatadogProvider(configuration) {
|
|
41
|
+
DdSdkReactNative.enableFeatures(configuration);
|
|
42
|
+
DdSdkReactNative.configuration = configuration;
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (configuration.initializationMode === InitializationMode.SYNC) {
|
|
45
|
+
return DdSdkReactNative.initializeNativeSDK(configuration);
|
|
46
|
+
}
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] = proxyConfig.port;
|
|
52
|
-
|
|
53
|
-
if (proxyConfig.username && proxyConfig.password) {
|
|
54
|
-
if (proxyConfig.type === ProxyType.SOCKS) {
|
|
55
|
-
console.warn("SOCKS proxy configuration doesn't support Basic authentication.");
|
|
56
|
-
} else {
|
|
57
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] = proxyConfig.username;
|
|
58
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] = proxyConfig.password;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
48
|
+
if (configuration.initializationMode === InitializationMode.ASYNC) {
|
|
49
|
+
return InteractionManager.runAfterInteractions(() => {
|
|
50
|
+
return DdSdkReactNative.initializeNativeSDK(configuration);
|
|
51
|
+
});
|
|
52
|
+
} // TODO: Remove when DdSdkReactNativeConfiguration is deprecated
|
|
62
53
|
|
|
63
|
-
if (configuration.serviceName) {
|
|
64
|
-
configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] = configuration.serviceName;
|
|
65
|
-
}
|
|
66
54
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
if (configuration instanceof DdSdkReactNativeConfiguration) {
|
|
56
|
+
return DdSdkReactNative.initializeNativeSDK(configuration);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* FOR INTERNAL USE ONLY.
|
|
61
|
+
*/
|
|
71
62
|
|
|
72
63
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;
|
|
78
|
-
configuration.additionalConfig['_dd.first_party_hosts'] = configuration.firstPartyHosts;
|
|
79
|
-
DdSdk.initialize(new DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig)).then(() => {
|
|
80
|
-
InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);
|
|
81
|
-
DdSdkReactNative.enableFeatures(configuration);
|
|
82
|
-
DdSdkReactNative.wasInitialized = true;
|
|
83
|
-
resolve();
|
|
84
|
-
}, rejection => {
|
|
85
|
-
reject(rejection);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
64
|
+
static async _enableFeaturesFromDatadogProvider(features) {
|
|
65
|
+
DdSdkReactNative.features = features;
|
|
66
|
+
DdSdkReactNative.enableFeatures(addDefaultValuesToAutoInstrumentationConfiguration(features));
|
|
88
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* FOR INTERNAL USE ONLY.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
|
|
89
73
|
/**
|
|
90
74
|
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
|
|
91
75
|
* @param attributes: The global context attributes.
|
|
92
76
|
* @returns a Promise.
|
|
93
77
|
*/
|
|
94
78
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
95
|
-
|
|
96
|
-
|
|
97
79
|
static setAttributes(attributes) {
|
|
98
80
|
InternalLog.log(`Setting attributes ${JSON.stringify(attributes)}`, SdkVerbosity.DEBUG);
|
|
99
81
|
return DdSdk.setAttributes(attributes);
|
|
@@ -123,6 +105,11 @@ export class DdSdkReactNative {
|
|
|
123
105
|
}
|
|
124
106
|
|
|
125
107
|
static enableFeatures(configuration) {
|
|
108
|
+
if (DdSdkReactNative.wasAutoInstrumented) {
|
|
109
|
+
InternalLog.log("Can't auto instrument Datadog, SDK was already instrumented", SdkVerbosity.WARN);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
126
113
|
if (configuration.trackInteractions) {
|
|
127
114
|
DdRumUserInteractionTracking.startTracking();
|
|
128
115
|
}
|
|
@@ -137,6 +124,8 @@ export class DdSdkReactNative {
|
|
|
137
124
|
if (configuration.trackErrors) {
|
|
138
125
|
DdRumErrorTracking.startTracking();
|
|
139
126
|
}
|
|
127
|
+
|
|
128
|
+
DdSdkReactNative.wasAutoInstrumented = true;
|
|
140
129
|
}
|
|
141
130
|
|
|
142
131
|
}
|
|
@@ -170,4 +159,91 @@ _defineProperty(DdSdkReactNative, "DD_NATIVE_LONG_TASK_THRESHOLD_KEY", '_dd.long
|
|
|
170
159
|
_defineProperty(DdSdkReactNative, "NATIVE_LONG_TASK_THRESHOLD_MS", 200);
|
|
171
160
|
|
|
172
161
|
_defineProperty(DdSdkReactNative, "wasInitialized", false);
|
|
162
|
+
|
|
163
|
+
_defineProperty(DdSdkReactNative, "wasAutoInstrumented", false);
|
|
164
|
+
|
|
165
|
+
_defineProperty(DdSdkReactNative, "configuration", void 0);
|
|
166
|
+
|
|
167
|
+
_defineProperty(DdSdkReactNative, "features", void 0);
|
|
168
|
+
|
|
169
|
+
_defineProperty(DdSdkReactNative, "initializeNativeSDK", async configuration => {
|
|
170
|
+
if (DdSdkReactNative.wasInitialized) {
|
|
171
|
+
InternalLog.log("Can't initialize Datadog, SDK was already initialized", SdkVerbosity.WARN);
|
|
172
|
+
|
|
173
|
+
if (!__DEV__) {
|
|
174
|
+
DdSdk.telemetryDebug('RN SDK was already initialized in javascript');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return new Promise(resolve => resolve());
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
InternalLog.verbosity = configuration.verbosity;
|
|
181
|
+
DdSdkReactNative.buildConfiguration(configuration);
|
|
182
|
+
await DdSdk.initialize(new DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig, configuration.telemetrySampleRate));
|
|
183
|
+
InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);
|
|
184
|
+
DdSdkReactNative.wasInitialized = true;
|
|
185
|
+
BufferSingleton.onInitialization();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
_defineProperty(DdSdkReactNative, "_initializeFromDatadogProviderAsync", async () => {
|
|
189
|
+
if (!DdSdkReactNative.configuration) {
|
|
190
|
+
InternalLog.log("Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function", SdkVerbosity.WARN);
|
|
191
|
+
return new Promise(resolve => resolve());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return DdSdkReactNative.initializeNativeSDK(DdSdkReactNative.configuration);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
_defineProperty(DdSdkReactNative, "_initializeFromDatadogProviderWithConfigurationAsync", async configuration => {
|
|
198
|
+
if (!DdSdkReactNative.features) {
|
|
199
|
+
InternalLog.log("Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function", SdkVerbosity.WARN);
|
|
200
|
+
return new Promise(resolve => resolve());
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return DdSdkReactNative.initializeNativeSDK(buildConfigurationFromPartialConfiguration(DdSdkReactNative.features, configuration));
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
_defineProperty(DdSdkReactNative, "buildConfiguration", configuration => {
|
|
207
|
+
configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] = 'react-native';
|
|
208
|
+
configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERSION] = sdkVersion;
|
|
209
|
+
configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY] = configuration.nativeViewTracking;
|
|
210
|
+
|
|
211
|
+
if (configuration.verbosity) {
|
|
212
|
+
configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERBOSITY_KEY] = configuration.verbosity;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (configuration.proxyConfig) {
|
|
216
|
+
const additionalConfig = configuration.additionalConfig;
|
|
217
|
+
const proxyConfig = configuration.proxyConfig;
|
|
218
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] = proxyConfig.type;
|
|
219
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] = proxyConfig.address;
|
|
220
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] = proxyConfig.port;
|
|
221
|
+
|
|
222
|
+
if (proxyConfig.username && proxyConfig.password) {
|
|
223
|
+
if (proxyConfig.type === ProxyType.SOCKS) {
|
|
224
|
+
console.warn("SOCKS proxy configuration doesn't support Basic authentication.");
|
|
225
|
+
} else {
|
|
226
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] = proxyConfig.username;
|
|
227
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] = proxyConfig.password;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (configuration.serviceName) {
|
|
233
|
+
configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] = configuration.serviceName;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (configuration.version) {
|
|
237
|
+
configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${configuration.version}${configuration.versionSuffix ? `-${configuration.versionSuffix}` : ''}`;
|
|
238
|
+
} // If both version and version suffix are provided, we merge them into the version field.
|
|
239
|
+
// To avoid adding it in again the native part, we only set it if the version isn't set.
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
if (configuration.versionSuffix && !configuration.version) {
|
|
243
|
+
configuration.additionalConfig[DdSdkReactNative.DD_VERSION_SUFFIX] = `-${configuration.versionSuffix}`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;
|
|
247
|
+
configuration.additionalConfig['_dd.first_party_hosts'] = configuration.firstPartyHosts;
|
|
248
|
+
});
|
|
173
249
|
//# sourceMappingURL=DdSdkReactNative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InternalLog","ProxyType","SdkVerbosity","DdSdk","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","Promise","resolve","reject","wasInitialized","log","WARN","verbosity","additionalConfig","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX","DD_NATIVE_LONG_TASK_THRESHOLD_KEY","NATIVE_LONG_TASK_THRESHOLD_MS","firstPartyHosts","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","then","INFO","enableFeatures","rejection","setAttributes","attributes","JSON","stringify","DEBUG","setUser","user","setTrackingConsent","consent","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","trackErrors"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,eAA5B;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AA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AK,CAAC+D,OAAN,CAAcC,IAAd,CAAP;AACH;AAED;AACJ;AACA;AACA;AACA;;;AAC6B,SAAlBC,kBAAkB,CAACC,OAAD,EAA0C;AAC/DrE,IAAAA,WAAW,CAACiB,GAAZ,CAAiB,mBAAkBoD,OAAQ,EAA3C,EAA8CnE,YAAY,CAAC+D,KAA3D;AACA,WAAO9D,KAAK,CAACiE,kBAAN,CAAyBC,OAAzB,CAAP;AACH;;AAE4B,SAAdV,cAAc,CACzB/C,aADyB,EAE3B;AACE,QAAIA,aAAa,CAAC0D,iBAAlB,EAAqC;AACjCjE,MAAAA,4BAA4B,CAACkE,aAA7B;AACH;;AAED,QAAI3D,aAAa,CAAC4D,cAAlB,EAAkC;AAC9BlE,MAAAA,qBAAqB,CAACiE,aAAtB,CAAoC;AAChCE,QAAAA,mBAAmB,EAAE7D,aAAa,CAAC8D,2BADH;AAEhC3B,QAAAA,eAAe,EAAEnC,aAAa,CAACmC;AAFC,OAApC;AAIH;;AAED,QAAInC,aAAa,CAAC+D,WAAlB,EAA+B;AAC3BvE,MAAAA,kBAAkB,CAACmE,aAAnB;AACH;AACJ;;AAvMyB;;gBAAjB7D,gB,mBAC+B,Y;;gBAD/BA,gB,oBAEgC,iB;;gBAFhCA,gB,qBAGiC,kB;;gBAHjCA,gB,0BAIsC,mB;;gBAJtCA,gB,iCAML,0B;;gBANKA,gB,gBAO4B,a;;gBAP5BA,gB,uBAQmC,oB;;gBARnCA,gB,uBAWmC,gB;;gBAXnCA,gB,0BAYsC,mB;;gBAZtCA,gB,uBAamC,gB;;gBAbnCA,gB,2BAcuC,oB;;gBAdvCA,gB,2BAeuC,oB;;gBAfvCA,gB,uCAkBL,yB;;gBAlBKA,gB,mCAmB+C,G;;gBAnB/CA,gB,oBAqBuB,K","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 { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { DdSdkConfiguration } from './types';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_SERVICE_NAME = '_dd.service_name';\n private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY =\n '_dd.native_view_tracking';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY =\n '_dd.long_task.threshold';\n private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200;\n\n private static wasInitialized = false;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n resolve();\n return;\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[\n DdSdkReactNative.DD_PROXY_USERNAME_KEY\n ] = proxyConfig.username;\n additionalConfig[\n DdSdkReactNative.DD_PROXY_PASSWORD_KEY\n ] = proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SERVICE_NAME\n ] = configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION\n ] = `${configuration.version}${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY\n ] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;\n\n configuration.additionalConfig['_dd.first_party_hosts'] =\n configuration.firstPartyHosts;\n\n DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig\n )\n ).then(\n () => {\n InternalLog.log(\n 'Datadog SDK was initialized',\n SdkVerbosity.INFO\n );\n DdSdkReactNative.enableFeatures(configuration);\n DdSdkReactNative.wasInitialized = true;\n resolve();\n },\n rejection => {\n reject(rejection);\n }\n );\n });\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setAttributes(attributes);\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser(user: object): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setUser(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static enableFeatures(\n configuration: DdSdkReactNativeConfiguration\n ) {\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: configuration.firstPartyHosts\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InteractionManager","BufferSingleton","DdSdkReactNativeConfiguration","buildConfigurationFromPartialConfiguration","addDefaultValuesToAutoInstrumentationConfiguration","InitializationMode","InternalLog","ProxyType","SdkVerbosity","DdSdk","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","initializeNativeSDK","enableFeatures","_initializeFromDatadogProvider","initializationMode","SYNC","ASYNC","runAfterInteractions","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","log","JSON","stringify","DEBUG","setUser","user","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","INFO","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX","DD_NATIVE_LONG_TASK_THRESHOLD_KEY","NATIVE_LONG_TASK_THRESHOLD_MS"],"mappings":";;AAAA;AACA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EAhB,QAAAA,gBAAgB,CAAC/C,gBAAgB,CAACqE,qBAAlB,CAAhB,GACIb,WAAW,CAACQ,QADhB;AAEH;AACJ;AACJ;;AAED,MAAI9D,aAAa,CAACoE,WAAlB,EAA+B;AAC3BpE,IAAAA,aAAa,CAAC6C,gBAAd,CAA+B/C,gBAAgB,CAACuE,eAAhD,IACIrE,aAAa,CAACoE,WADlB;AAEH;;AAED,MAAIpE,aAAa,CAACJ,OAAlB,EAA2B;AACvBI,IAAAA,aAAa,CAAC6C,gBAAd,CAA+B/C,gBAAgB,CAACwE,UAAhD,IAA+D,GAC3DtE,aAAa,CAACJ,OACjB,GACGI,aAAa,CAACuE,aAAd,GACO,IAAGvE,aAAa,CAACuE,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GApDA,CAsDD;AACA;;;AACA,MAAIvE,aAAa,CAACuE,aAAd,IAA+B,CAACvE,aAAa,CAACJ,OAAlD,EAA2D;AACvDI,IAAAA,aAAa,CAAC6C,gBAAd,CACI/C,gBAAgB,CAAC0E,iBADrB,IAEK,IAAGxE,aAAa,CAACuE,aAAc,EAFpC;AAGH;;AAEDvE,EAAAA,aAAa,CAAC6C,gBAAd,CACI/C,gBAAgB,CAAC2E,iCADrB,IAEI3E,gBAAgB,CAAC4E,6BAFrB;AAIA1E,EAAAA,aAAa,CAAC6C,gBAAd,CAA+B,uBAA/B,IACI7C,aAAa,CAAC2B,eADlB;AAEH,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\nimport { InteractionManager } from 'react-native';\n\nimport { BufferSingleton } from './DatadogProvider/Buffer/BufferSingleton';\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { DdSdkConfiguration } from './types';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_SERVICE_NAME = '_dd.service_name';\n private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY =\n '_dd.native_view_tracking';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY =\n '_dd.long_task.threshold';\n private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200;\n\n private static wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static configuration?: DdSdkReactNativeConfiguration;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n await DdSdkReactNative.initializeNativeSDK(configuration);\n DdSdkReactNative.enableFeatures(configuration);\n }\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n DdSdkReactNative.buildConfiguration(configuration);\n\n await DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate\n )\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n DdSdkReactNative.configuration = configuration;\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration);\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration);\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration);\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderAsync = async (): Promise<void> => {\n if (!DdSdkReactNative.configuration) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n return DdSdkReactNative.initializeNativeSDK(\n DdSdkReactNative.configuration\n );\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n )\n );\n };\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setAttributes(attributes);\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser(user: object): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setUser(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration\n ) => {\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] =\n proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] =\n proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] =\n configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${\n configuration.version\n }${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY\n ] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;\n\n configuration.additionalConfig['_dd.first_party_hosts'] =\n configuration.firstPartyHosts;\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: configuration.firstPartyHosts\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
|
@@ -6,6 +6,17 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
* Copyright 2016-Present Datadog, Inc.
|
|
7
7
|
*/
|
|
8
8
|
import { TrackingConsent } from './TrackingConsent';
|
|
9
|
+
const DEFAULTS = {
|
|
10
|
+
nativeCrashReportEnabled: false,
|
|
11
|
+
sessionSamplingRate: 100.0,
|
|
12
|
+
resourceTracingSamplingRate: 20.0,
|
|
13
|
+
site: 'US1',
|
|
14
|
+
nativeViewTracking: false,
|
|
15
|
+
getFirstPartyHosts: () => [],
|
|
16
|
+
getAdditionalConfig: () => ({}),
|
|
17
|
+
trackingConsent: TrackingConsent.GRANTED,
|
|
18
|
+
telemetrySampleRate: 20.0
|
|
19
|
+
};
|
|
9
20
|
/**
|
|
10
21
|
* The SDK configuration class.
|
|
11
22
|
* It will be used to configure the SDK functionality at initialization.
|
|
@@ -43,7 +54,17 @@ export class DdSdkReactNativeConfiguration {
|
|
|
43
54
|
*
|
|
44
55
|
* A dash (`-`) will be automatically added between the version and the suffix
|
|
45
56
|
*/
|
|
46
|
-
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The sampling rate for Internal Telemetry (info related to the work of the
|
|
60
|
+
* SDK internals).
|
|
61
|
+
*
|
|
62
|
+
* The sampling rate must be a value between 0 and 100. A value of 0 means no
|
|
63
|
+
* telemetry will be sent, 100 means all telemetry will be sent. When
|
|
64
|
+
* `telemetrySampleRate` is not set, the default value from the iOS and
|
|
65
|
+
* Android SDK is used, which is 20.
|
|
66
|
+
*/
|
|
67
|
+
constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = DEFAULTS.trackingConsent) {
|
|
47
68
|
this.clientToken = clientToken;
|
|
48
69
|
this.env = env;
|
|
49
70
|
this.applicationId = applicationId;
|
|
@@ -52,32 +73,94 @@ export class DdSdkReactNativeConfiguration {
|
|
|
52
73
|
this.trackErrors = trackErrors;
|
|
53
74
|
this.trackingConsent = trackingConsent;
|
|
54
75
|
|
|
55
|
-
_defineProperty(this, "nativeCrashReportEnabled",
|
|
76
|
+
_defineProperty(this, "nativeCrashReportEnabled", DEFAULTS.nativeCrashReportEnabled);
|
|
56
77
|
|
|
57
78
|
_defineProperty(this, "sampleRate", void 0);
|
|
58
79
|
|
|
59
|
-
_defineProperty(this, "sessionSamplingRate",
|
|
80
|
+
_defineProperty(this, "sessionSamplingRate", DEFAULTS.sessionSamplingRate);
|
|
60
81
|
|
|
61
|
-
_defineProperty(this, "resourceTracingSamplingRate",
|
|
82
|
+
_defineProperty(this, "resourceTracingSamplingRate", DEFAULTS.resourceTracingSamplingRate);
|
|
62
83
|
|
|
63
|
-
_defineProperty(this, "site",
|
|
84
|
+
_defineProperty(this, "site", DEFAULTS.site);
|
|
64
85
|
|
|
65
86
|
_defineProperty(this, "verbosity", undefined);
|
|
66
87
|
|
|
67
|
-
_defineProperty(this, "nativeViewTracking",
|
|
88
|
+
_defineProperty(this, "nativeViewTracking", DEFAULTS.nativeViewTracking);
|
|
68
89
|
|
|
69
90
|
_defineProperty(this, "proxyConfig", undefined);
|
|
70
91
|
|
|
71
92
|
_defineProperty(this, "serviceName", undefined);
|
|
72
93
|
|
|
73
|
-
_defineProperty(this, "firstPartyHosts",
|
|
94
|
+
_defineProperty(this, "firstPartyHosts", DEFAULTS.getFirstPartyHosts());
|
|
74
95
|
|
|
75
96
|
_defineProperty(this, "version", void 0);
|
|
76
97
|
|
|
77
98
|
_defineProperty(this, "versionSuffix", void 0);
|
|
78
99
|
|
|
79
|
-
_defineProperty(this, "
|
|
100
|
+
_defineProperty(this, "telemetrySampleRate", DEFAULTS.telemetrySampleRate);
|
|
101
|
+
|
|
102
|
+
_defineProperty(this, "additionalConfig", DEFAULTS.getAdditionalConfig());
|
|
80
103
|
}
|
|
81
104
|
|
|
82
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Auto Instrumentation configuration passed to DatadogProvider.
|
|
108
|
+
* Does not include default values.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* We could use `Proxy` instead of this function, but `Proxy` is not available on
|
|
113
|
+
* the older android jsc that can still be used.
|
|
114
|
+
*/
|
|
115
|
+
export const addDefaultValuesToAutoInstrumentationConfiguration = features => {
|
|
116
|
+
return { ...features,
|
|
117
|
+
firstPartyHosts: features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),
|
|
118
|
+
resourceTracingSamplingRate: features.resourceTracingSamplingRate || DEFAULTS.resourceTracingSamplingRate
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const setConfigurationAttribute = (attribute, configuration) => {
|
|
123
|
+
if (attribute.value !== undefined) {
|
|
124
|
+
configuration[attribute.name] = attribute.value;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const buildConfigurationFromPartialConfiguration = (features, configuration) => {
|
|
129
|
+
const {
|
|
130
|
+
clientToken,
|
|
131
|
+
env,
|
|
132
|
+
applicationId,
|
|
133
|
+
...remainingConfiguration
|
|
134
|
+
} = configuration;
|
|
135
|
+
const SdkConfiguration = new DdSdkReactNativeConfiguration(clientToken, env, applicationId, features.trackInteractions, features.trackResources, features.trackErrors, configuration.trackingConsent);
|
|
136
|
+
Object.keys(remainingConfiguration).forEach(name => {
|
|
137
|
+
setConfigurationAttribute({
|
|
138
|
+
value: remainingConfiguration[name],
|
|
139
|
+
name
|
|
140
|
+
}, SdkConfiguration);
|
|
141
|
+
});
|
|
142
|
+
setConfigurationAttribute({
|
|
143
|
+
name: 'resourceTracingSamplingRate',
|
|
144
|
+
value: features.resourceTracingSamplingRate
|
|
145
|
+
}, SdkConfiguration);
|
|
146
|
+
setConfigurationAttribute({
|
|
147
|
+
name: 'firstPartyHosts',
|
|
148
|
+
value: features.firstPartyHosts
|
|
149
|
+
}, SdkConfiguration);
|
|
150
|
+
return SdkConfiguration;
|
|
151
|
+
};
|
|
152
|
+
export class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
|
|
153
|
+
constructor(...args) {
|
|
154
|
+
super(...args);
|
|
155
|
+
|
|
156
|
+
_defineProperty(this, "initializationMode", InitializationMode.SYNC);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
export let InitializationMode;
|
|
161
|
+
|
|
162
|
+
(function (InitializationMode) {
|
|
163
|
+
InitializationMode["SYNC"] = "SYNC";
|
|
164
|
+
InitializationMode["ASYNC"] = "ASYNC";
|
|
165
|
+
})(InitializationMode || (InitializationMode = {}));
|
|
83
166
|
//# sourceMappingURL=DdSdkReactNativeConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","GRANTED","undefined"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAAN,CAAoC;AAEvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;;AAQI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKIC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEC,eAAgC,GAAGT,eAAe,CAACU,OAPrD,EAQT;AAAA,SAPWP,WAOX,GAPWA,WAOX;AAAA,SANWC,GAMX,GANWA,GAMX;AAAA,SALWC,aAKX,GALWA,aAKX;AAAA,SAJWC,iBAIX,GAJWA,iBAIX;AAAA,SAHWC,cAGX,GAHWA,cAGX;AAAA,SAFWC,WAEX,GAFWA,WAEX;AAAA,SADWC,eACX,GADWA,eACX;;AAAA,sDAlDyC,KAkDzC;;AAAA;;AAAA,iDA1CmC,KA0CnC;;AAAA,yDAtC2C,IAsC3C;;AAAA,kCArCoB,IAqCpB;;AAAA,uCApC2CE,SAoC3C;;AAAA,gDAnCmC,KAmCnC;;AAAA,yCAlCwCA,SAkCxC;;AAAA,yCAjC4BA,SAiC5B;;AAAA,6CAhCiC,EAgCjC;;AAAA;;AAAA;;AAAA,8CAV8C,EAU9C;AAAE;;AAnDmC","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 { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n public nativeCrashReportEnabled: boolean = false;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = 100.0;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number = 20.0;\n public site: string = 'US';\n public verbosity: SdkVerbosity | undefined = undefined;\n public nativeViewTracking: boolean = false;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n public firstPartyHosts: string[] = [];\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n public additionalConfig: { [k: string]: any } = {};\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = TrackingConsent.GRANTED\n ) {}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","nativeViewTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","GRANTED","telemetrySampleRate","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","firstPartyHosts","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAEA,MAAMC,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,kBAAkB,EAAE,KALP;AAMbC,EAAAA,kBAAkB,EAAE,MAAM,EANb;AAObC,EAAAA,mBAAmB,EAAE,OAAO,EAAP,CAPR;AAQbC,EAAAA,eAAe,EAAET,eAAe,CAACU,OARpB;AASbC,EAAAA,mBAAmB,EAAE;AATR,CAAjB;AAYA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAAN,CAAoC;AAGvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;;AASI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOIC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEV,eAAgC,GAAGR,QAAQ,CAACQ,eAP9C,EAQT;AAAA,SAPWK,WAOX,GAPWA,WAOX;AAAA,SANWC,GAMX,GANWA,GAMX;AAAA,SALWC,aAKX,GALWA,aAKX;AAAA,SAJWC,iBAIX,GAJWA,iBAIX;AAAA,SAHWC,cAGX,GAHWA,cAGX;AAAA,SAFWC,WAEX,GAFWA,WAEX;AAAA,SADWV,eACX,GADWA,eACX;;AAAA,sDAhEER,QAAQ,CAACC,wBAgEX;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Q,CAACJ,cALY,EAMrBI,QAAQ,CAACH,WANY,EAOrBO,aAAa,CAACjB,eAPO,CAAzB;AAUCuB,EAAAA,MAAM,CAACC,IAAP,CACGH,sBADH,CAAD,CAE8CI,OAF9C,CAEsDN,IAAI,IAAI;AAC1DJ,IAAAA,yBAAyB,CACrB;AAAEG,MAAAA,KAAK,EAAEG,sBAAsB,CAACF,IAAD,CAA/B;AAAuCA,MAAAA;AAAvC,KADqB,EAErBG,gBAFqB,CAAzB;AAIH,GAPD;AASAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,6BADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAAClB;AAFpB,GADqB,EAKrB2B,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AAAEI,IAAAA,IAAI,EAAE,iBAAR;AAA2BD,IAAAA,KAAK,EAAEL,QAAQ,CAACC;AAA3C,GADqB,EAErBQ,gBAFqB,CAAzB;AAKA,SAAOA,gBAAP;AACH,CA1CM;AA4CP,OAAO,MAAMI,4BAAN,SAA2CvB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;AAIhF,WAAYD,kBAAZ;;WAAYA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,KAAAA,kB","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 { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n nativeViewTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0\n};\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n public verbosity: SdkVerbosity | undefined = undefined;\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n public firstPartyHosts: string[] = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: string[];\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: string[];\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate ||\n DEFAULTS.resourceTracingSamplingRate\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
export const EMPTY_MESSAGE = 'Unknown Error';
|
|
7
|
+
export const EMPTY_STACK_TRACE = '';
|
|
8
|
+
export const getErrorMessage = error => {
|
|
9
|
+
let message = EMPTY_MESSAGE;
|
|
10
|
+
|
|
11
|
+
if (error === undefined || error === null) {
|
|
12
|
+
message = EMPTY_MESSAGE;
|
|
13
|
+
} else if (typeof error === 'object' && 'message' in error) {
|
|
14
|
+
message = String(error.message);
|
|
15
|
+
} else {
|
|
16
|
+
message = String(error);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return message;
|
|
20
|
+
};
|
|
21
|
+
export const getErrorStackTrace = error => {
|
|
22
|
+
let stack = EMPTY_STACK_TRACE;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
if (error === undefined || error === null) {
|
|
26
|
+
stack = EMPTY_STACK_TRACE;
|
|
27
|
+
} else if (typeof error === 'string') {
|
|
28
|
+
stack = EMPTY_STACK_TRACE;
|
|
29
|
+
} else if (typeof error === 'object') {
|
|
30
|
+
if ('componentStack' in error) {
|
|
31
|
+
stack = String(error.componentStack);
|
|
32
|
+
} else if ('stacktrace' in error) {
|
|
33
|
+
stack = String(error.stacktrace);
|
|
34
|
+
} else if ('stack' in error) {
|
|
35
|
+
stack = String(error.stack);
|
|
36
|
+
} else if ('sourceURL' in error && 'line' in error && 'column' in error) {
|
|
37
|
+
stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} catch (e) {// Do nothing
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return stack;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=errorUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["errorUtils.ts"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","getErrorMessage","error","message","undefined","String","getErrorStackTrace","stack","componentStack","stacktrace","sourceURL","line","column","e"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,eAAtB;AACP,OAAO,MAAMC,iBAAiB,GAAG,EAA1B;AAEP,OAAO,MAAMC,eAAe,GAAIC,KAAD,IAAoC;AAC/D,MAAIC,OAAO,GAAGJ,aAAd;;AACA,MAAIG,KAAK,KAAKE,SAAV,IAAuBF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AAP;AACH,CA3BM","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\nexport const EMPTY_MESSAGE = 'Unknown Error';\nexport const EMPTY_STACK_TRACE = '';\n\nexport const getErrorMessage = (error: any | undefined): string => {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n};\n\nexport const getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
|