@datadog/mobile-react-native 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +2 -1
- package/android/build.gradle +1 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +2 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +11 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +5 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +64 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +164 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +6 -354
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +351 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +5 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +10 -0
- package/android/src/main/kotlin/com/datadog/reactnative/JSONFileReader.kt +20 -0
- package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +4 -1
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +10 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +3 -2
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +5 -2
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +3 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkConfigurationTest.kt +196 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +181 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +12 -271
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +10 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +28 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +24 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +9 -1
- package/android/src/test/resources/input/complete-configuration.json +48 -0
- package/android/src/test/resources/input/malformed-configuration.json +5 -0
- package/android/src/test/resources/input/minimal-configuration.json +8 -0
- package/datadog-configuration.gradle +57 -0
- package/datadog-configuration.schema.json +200 -0
- package/ios/Sources/DatadogSDKWrapper.swift +16 -13
- package/ios/Sources/DdLogsImplementation.swift +14 -0
- package/ios/Sources/DdSdk.h +2 -0
- package/ios/Sources/DdSdk.mm +6 -1
- package/ios/Sources/DdSdkConfiguration.swift +47 -56
- package/ios/Sources/DdSdkImplementation.swift +10 -279
- package/ios/Sources/DdSdkNativeInitialization.swift +218 -0
- package/ios/Sources/DdTraceImplementation.swift +3 -1
- package/ios/Sources/GlobalState.swift +1 -1
- package/ios/Sources/JSONFileReader.swift +28 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +227 -9
- package/ios/Sources/SdkVersion.swift +10 -0
- package/lib/commonjs/DdSdkReactNative.js +24 -66
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -4
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/ProxyConfiguration.js +15 -2
- package/lib/commonjs/ProxyConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +2 -2
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
- package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js +214 -0
- package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +1 -0
- package/lib/commonjs/types.js +10 -2
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +23 -65
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +22 -4
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/ProxyConfiguration.js +15 -2
- package/lib/module/ProxyConfiguration.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +2 -2
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
- package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js +197 -0
- package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +1 -0
- package/lib/module/types.js +10 -2
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +0 -9
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +43 -3
- package/lib/typescript/ProxyConfiguration.d.ts +4 -12
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/nativeModulesTypes.d.ts +2 -2
- package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts +2 -1
- package/lib/typescript/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts +31 -0
- package/lib/typescript/types.d.ts +29 -3
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +7 -4
- package/src/DdSdkReactNative.tsx +58 -101
- package/src/DdSdkReactNativeConfiguration.tsx +26 -7
- package/src/ProxyConfiguration.tsx +17 -3
- package/src/__tests__/DdSdkReactNative.test.tsx +134 -112
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +19 -10
- package/src/__tests__/mock.test.ts +0 -9
- package/src/index.tsx +2 -0
- package/src/nativeModulesTypes.ts +1 -1
- package/src/sdk/DatadogProvider/DatadogProvider.tsx +3 -1
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +12 -5
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +1 -2
- package/src/sdk/FileBasedConfiguration/FileBasedConfiguration.ts +235 -0
- package/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +245 -0
- package/src/sdk/FileBasedConfiguration/__tests__/__fixtures__/configuration-all-fields.json +22 -0
- package/src/sdk/FileBasedConfiguration/__tests__/__fixtures__/malformed-configuration.json +5 -0
- package/src/types.tsx +21 -2
- package/src/version.ts +1 -1
|
@@ -28,8 +28,18 @@ extension NSDictionary {
|
|
|
28
28
|
let batchSize = object(forKey: "batchSize") as? NSString
|
|
29
29
|
let trackBackgroundEvents = object(forKey: "trackBackgroundEvents") as? Bool
|
|
30
30
|
let customEndpoints = object(forKey: "customEndpoints") as? NSDictionary
|
|
31
|
-
let additionalConfig = object(forKey: "
|
|
31
|
+
let additionalConfig = object(forKey: "additionalConfiguration") as? NSDictionary
|
|
32
32
|
let configurationForTelemetry = object(forKey: "configurationForTelemetry") as? NSDictionary
|
|
33
|
+
let nativeViewTracking = object(forKey: "nativeViewTracking") as? Bool
|
|
34
|
+
let nativeInteractionTracking = object(forKey: "nativeInteractionTracking") as? Bool
|
|
35
|
+
let verbosity = object(forKey: "verbosity") as? NSString
|
|
36
|
+
let proxyConfig = object(forKey: "proxyConfig") as? NSDictionary
|
|
37
|
+
let serviceName = object(forKey: "serviceName") as? NSString
|
|
38
|
+
let firstPartyHosts = object(forKey: "firstPartyHosts") as? NSArray
|
|
39
|
+
let resourceTracingSamplingRate = object(forKey: "resourceTracingSamplingRate") as? Double
|
|
40
|
+
let bundleLogsWithRum = object(forKey: "bundleLogsWithRum") as? Bool
|
|
41
|
+
let bundleLogsWithTraces = object(forKey: "bundleLogsWithTraces") as? Bool
|
|
42
|
+
|
|
33
43
|
return DdSdkConfiguration(
|
|
34
44
|
clientToken: (clientToken != nil) ? clientToken! : String(),
|
|
35
45
|
env: (env != nil) ? env! : String(),
|
|
@@ -38,20 +48,29 @@ extension NSDictionary {
|
|
|
38
48
|
nativeLongTaskThresholdMs: nativeLongTaskThresholdMs,
|
|
39
49
|
longTaskThresholdMs: (longTaskThresholdMs != nil) ? longTaskThresholdMs! : Double(),
|
|
40
50
|
sampleRate: sampleRate,
|
|
41
|
-
site: site,
|
|
42
|
-
trackingConsent: trackingConsent,
|
|
51
|
+
site: site.asSite(),
|
|
52
|
+
trackingConsent: trackingConsent.asTrackingConsent(),
|
|
43
53
|
telemetrySampleRate: telemetrySampleRate,
|
|
44
|
-
vitalsUpdateFrequency: vitalsUpdateFrequency,
|
|
54
|
+
vitalsUpdateFrequency: vitalsUpdateFrequency.asVitalsUpdateFrequency(),
|
|
45
55
|
trackFrustrations: trackFrustrations,
|
|
46
|
-
uploadFrequency: uploadFrequency,
|
|
47
|
-
batchSize: batchSize,
|
|
56
|
+
uploadFrequency: uploadFrequency.asUploadFrequency(),
|
|
57
|
+
batchSize: batchSize.asBatchSize(),
|
|
48
58
|
trackBackgroundEvents: trackBackgroundEvents,
|
|
49
59
|
customEndpoints: customEndpoints?.asCustomEndpoints(),
|
|
50
60
|
additionalConfig: additionalConfig,
|
|
51
|
-
configurationForTelemetry: configurationForTelemetry?.asConfigurationForTelemetry()
|
|
61
|
+
configurationForTelemetry: configurationForTelemetry?.asConfigurationForTelemetry(),
|
|
62
|
+
nativeViewTracking: nativeViewTracking,
|
|
63
|
+
nativeInteractionTracking: nativeInteractionTracking,
|
|
64
|
+
verbosity: verbosity,
|
|
65
|
+
proxyConfig: proxyConfig?.asProxyConfig(),
|
|
66
|
+
serviceName: serviceName,
|
|
67
|
+
firstPartyHosts: firstPartyHosts?.asFirstPartyHosts(),
|
|
68
|
+
resourceTracingSamplingRate: resourceTracingSamplingRate,
|
|
69
|
+
bundleLogsWithRum: bundleLogsWithRum ?? DefaultConfiguration.bundleLogsWithRum,
|
|
70
|
+
bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces
|
|
52
71
|
)
|
|
53
72
|
}
|
|
54
|
-
|
|
73
|
+
|
|
55
74
|
func asConfigurationForTelemetry() -> ConfigurationForTelemetry {
|
|
56
75
|
let initializationType = object(forKey: "initializationType") as? NSString
|
|
57
76
|
let trackErrors = object(forKey: "trackErrors") as? Bool
|
|
@@ -81,6 +100,46 @@ extension NSDictionary {
|
|
|
81
100
|
trace: trace
|
|
82
101
|
)
|
|
83
102
|
}
|
|
103
|
+
|
|
104
|
+
func asProxyConfig() -> [AnyHashable: Any]? {
|
|
105
|
+
guard let address = object(forKey: "address") as? String else {
|
|
106
|
+
return nil
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var proxy: [AnyHashable: Any] = [:]
|
|
110
|
+
proxy[kCFProxyUsernameKey] = object(forKey: "username")
|
|
111
|
+
proxy[kCFProxyPasswordKey] = object(forKey: "password")
|
|
112
|
+
|
|
113
|
+
let type = object(forKey: "type") as? String
|
|
114
|
+
var port = object(forKey: "port") as? Int
|
|
115
|
+
if let string = object(forKey: "port") as? String {
|
|
116
|
+
port = Int(string)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
switch type?.lowercased() {
|
|
120
|
+
case "http", "https":
|
|
121
|
+
// CFNetwork support HTTP and tunneling HTTPS proxies.
|
|
122
|
+
// As intakes will most likely be https, we enable both channels.
|
|
123
|
+
//
|
|
124
|
+
// We use constants string keys because there is an issue with
|
|
125
|
+
// cross-platform availability for proxy configuration symbols.
|
|
126
|
+
// see. https://developer.apple.com/forums/thread/19356?answerId=131709022#131709022
|
|
127
|
+
proxy["HTTPEnable"] = 1
|
|
128
|
+
proxy["HTTPProxy"] = address
|
|
129
|
+
proxy["HTTPPort"] = port
|
|
130
|
+
proxy["HTTPSEnable"] = 1
|
|
131
|
+
proxy["HTTPSProxy"] = address
|
|
132
|
+
proxy["HTTPSPort"] = port
|
|
133
|
+
case "socks":
|
|
134
|
+
proxy["SOCKSEnable"] = 1
|
|
135
|
+
proxy["SOCKSProxy"] = address
|
|
136
|
+
proxy["SOCKSPort"] = port
|
|
137
|
+
default:
|
|
138
|
+
break
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return proxy
|
|
142
|
+
}
|
|
84
143
|
}
|
|
85
144
|
|
|
86
145
|
extension NSArray {
|
|
@@ -108,7 +167,7 @@ extension NSArray {
|
|
|
108
167
|
|
|
109
168
|
func asTracingHeaderType() -> Set<TracingHeaderType> {
|
|
110
169
|
return Set(compactMap { headerType in
|
|
111
|
-
switch(headerType as? String) {
|
|
170
|
+
switch((headerType as? String)?.lowercased()) {
|
|
112
171
|
case "datadog":
|
|
113
172
|
return TracingHeaderType.datadog
|
|
114
173
|
case "b3":
|
|
@@ -123,3 +182,162 @@ extension NSArray {
|
|
|
123
182
|
})
|
|
124
183
|
}
|
|
125
184
|
}
|
|
185
|
+
|
|
186
|
+
internal struct DefaultConfiguration {
|
|
187
|
+
static let nativeCrashReportEnabled = false
|
|
188
|
+
static let sessionSamplingRate = 100.0
|
|
189
|
+
static let resourceTracingSamplingRate = 20.0
|
|
190
|
+
static let longTaskThresholdMs = 0.0
|
|
191
|
+
static let nativeLongTaskThresholdMs = 200.0
|
|
192
|
+
static let nativeViewTracking = false
|
|
193
|
+
static let nativeInteractionTracking = false
|
|
194
|
+
static let firstPartyHosts: [String: Set<TracingHeaderType>] = [:]
|
|
195
|
+
static let telemetrySampleRate = 20.0
|
|
196
|
+
static let trackFrustrations = true
|
|
197
|
+
static let trackBackgroundEvents = false
|
|
198
|
+
static let bundleLogsWithRum = true
|
|
199
|
+
static let bundleLogsWithTraces = true
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
extension Dictionary where Key == String, Value == AnyObject {
|
|
203
|
+
func asDdSdkConfigurationFromJSON() throws -> DdSdkConfiguration {
|
|
204
|
+
guard let configuration = self["configuration"] as? Dictionary<String, Any?> else {
|
|
205
|
+
throw ProgrammerError(description: "JSON configuration file is missing top-level \"configuration\" key.")
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let clientToken = configuration["clientToken"] as? String
|
|
209
|
+
let env = configuration["env"] as? String
|
|
210
|
+
let applicationId = configuration["applicationId"] as? String
|
|
211
|
+
let nativeCrashReportEnabled = configuration["nativeCrashReportEnabled"] as? Bool
|
|
212
|
+
let nativeLongTaskThresholdMs = configuration["nativeLongTaskThresholdMs"] as? Double
|
|
213
|
+
let longTaskThresholdMs = configuration["longTaskThresholdMs"] as? Double
|
|
214
|
+
let sampleRate = configuration["sessionSamplingRate"] as? Double
|
|
215
|
+
let site = configuration["site"] as? NSString
|
|
216
|
+
let trackingConsent = configuration["trackingConsent"] as? NSString
|
|
217
|
+
let telemetrySampleRate = configuration["telemetrySampleRate"] as? Double
|
|
218
|
+
let vitalsUpdateFrequency = configuration["vitalsUpdateFrequency"] as? NSString
|
|
219
|
+
let trackFrustrations = configuration["trackFrustrations"] as? Bool
|
|
220
|
+
let uploadFrequency = configuration["uploadFrequency"] as? NSString
|
|
221
|
+
let batchSize = configuration["batchSize"] as? NSString
|
|
222
|
+
let trackBackgroundEvents = configuration["trackBackgroundEvents"] as? Bool
|
|
223
|
+
let customEndpoints = configuration["customEndpoints"] as? NSDictionary
|
|
224
|
+
let configurationForTelemetry = configuration["configurationForTelemetry"] as? NSDictionary
|
|
225
|
+
let nativeViewTracking = configuration["nativeViewTracking"] as? Bool
|
|
226
|
+
let nativeInteractionTracking = configuration["nativeInteractionTracking"] as? Bool
|
|
227
|
+
let verbosity = configuration["verbosity"] as? NSString
|
|
228
|
+
let proxyConfig = configuration["proxy"] as? NSDictionary
|
|
229
|
+
let serviceName = configuration["serviceName"] as? NSString
|
|
230
|
+
let firstPartyHosts = configuration["firstPartyHosts"] as? NSArray
|
|
231
|
+
let resourceTracingSamplingRate = configuration["resourceTracingSamplingRate"] as? Double
|
|
232
|
+
let bundleLogsWithRum = configuration["bundleLogsWithRum"] as? Bool
|
|
233
|
+
let bundleLogsWithTraces = configuration["bundleLogsWithTraces"] as? Bool
|
|
234
|
+
|
|
235
|
+
return DdSdkConfiguration(
|
|
236
|
+
clientToken: clientToken ?? String(),
|
|
237
|
+
env: env ?? String(),
|
|
238
|
+
applicationId: applicationId ?? String(),
|
|
239
|
+
nativeCrashReportEnabled: nativeCrashReportEnabled ?? DefaultConfiguration.nativeCrashReportEnabled,
|
|
240
|
+
nativeLongTaskThresholdMs: nativeLongTaskThresholdMs ?? DefaultConfiguration.nativeLongTaskThresholdMs,
|
|
241
|
+
longTaskThresholdMs: (longTaskThresholdMs != nil) ? longTaskThresholdMs! : DefaultConfiguration.longTaskThresholdMs,
|
|
242
|
+
sampleRate: sampleRate ?? DefaultConfiguration.sessionSamplingRate,
|
|
243
|
+
site: site.asSite(),
|
|
244
|
+
trackingConsent: trackingConsent.asTrackingConsent(),
|
|
245
|
+
telemetrySampleRate: telemetrySampleRate ?? DefaultConfiguration.telemetrySampleRate,
|
|
246
|
+
vitalsUpdateFrequency: vitalsUpdateFrequency.asVitalsUpdateFrequency(),
|
|
247
|
+
trackFrustrations: trackFrustrations ?? DefaultConfiguration.trackFrustrations,
|
|
248
|
+
uploadFrequency: uploadFrequency.asUploadFrequency(),
|
|
249
|
+
batchSize: batchSize.asBatchSize(),
|
|
250
|
+
trackBackgroundEvents: trackBackgroundEvents ?? DefaultConfiguration.trackBackgroundEvents,
|
|
251
|
+
customEndpoints: customEndpoints?.asCustomEndpoints(),
|
|
252
|
+
additionalConfig: [
|
|
253
|
+
CrossPlatformAttributes.ddsource: "react-native",
|
|
254
|
+
CrossPlatformAttributes.sdkVersion: SdkVersion
|
|
255
|
+
],
|
|
256
|
+
configurationForTelemetry: configurationForTelemetry?.asConfigurationForTelemetry(),
|
|
257
|
+
nativeViewTracking: nativeViewTracking ?? DefaultConfiguration.nativeViewTracking,
|
|
258
|
+
nativeInteractionTracking: nativeInteractionTracking ?? DefaultConfiguration.nativeInteractionTracking,
|
|
259
|
+
verbosity: verbosity,
|
|
260
|
+
proxyConfig: proxyConfig?.asProxyConfig(),
|
|
261
|
+
serviceName: serviceName,
|
|
262
|
+
firstPartyHosts: firstPartyHosts?.asFirstPartyHosts() ?? DefaultConfiguration.firstPartyHosts,
|
|
263
|
+
resourceTracingSamplingRate: resourceTracingSamplingRate ?? DefaultConfiguration.resourceTracingSamplingRate,
|
|
264
|
+
bundleLogsWithRum: bundleLogsWithRum ?? DefaultConfiguration.bundleLogsWithRum,
|
|
265
|
+
bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
extension NSString? {
|
|
271
|
+
func asTrackingConsent() -> TrackingConsent {
|
|
272
|
+
switch self?.lowercased {
|
|
273
|
+
case "pending":
|
|
274
|
+
return .pending
|
|
275
|
+
case "granted":
|
|
276
|
+
return .granted
|
|
277
|
+
case "not_granted":
|
|
278
|
+
return .notGranted
|
|
279
|
+
default:
|
|
280
|
+
return .pending
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
func asVitalsUpdateFrequency() -> RUM.Configuration.VitalsFrequency? {
|
|
285
|
+
switch self?.lowercased {
|
|
286
|
+
case "never":
|
|
287
|
+
return nil
|
|
288
|
+
case "rare":
|
|
289
|
+
return .rare
|
|
290
|
+
case "average":
|
|
291
|
+
return .average
|
|
292
|
+
case "frequent":
|
|
293
|
+
return .frequent
|
|
294
|
+
default:
|
|
295
|
+
return .average
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
func asUploadFrequency() -> Datadog.Configuration.UploadFrequency {
|
|
300
|
+
switch self?.lowercased {
|
|
301
|
+
case "rare":
|
|
302
|
+
return .rare
|
|
303
|
+
case "average":
|
|
304
|
+
return .average
|
|
305
|
+
case "frequent":
|
|
306
|
+
return .frequent
|
|
307
|
+
default:
|
|
308
|
+
return .average
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
func asBatchSize() -> Datadog.Configuration.BatchSize {
|
|
313
|
+
switch self?.lowercased {
|
|
314
|
+
case "small":
|
|
315
|
+
return .small
|
|
316
|
+
case "medium":
|
|
317
|
+
return .medium
|
|
318
|
+
case "large":
|
|
319
|
+
return .large
|
|
320
|
+
default:
|
|
321
|
+
return .medium
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
func asSite() -> DatadogSite {
|
|
326
|
+
switch self?.lowercased {
|
|
327
|
+
case "us1", "us":
|
|
328
|
+
return .us1
|
|
329
|
+
case "eu1", "eu":
|
|
330
|
+
return .eu1
|
|
331
|
+
case "us3":
|
|
332
|
+
return .us3
|
|
333
|
+
case "us5":
|
|
334
|
+
return .us5
|
|
335
|
+
case "us1_fed", "gov":
|
|
336
|
+
return .us1_fed
|
|
337
|
+
case "ap1":
|
|
338
|
+
return .ap1
|
|
339
|
+
default:
|
|
340
|
+
return .us1
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
// This is automatically updated by the update-version.sh script
|
|
10
|
+
let SdkVersion = "2.3.0"
|
|
@@ -11,8 +11,6 @@ var _DdSdkReactNativeConfiguration = require("./DdSdkReactNativeConfiguration");
|
|
|
11
11
|
|
|
12
12
|
var _InternalLog = require("./InternalLog");
|
|
13
13
|
|
|
14
|
-
var _ProxyConfiguration = require("./ProxyConfiguration");
|
|
15
|
-
|
|
16
14
|
var _SdkVerbosity = require("./SdkVerbosity");
|
|
17
15
|
|
|
18
16
|
var _DdLogs = require("./logs/DdLogs");
|
|
@@ -31,6 +29,8 @@ var _BufferSingleton = require("./sdk/DatadogProvider/Buffer/BufferSingleton");
|
|
|
31
29
|
|
|
32
30
|
var _DdSdk = require("./sdk/DdSdk");
|
|
33
31
|
|
|
32
|
+
var _FileBasedConfiguration = require("./sdk/FileBasedConfiguration/FileBasedConfiguration");
|
|
33
|
+
|
|
34
34
|
var _UserInfoSingleton = require("./sdk/UserInfoSingleton/UserInfoSingleton");
|
|
35
35
|
|
|
36
36
|
var _types = require("./types");
|
|
@@ -45,8 +45,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
45
45
|
* This class initializes the Datadog SDK, and sets up communication with the server.
|
|
46
46
|
*/
|
|
47
47
|
class DdSdkReactNative {
|
|
48
|
-
// Proxy
|
|
49
|
-
|
|
50
48
|
/**
|
|
51
49
|
* Initializes the Datadog SDK.
|
|
52
50
|
* @param configuration the configuration for the SDK library
|
|
@@ -59,6 +57,12 @@ class DdSdkReactNative {
|
|
|
59
57
|
static async _initializeFromDatadogProvider(configuration) {
|
|
60
58
|
DdSdkReactNative.enableFeatures(configuration);
|
|
61
59
|
|
|
60
|
+
if (configuration instanceof _FileBasedConfiguration.FileBasedConfiguration) {
|
|
61
|
+
return DdSdkReactNative.initializeNativeSDK(configuration, {
|
|
62
|
+
initializationModeForTelemetry: 'FILE'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
62
66
|
if (configuration.initializationMode === _DdSdkReactNativeConfiguration.InitializationMode.SYNC) {
|
|
63
67
|
return DdSdkReactNative.initializeNativeSDK(configuration, {
|
|
64
68
|
initializationModeForTelemetry: 'SYNC'
|
|
@@ -145,28 +149,10 @@ _defineProperty(DdSdkReactNative, "DD_SOURCE_KEY", '_dd.source');
|
|
|
145
149
|
|
|
146
150
|
_defineProperty(DdSdkReactNative, "DD_SDK_VERSION", '_dd.sdk_version');
|
|
147
151
|
|
|
148
|
-
_defineProperty(DdSdkReactNative, "DD_SERVICE_NAME", '_dd.service_name');
|
|
149
|
-
|
|
150
|
-
_defineProperty(DdSdkReactNative, "DD_SDK_VERBOSITY_KEY", '_dd.sdk_verbosity');
|
|
151
|
-
|
|
152
|
-
_defineProperty(DdSdkReactNative, "DD_NATIVE_VIEW_TRACKING_KEY", '_dd.native_view_tracking');
|
|
153
|
-
|
|
154
|
-
_defineProperty(DdSdkReactNative, "DD_NATIVE_INTERACTION_TRACKING_KEY", '_dd.native_interaction_tracking');
|
|
155
|
-
|
|
156
152
|
_defineProperty(DdSdkReactNative, "DD_VERSION", '_dd.version');
|
|
157
153
|
|
|
158
154
|
_defineProperty(DdSdkReactNative, "DD_VERSION_SUFFIX", '_dd.version_suffix');
|
|
159
155
|
|
|
160
|
-
_defineProperty(DdSdkReactNative, "DD_PROXY_TYPE_KEY", '_dd.proxy.type');
|
|
161
|
-
|
|
162
|
-
_defineProperty(DdSdkReactNative, "DD_PROXY_ADDRESS_KEY", '_dd.proxy.address');
|
|
163
|
-
|
|
164
|
-
_defineProperty(DdSdkReactNative, "DD_PROXY_PORT_KEY", '_dd.proxy.port');
|
|
165
|
-
|
|
166
|
-
_defineProperty(DdSdkReactNative, "DD_PROXY_USERNAME_KEY", '_dd.proxy.username');
|
|
167
|
-
|
|
168
|
-
_defineProperty(DdSdkReactNative, "DD_PROXY_PASSWORD_KEY", '_dd.proxy.password');
|
|
169
|
-
|
|
170
156
|
_defineProperty(DdSdkReactNative, "wasInitialized", false);
|
|
171
157
|
|
|
172
158
|
_defineProperty(DdSdkReactNative, "wasAutoInstrumented", false);
|
|
@@ -192,17 +178,7 @@ _defineProperty(DdSdkReactNative, "initializeNativeSDK", async (configuration, p
|
|
|
192
178
|
}
|
|
193
179
|
|
|
194
180
|
_InternalLog.InternalLog.verbosity = configuration.verbosity;
|
|
195
|
-
DdSdkReactNative.buildConfiguration(configuration);
|
|
196
|
-
await _DdSdk.DdSdk.initialize(new _types.DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, (0, _longTasksUtils.adaptLongTaskThreshold)(configuration.nativeLongTaskThresholdMs), (0, _longTasksUtils.adaptLongTaskThreshold)(configuration.longTaskThresholdMs), configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig, configuration.telemetrySampleRate, configuration.vitalsUpdateFrequency, configuration.uploadFrequency, configuration.batchSize, configuration.trackFrustrations, configuration.trackBackgroundEvents, configuration.customEndpoints, {
|
|
197
|
-
initializationType: params.initializationModeForTelemetry,
|
|
198
|
-
trackErrors: configuration.trackErrors,
|
|
199
|
-
trackInteractions: configuration.trackInteractions,
|
|
200
|
-
trackNetworkRequests: configuration.trackResources,
|
|
201
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
202
|
-
reactNativeVersion: require('react-native/package.json').version,
|
|
203
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
204
|
-
reactVersion: require('react/package.json').version
|
|
205
|
-
}));
|
|
181
|
+
await _DdSdk.DdSdk.initialize(DdSdkReactNative.buildConfiguration(configuration, params));
|
|
206
182
|
|
|
207
183
|
_InternalLog.InternalLog.log('Datadog SDK was initialized', _SdkVerbosity.SdkVerbosity.INFO);
|
|
208
184
|
|
|
@@ -251,47 +227,29 @@ _defineProperty(DdSdkReactNative, "clearAllData", () => {
|
|
|
251
227
|
return _DdSdk.DdSdk.clearAllData();
|
|
252
228
|
});
|
|
253
229
|
|
|
254
|
-
_defineProperty(DdSdkReactNative, "buildConfiguration", configuration => {
|
|
255
|
-
configuration.
|
|
256
|
-
configuration.
|
|
257
|
-
configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY] = configuration.nativeViewTracking;
|
|
258
|
-
configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_INTERACTION_TRACKING_KEY] = configuration.nativeInteractionTracking;
|
|
259
|
-
|
|
260
|
-
if (configuration.verbosity) {
|
|
261
|
-
configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERBOSITY_KEY] = configuration.verbosity;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (configuration.proxyConfig) {
|
|
265
|
-
const additionalConfig = configuration.additionalConfig;
|
|
266
|
-
const proxyConfig = configuration.proxyConfig;
|
|
267
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] = proxyConfig.type;
|
|
268
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] = proxyConfig.address;
|
|
269
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] = proxyConfig.port;
|
|
270
|
-
|
|
271
|
-
if (proxyConfig.username && proxyConfig.password) {
|
|
272
|
-
if (proxyConfig.type === _ProxyConfiguration.ProxyType.SOCKS) {
|
|
273
|
-
console.warn("SOCKS proxy configuration doesn't support Basic authentication.");
|
|
274
|
-
} else {
|
|
275
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] = proxyConfig.username;
|
|
276
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] = proxyConfig.password;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (configuration.serviceName) {
|
|
282
|
-
configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] = configuration.serviceName;
|
|
283
|
-
}
|
|
230
|
+
_defineProperty(DdSdkReactNative, "buildConfiguration", (configuration, params) => {
|
|
231
|
+
configuration.additionalConfiguration[DdSdkReactNative.DD_SOURCE_KEY] = 'react-native';
|
|
232
|
+
configuration.additionalConfiguration[DdSdkReactNative.DD_SDK_VERSION] = _version.version;
|
|
284
233
|
|
|
285
234
|
if (configuration.version) {
|
|
286
|
-
configuration.
|
|
235
|
+
configuration.additionalConfiguration[DdSdkReactNative.DD_VERSION] = `${configuration.version}${configuration.versionSuffix ? `-${configuration.versionSuffix}` : ''}`;
|
|
287
236
|
} // If both version and version suffix are provided, we merge them into the version field.
|
|
288
237
|
// To avoid adding it in again the native part, we only set it if the version isn't set.
|
|
289
238
|
|
|
290
239
|
|
|
291
240
|
if (configuration.versionSuffix && !configuration.version) {
|
|
292
|
-
configuration.
|
|
241
|
+
configuration.additionalConfiguration[DdSdkReactNative.DD_VERSION_SUFFIX] = `-${configuration.versionSuffix}`;
|
|
293
242
|
}
|
|
294
243
|
|
|
295
|
-
configuration.
|
|
244
|
+
return new _types.DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, (0, _longTasksUtils.adaptLongTaskThreshold)(configuration.nativeLongTaskThresholdMs), (0, _longTasksUtils.adaptLongTaskThreshold)(configuration.longTaskThresholdMs), configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfiguration, configuration.telemetrySampleRate, configuration.vitalsUpdateFrequency, configuration.uploadFrequency, configuration.batchSize, configuration.trackFrustrations, configuration.trackBackgroundEvents, configuration.customEndpoints, {
|
|
245
|
+
initializationType: params.initializationModeForTelemetry,
|
|
246
|
+
trackErrors: configuration.trackErrors,
|
|
247
|
+
trackInteractions: configuration.trackInteractions,
|
|
248
|
+
trackNetworkRequests: configuration.trackResources,
|
|
249
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
250
|
+
reactNativeVersion: require('react-native/package.json').version,
|
|
251
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
252
|
+
reactVersion: require('react/package.json').version
|
|
253
|
+
}, configuration.nativeViewTracking, configuration.nativeInteractionTracking, configuration.verbosity, configuration.proxyConfig, configuration.serviceName, (0, _DdSdkReactNativeConfiguration.formatFirstPartyHosts)(configuration.firstPartyHosts), configuration.bundleLogsWithRum, configuration.bundleLogsWithTraces);
|
|
296
254
|
});
|
|
297
255
|
//# sourceMappingURL=DdSdkReactNative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","_initializeFromDatadogProvider","configuration","enableFeatures","initializationMode","InitializationMode","SYNC","initializeNativeSDK","initializationModeForTelemetry","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","wasAutoInstrumented","InternalLog","log","SdkVerbosity","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","actionNameAttribute","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","DdSdk","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","initialize","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","customEndpoints","initializationType","trackNetworkRequests","reactNativeVersion","require","version","reactVersion","INFO","BufferSingleton","onInitialization","attributes","JSON","stringify","DEBUG","setAttributes","AttributesSingleton","getInstance","user","setUser","UserInfoSingleton","setUserInfo","consent","setTrackingConsent","clearAllData","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_NATIVE_INTERACTION_TRACKING_KEY","nativeInteractionTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","ProxyType","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;;;;;;AAMA;;AAEA;;AAcA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;A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;AAEDtH,EAAAA,aAAa,CAAC6D,gBAAd,CACI,uBADJ,IAEI,0DAAsB7D,aAAa,CAAC0B,eAApC,CAFJ;AAGH,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 {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { adaptLongTaskThreshold } from './utils/longTasksUtils';\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_NATIVE_INTERACTION_TRACKING_KEY =\n '_dd.native_interaction_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 wasInitialized = false;\n private static wasAutoInstrumented = false;\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 initialize = async (\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> => {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n };\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\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 adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n configuration.customEndpoints,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n }\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 if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\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 _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 { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes = async (attributes: Attributes): Promise<void> => {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().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 = async (user: UserInfo): Promise<void> => {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(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 /**\n * Clears all data that has not already been sent to Datadog servers\n * @returns a Promise\n */\n static clearAllData = (): Promise<void> => {\n InternalLog.log('Clearing all data', SdkVerbosity.DEBUG);\n return DdSdk.clearAllData();\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 configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_INTERACTION_TRACKING_KEY\n ] = configuration.nativeInteractionTracking;\n\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 '_dd.first_party_hosts'\n ] = formatFirstPartyHosts(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 actionNameAttribute: configuration.actionNameAttribute\n });\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","_initializeFromDatadogProvider","configuration","enableFeatures","FileBasedConfiguration","initializeNativeSDK","initializationModeForTelemetry","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","wasAutoInstrumented","InternalLog","log","SdkVerbosity","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","actionNameAttribute","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","DdSdk","telemetryDebug","Promise","resolve","verbosity","initialize","buildConfiguration","INFO","BufferSingleton","onInitialization","attributes","JSON","stringify","DEBUG","setAttributes","AttributesSingleton","getInstance","user","setUser","UserInfoSingleton","setUserInfo","consent","setTrackingConsent","clearAllData","additionalConfiguration","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","version","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","customEndpoints","initializationType","trackNetworkRequests","reactNativeVersion","require","reactVersion","nativeViewTracking","nativeInteractionTracking","proxyConfig","serviceName","bundleLogsWithRum","bundleLogsWithTraces"],"mappings":";;;;;;;AAMA;;AAEA;;AAcA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,gBAAN,CAAuB;AAU1B;AACJ;AACA;AACA;AACA;;AAuCI;AACJ;AACA;AAC+C,eAA9BC,8BAA8B,CACvCC,aADuC,EAE1B;AACbF,IAAAA,gBAAgB,CAACG,cAAjB,CAAgCD,aAAhC;;AACA,QAAIA,aAAa,YAAYE,8CAA7B,EAAqD;AACjD,aAAOJ,gBAAgB,CAACK,mBAAjB,CAAqCH,aAArC,EAAoD;AACvDI,QAAAA,8BAA8B,EAAE;AADuB,OAApD,CAAP;AAGH;;AACD,QAAIJ,aAAa,CAACK,kBAAd,KA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UAAd,KAA6BC,SAA7B,GACMnF,aAAa,CAACoF,mBADpB,GAEMpF,aAAa,CAACkF,UATjB,EAUHlF,aAAa,CAACqF,IAVX,EAWHrF,aAAa,CAACsF,eAXX,EAYHtF,aAAa,CAACmE,uBAZX,EAaHnE,aAAa,CAACuF,mBAbX,EAcHvF,aAAa,CAACwF,qBAdX,EAeHxF,aAAa,CAACyF,eAfX,EAgBHzF,aAAa,CAAC0F,SAhBX,EAiBH1F,aAAa,CAAC2F,iBAjBX,EAkBH3F,aAAa,CAAC4F,qBAlBX,EAmBH5F,aAAa,CAAC6F,eAnBX,EAoBH;AACIC,IAAAA,kBAAkB,EAAEtD,MAAM,CAACpC,8BAD/B;AAEIwB,IAAAA,WAAW,EAAE5B,aAAa,CAAC4B,WAF/B;AAGIT,IAAAA,iBAAiB,EAAEnB,aAAa,CAACmB,iBAHrC;AAII4E,IAAAA,oBAAoB,EAAE/F,aAAa,CAACuB,cAJxC;AAKI;AACAyE,IAAAA,kBAAkB,EAAEC,OAAO,CAAC,2BAAD,CAAP,CACf1B,OAPT;AAQI;AACA2B,IAAAA,YAAY,EAAED,OAAO,CAAC,oBAAD,CAAP,CAA8B1B;AAThD,GApBG,EA+BHvE,aAAa,CAACmG,kBA/BX,EAgCHnG,aAAa,CAACoG,yBAhCX,EAiCHpG,aAAa,CAAC+C,SAjCX,EAkCH/C,aAAa,CAACqG,WAlCX,EAmCHrG,aAAa,CAACsG,WAnCX,EAoCH,0DAAsBtG,aAAa,CAAC2B,eAApC,CApCG,EAqCH3B,aAAa,CAACuG,iBArCX,EAsCHvG,aAAa,CAACwG,oBAtCX,CAAP;AAwCH,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 {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { FileBasedConfiguration } from './sdk/FileBasedConfiguration/FileBasedConfiguration';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { adaptLongTaskThreshold } from './utils/longTasksUtils';\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_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n private static wasInitialized = false;\n private static wasAutoInstrumented = false;\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 initialize = async (\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> => {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n };\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\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 await DdSdk.initialize(\n DdSdkReactNative.buildConfiguration(configuration, params)\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 if (configuration instanceof FileBasedConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'FILE'\n });\n }\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\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 _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 { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes = async (attributes: Attributes): Promise<void> => {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().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 = async (user: UserInfo): Promise<void> => {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(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 /**\n * Clears all data that has not already been sent to Datadog servers\n * @returns a Promise\n */\n static clearAllData = (): Promise<void> => {\n InternalLog.log('Clearing all data', SdkVerbosity.DEBUG);\n return DdSdk.clearAllData();\n };\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): DdSdkConfiguration => {\n configuration.additionalConfiguration[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n\n if (configuration.version) {\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_VERSION\n ] = `${configuration.version}${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\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.additionalConfiguration[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n return new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfiguration,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n configuration.customEndpoints,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n },\n configuration.nativeViewTracking,\n configuration.nativeInteractionTracking,\n configuration.verbosity,\n configuration.proxyConfig,\n configuration.serviceName,\n formatFirstPartyHosts(configuration.firstPartyHosts),\n configuration.bundleLogsWithRum,\n configuration.bundleLogsWithTraces\n );\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 actionNameAttribute: configuration.actionNameAttribute\n });\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.formatFirstPartyHosts = exports.BatchSize = exports.UploadFrequency = exports.VitalsUpdateFrequency = void 0;
|
|
6
|
+
exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.DEFAULTS = exports.formatFirstPartyHosts = exports.BatchSize = exports.UploadFrequency = exports.VitalsUpdateFrequency = void 0;
|
|
7
7
|
|
|
8
8
|
var _TrackingConsent = require("./TrackingConsent");
|
|
9
9
|
|
|
@@ -71,7 +71,7 @@ const DEFAULTS = {
|
|
|
71
71
|
nativeViewTracking: false,
|
|
72
72
|
nativeInteractionTracking: false,
|
|
73
73
|
getFirstPartyHosts: () => [],
|
|
74
|
-
|
|
74
|
+
getAdditionalConfiguration: () => ({}),
|
|
75
75
|
trackingConsent: _TrackingConsent.TrackingConsent.GRANTED,
|
|
76
76
|
telemetrySampleRate: 20.0,
|
|
77
77
|
vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,
|
|
@@ -83,13 +83,17 @@ const DEFAULTS = {
|
|
|
83
83
|
uploadFrequency: UploadFrequency.AVERAGE,
|
|
84
84
|
batchSize: BatchSize.MEDIUM,
|
|
85
85
|
trackBackgroundEvents: false,
|
|
86
|
-
getCustomEndpoints: () => ({})
|
|
86
|
+
getCustomEndpoints: () => ({}),
|
|
87
|
+
bundleLogsWithRum: true,
|
|
88
|
+
bundleLogsWithTraces: true
|
|
87
89
|
};
|
|
88
90
|
/**
|
|
89
91
|
* The SDK configuration class.
|
|
90
92
|
* It will be used to configure the SDK functionality at initialization.
|
|
91
93
|
*/
|
|
92
94
|
|
|
95
|
+
exports.DEFAULTS = DEFAULTS;
|
|
96
|
+
|
|
93
97
|
class DdSdkReactNativeConfiguration {
|
|
94
98
|
/**
|
|
95
99
|
* Enables crash reporting for native platforms (iOS, Android). Default `false`.
|
|
@@ -203,6 +207,18 @@ class DdSdkReactNativeConfiguration {
|
|
|
203
207
|
* number of sessions tracked and impact your billing.
|
|
204
208
|
*/
|
|
205
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Enables RUM correlation with logs.
|
|
212
|
+
*
|
|
213
|
+
* By default, RUM is enabled for logs.
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Enables Traces correlation with logs.
|
|
218
|
+
*
|
|
219
|
+
* By default, Traces is enabled for logs.
|
|
220
|
+
*/
|
|
221
|
+
|
|
206
222
|
/**
|
|
207
223
|
* Specifies a custom prop to name RUM actions on elements having an `onPress` prop.
|
|
208
224
|
*
|
|
@@ -265,6 +281,10 @@ class DdSdkReactNativeConfiguration {
|
|
|
265
281
|
|
|
266
282
|
_defineProperty(this, "trackBackgroundEvents", DEFAULTS.trackBackgroundEvents);
|
|
267
283
|
|
|
284
|
+
_defineProperty(this, "bundleLogsWithRum", DEFAULTS.bundleLogsWithRum);
|
|
285
|
+
|
|
286
|
+
_defineProperty(this, "bundleLogsWithTraces", DEFAULTS.bundleLogsWithTraces);
|
|
287
|
+
|
|
268
288
|
_defineProperty(this, "actionNameAttribute", void 0);
|
|
269
289
|
|
|
270
290
|
_defineProperty(this, "logEventMapper", DEFAULTS.logEventMapper);
|
|
@@ -275,7 +295,7 @@ class DdSdkReactNativeConfiguration {
|
|
|
275
295
|
|
|
276
296
|
_defineProperty(this, "actionEventMapper", DEFAULTS.actionEventMapper);
|
|
277
297
|
|
|
278
|
-
_defineProperty(this, "
|
|
298
|
+
_defineProperty(this, "additionalConfiguration", DEFAULTS.getAdditionalConfiguration());
|
|
279
299
|
|
|
280
300
|
_defineProperty(this, "customEndpoints", DEFAULTS.getCustomEndpoints());
|
|
281
301
|
}
|