@datadog/mobile-react-native 1.3.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +2 -2
- package/android/build.gradle +5 -5
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +4 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +6 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +155 -92
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +2 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +16 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +293 -30
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +5 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +7 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +2 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +10 -0
- package/datadog-sourcemaps.gradle +55 -7
- package/ios/Sources/DdSdk.m +4 -0
- package/ios/Sources/DdSdk.swift +19 -2
- package/ios/Sources/DdSdkConfiguration.swift +6 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +44 -0
- package/jest/mock.js +1 -1
- package/lib/commonjs/DdSdkReactNative.js +3 -3
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +34 -2
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -5
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +101 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +136 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.js +39 -6
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.js +4 -4
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js +2 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.js +15 -24
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.js +2 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -0
- package/lib/commonjs/rum/types.js +19 -1
- package/lib/commonjs/rum/types.js.map +1 -1
- 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/DdSdkReactNative.js +4 -4
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +30 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +6 -6
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +93 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +115 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.js +37 -3
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.js +4 -4
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js +2 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.js +13 -18
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.js +2 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -0
- package/lib/module/rum/types.js +16 -0
- package/lib/module/rum/types.js.map +1 -1
- 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/DdSdkReactNativeConfiguration.d.ts +16 -3
- package/lib/typescript/index.d.ts +3 -3
- package/lib/typescript/nativeModulesTypes.d.ts +5 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +2 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +45 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +21 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.d.ts +2 -7
- package/lib/typescript/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.d.ts +6 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.d.ts +1 -1
- package/lib/typescript/rum/types.d.ts +17 -0
- package/lib/typescript/types.d.ts +2 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +76 -76
- package/src/DdSdkReactNative.tsx +9 -4
- package/src/DdSdkReactNativeConfiguration.tsx +44 -4
- package/src/__tests__/DdSdkReactNative.test.tsx +16 -4
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -2
- package/src/index.tsx +6 -3
- package/src/nativeModulesTypes.ts +6 -0
- package/src/rum/__tests__/DdRum.test.ts +17 -1
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +10 -7
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +13 -2
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +71 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/firstPartyHosts.test.ts +34 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +131 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +141 -0
- package/src/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.ts +42 -7
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.ts +6 -6
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -2
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/__utils__/ResourceMockFactory.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.ts +3 -3
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.ts +13 -28
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/__tests__/XHRProxy.test.ts +257 -79
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.ts +2 -2
- package/src/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.ts +8 -1
- package/src/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.ts +1 -1
- package/src/rum/types.ts +19 -0
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -0
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +1 -1
- package/src/types.tsx +1 -0
- package/src/version.ts +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js +0 -83
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js +0 -71
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +0 -19
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +0 -6
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/distributedTracing.test.ts +0 -31
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +0 -22
- package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +0 -89
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.js +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js.map +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.js +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js.map +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.js +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js.map +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.js +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js.map +0 -0
- /package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.d.ts +0 -0
- /package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.d.ts +0 -0
- /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +0 -0
- /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.ts +0 -0
- /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/__tests__/URLHostParser.test.ts +0 -0
package/ios/Sources/DdSdk.swift
CHANGED
|
@@ -116,6 +116,16 @@ class RNDdSdk: NSObject {
|
|
|
116
116
|
resolve(nil)
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
@objc(consumeWebviewEvent:withResolver:withRejecter:)
|
|
120
|
+
func consumeWebviewEvent(message: NSString, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
121
|
+
do{
|
|
122
|
+
try Datadog._internal.webEventBridge.send(message)
|
|
123
|
+
} catch {
|
|
124
|
+
Datadog._internal.telemetry.error(id: "datadog_react_native:\(error.localizedDescription)", message: "The message being sent was:\(message)" as String, kind: "WebViewEventBridgeError" as String, stack: String(describing: error) as String)
|
|
125
|
+
}
|
|
126
|
+
resolve(nil)
|
|
127
|
+
}
|
|
128
|
+
|
|
119
129
|
func sendConfigurationAsTelemetry(rnConfiguration: DdSdkConfiguration) -> Void {
|
|
120
130
|
Datadog._internal.telemetry.setConfigurationMapper { event in
|
|
121
131
|
var event = event
|
|
@@ -165,6 +175,8 @@ class RNDdSdk: NSObject {
|
|
|
165
175
|
_ = ddConfigBuilder.set(endpoint: .us5)
|
|
166
176
|
case "us1_fed", "gov":
|
|
167
177
|
_ = ddConfigBuilder.set(endpoint: .us1_fed)
|
|
178
|
+
case "ap1":
|
|
179
|
+
_ = ddConfigBuilder.set(endpoint: .ap1)
|
|
168
180
|
default:
|
|
169
181
|
_ = ddConfigBuilder.set(endpoint: .us1)
|
|
170
182
|
}
|
|
@@ -174,6 +186,10 @@ class RNDdSdk: NSObject {
|
|
|
174
186
|
if var telemetrySampleRate = (configuration.telemetrySampleRate as? NSNumber)?.floatValue {
|
|
175
187
|
_ = ddConfigBuilder.set(sampleTelemetry: telemetrySampleRate)
|
|
176
188
|
}
|
|
189
|
+
|
|
190
|
+
if var trackFrustrations = (configuration.trackFrustrations) {
|
|
191
|
+
_ = ddConfigBuilder.trackFrustrations(trackFrustrations)
|
|
192
|
+
}
|
|
177
193
|
|
|
178
194
|
if let threshold = configuration.nativeLongTaskThresholdMs as? TimeInterval {
|
|
179
195
|
if (threshold != 0) {
|
|
@@ -205,8 +221,9 @@ class RNDdSdk: NSObject {
|
|
|
205
221
|
_ = ddConfigBuilder.set(serviceName: serviceName)
|
|
206
222
|
}
|
|
207
223
|
|
|
208
|
-
if let firstPartyHosts = additionalConfig?[InternalConfigurationAttributes.firstPartyHosts] as?
|
|
209
|
-
|
|
224
|
+
if let firstPartyHosts = additionalConfig?[InternalConfigurationAttributes.firstPartyHosts] as? NSArray {
|
|
225
|
+
// We will always fall under this condition as firstPartyHosts is an empty array by default
|
|
226
|
+
_ = ddConfigBuilder.trackURLSession(firstPartyHostsWithHeaderTypes: firstPartyHosts.asFirstPartyHosts())
|
|
210
227
|
}
|
|
211
228
|
|
|
212
229
|
if let proxyConfiguration = buildProxyConfiguration(config: additionalConfig) {
|
|
@@ -19,7 +19,10 @@ import Foundation
|
|
|
19
19
|
- site: The Datadog site of your organization (can be 'US1', 'US1_FED', 'US3', 'US5', or 'EU1', default is 'US1').
|
|
20
20
|
- trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
21
21
|
- telemetrySampleRate: The sample rate (between 0 and 100) of telemetry events.
|
|
22
|
+
- vitalsUpdateFrequency: The frequency at which to measure vitals performance metrics.
|
|
23
|
+
- trackFrustrations: Whether to track frustration signals or not.
|
|
22
24
|
- additionalConfig: Additional configuration parameters.
|
|
25
|
+
- configurationForTelemetry: Additional configuration paramters only used for telemetry purposes.
|
|
23
26
|
*/
|
|
24
27
|
@objc(DdSdkConfiguration)
|
|
25
28
|
public class DdSdkConfiguration: NSObject {
|
|
@@ -34,6 +37,7 @@ public class DdSdkConfiguration: NSObject {
|
|
|
34
37
|
public var trackingConsent: NSString? = nil
|
|
35
38
|
public var telemetrySampleRate: Double? = nil
|
|
36
39
|
public var vitalsUpdateFrequency: NSString? = nil
|
|
40
|
+
public var trackFrustrations: Bool? = nil
|
|
37
41
|
public var additionalConfig: NSDictionary? = nil
|
|
38
42
|
public var configurationForTelemetry: ConfigurationForTelemetry? = nil
|
|
39
43
|
|
|
@@ -49,6 +53,7 @@ public class DdSdkConfiguration: NSObject {
|
|
|
49
53
|
trackingConsent: NSString?,
|
|
50
54
|
telemetrySampleRate: Double?,
|
|
51
55
|
vitalsUpdateFrequency: NSString?,
|
|
56
|
+
trackFrustrations: Bool?,
|
|
52
57
|
additionalConfig: NSDictionary?,
|
|
53
58
|
configurationForTelemetry: ConfigurationForTelemetry?
|
|
54
59
|
) {
|
|
@@ -63,6 +68,7 @@ public class DdSdkConfiguration: NSObject {
|
|
|
63
68
|
self.trackingConsent = trackingConsent
|
|
64
69
|
self.telemetrySampleRate = telemetrySampleRate
|
|
65
70
|
self.vitalsUpdateFrequency = vitalsUpdateFrequency
|
|
71
|
+
self.trackFrustrations = trackFrustrations
|
|
66
72
|
self.additionalConfig = additionalConfig
|
|
67
73
|
self.configurationForTelemetry = configurationForTelemetry
|
|
68
74
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import Datadog
|
|
7
8
|
import Foundation
|
|
8
9
|
|
|
9
10
|
extension NSDictionary {
|
|
@@ -20,6 +21,7 @@ extension NSDictionary {
|
|
|
20
21
|
let trackingConsent = object(forKey: "trackingConsent") as? NSString
|
|
21
22
|
let telemetrySampleRate = object(forKey: "telemetrySampleRate") as? Double
|
|
22
23
|
let vitalsUpdateFrequency = object(forKey: "vitalsUpdateFrequency") as? NSString
|
|
24
|
+
let trackFrustrations = object(forKey: "trackFrustrations") as? Bool
|
|
23
25
|
let additionalConfig = object(forKey: "additionalConfig") as? NSDictionary
|
|
24
26
|
let configurationForTelemetry = object(forKey: "configurationForTelemetry") as? NSDictionary
|
|
25
27
|
return DdSdkConfiguration(
|
|
@@ -34,6 +36,7 @@ extension NSDictionary {
|
|
|
34
36
|
trackingConsent: trackingConsent,
|
|
35
37
|
telemetrySampleRate: telemetrySampleRate,
|
|
36
38
|
vitalsUpdateFrequency: vitalsUpdateFrequency,
|
|
39
|
+
trackFrustrations: trackFrustrations,
|
|
37
40
|
additionalConfig: additionalConfig,
|
|
38
41
|
configurationForTelemetry: configurationForTelemetry?.asConfigurationForTelemetry()
|
|
39
42
|
)
|
|
@@ -53,3 +56,44 @@ extension NSDictionary {
|
|
|
53
56
|
)
|
|
54
57
|
}
|
|
55
58
|
}
|
|
59
|
+
|
|
60
|
+
extension NSArray {
|
|
61
|
+
/*
|
|
62
|
+
* Adapts the data format from the React Native SDK configuration to match with the
|
|
63
|
+
* iOS SDK configuration. For example:
|
|
64
|
+
*
|
|
65
|
+
* RN config: [{ match: "example.com", propagatorTypes: [DATADOG, B3] }]
|
|
66
|
+
* iOS config: { "example.com": [DATADOG, B3] }
|
|
67
|
+
*/
|
|
68
|
+
func asFirstPartyHosts() -> [String: Set<TracingHeaderType>] {
|
|
69
|
+
return reduce(into: [:], { firstPartyHosts, h in
|
|
70
|
+
let host = (h as? NSDictionary)
|
|
71
|
+
|
|
72
|
+
if let match = (host?.value(forKey: "match") as? String),
|
|
73
|
+
let propagatorTypes = (host?.value(forKey: "propagatorTypes") as? NSArray) {
|
|
74
|
+
if let hostPropagatorTypes = firstPartyHosts[match] {
|
|
75
|
+
firstPartyHosts[match] = hostPropagatorTypes.union(propagatorTypes.asTracingHeaderType())
|
|
76
|
+
} else {
|
|
77
|
+
firstPartyHosts[match] = propagatorTypes.asTracingHeaderType()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
func asTracingHeaderType() -> Set<TracingHeaderType> {
|
|
84
|
+
return Set(compactMap { headerType in
|
|
85
|
+
switch(headerType as? String) {
|
|
86
|
+
case "datadog":
|
|
87
|
+
return TracingHeaderType.datadog
|
|
88
|
+
case "b3":
|
|
89
|
+
return TracingHeaderType.b3
|
|
90
|
+
case "b3multi":
|
|
91
|
+
return TracingHeaderType.b3multi
|
|
92
|
+
case "tracecontext":
|
|
93
|
+
return TracingHeaderType.tracecontext
|
|
94
|
+
default:
|
|
95
|
+
return nil
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
}
|
package/jest/mock.js
CHANGED
|
@@ -11,7 +11,7 @@ const React = require('react');
|
|
|
11
11
|
const actualDatadog = jest.requireActual('@datadog/mobile-react-native');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Explicitly mocking the provider prevents auto-instrumentation in tests.
|
|
15
15
|
* This prevents errors in tests to be logged in the console, as well as needing
|
|
16
16
|
* to mock XMLHttpRequest.
|
|
17
17
|
*/
|
|
@@ -156,7 +156,7 @@ class DdSdkReactNative {
|
|
|
156
156
|
if (configuration.trackResources) {
|
|
157
157
|
_DdRumResourceTracking.DdRumResourceTracking.startTracking({
|
|
158
158
|
tracingSamplingRate: configuration.resourceTracingSamplingRate,
|
|
159
|
-
firstPartyHosts: configuration.firstPartyHosts
|
|
159
|
+
firstPartyHosts: (0, _DdSdkReactNativeConfiguration.formatFirstPartyHosts)(configuration.firstPartyHosts)
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -232,7 +232,7 @@ _defineProperty(DdSdkReactNative, "initializeNativeSDK", async (configuration, p
|
|
|
232
232
|
|
|
233
233
|
_InternalLog.InternalLog.verbosity = configuration.verbosity;
|
|
234
234
|
DdSdkReactNative.buildConfiguration(configuration);
|
|
235
|
-
await _foundation.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, {
|
|
235
|
+
await _foundation.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.trackFrustrations, {
|
|
236
236
|
initializationType: params.initializationModeForTelemetry,
|
|
237
237
|
trackErrors: configuration.trackErrors,
|
|
238
238
|
trackInteractions: configuration.trackInteractions,
|
|
@@ -299,6 +299,6 @@ _defineProperty(DdSdkReactNative, "buildConfiguration", configuration => {
|
|
|
299
299
|
configuration.additionalConfig[DdSdkReactNative.DD_VERSION_SUFFIX] = `-${configuration.versionSuffix}`;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
configuration.additionalConfig['_dd.first_party_hosts'] = configuration.firstPartyHosts;
|
|
302
|
+
configuration.additionalConfig['_dd.first_party_hosts'] = (0, _DdSdkReactNativeConfiguration.formatFirstPartyHosts)(configuration.firstPartyHosts);
|
|
303
303
|
});
|
|
304
304
|
//# sourceMappingURL=DdSdkReactNative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","InternalLog","log","JSON","stringify","SdkVerbosity","DEBUG","DdSdk","AttributesSingleton","getInstance","setUser","user","UserInfoSingleton","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","initializationType","trackNetworkRequests","INFO","BufferSingleton","onInitialization","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","version","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;;;;;;AAMA;;AAEA;;AAaA;;AACA;;AACA;;AAE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AAnC,EAA0C;AACtCC,QAAAA,OAAO,CAACC,IAAR,CACI,iEADJ;AAGH,OAJD,MAIO;AACH5B,QAAAA,gBAAgB,CAAC3E,gBAAgB,CAACwG,qBAAlB,CAAhB,GACIb,WAAW,CAACO,QADhB;AAEAvB,QAAAA,gBAAgB,CAAC3E,gBAAgB,CAACyG,qBAAlB,CAAhB,GACId,WAAW,CAACQ,QADhB;AAEH;AACJ;AACJ;;AAED,MAAIjG,aAAa,CAACwG,WAAlB,EAA+B;AAC3BxG,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAAC2G,eAAhD,IACIzG,aAAa,CAACwG,WADlB;AAEH;;AAED,MAAIxG,aAAa,CAAC0G,OAAlB,EAA2B;AACvB1G,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAAC6G,UAAhD,IAA+D,GAC3D3G,aAAa,CAAC0G,OACjB,GACG1G,aAAa,CAAC4G,aAAd,GACO,IAAG5G,aAAa,CAAC4G,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAI5G,aAAa,CAAC4G,aAAd,IAA+B,CAAC5G,aAAa,CAAC0G,OAAlD,EAA2D;AACvD1G,IAAAA,aAAa,CAACyE,gBAAd,CACI3E,gBAAgB,CAAC+G,iBADrB,IAEK,IAAG7G,aAAa,CAAC4G,aAAc,EAFpC;AAGH;;AAED5G,EAAAA,aAAa,CAACyE,gBAAd,CAA+B,uBAA/B,IACIzE,aAAa,CAACwC,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 {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode\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 { DdSdk } from './foundation';\nimport { DdLogs } from './logs/DdLogs';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\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 { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\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_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 async initialize(\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 {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources\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 async setAttributes(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 async setUser(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 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['_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\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","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","InternalLog","log","JSON","stringify","SdkVerbosity","DEBUG","DdSdk","AttributesSingleton","getInstance","setUser","user","UserInfoSingleton","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","trackFrustrations","initializationType","trackNetworkRequests","INFO","BufferSingleton","onInitialization","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","version","DD_VERSION","versionSuffix","DD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EA,QAAIN,WAAW,CAACO,QAAZ,IAAwBP,WAAW,CAACQ,QAAxC,EAAkD;AAC9C,UAAIR,WAAW,CAACE,IAAZ,KAAqBO,8BAAUC,KAAnC,EAA0C;AACtCC,QAAAA,OAAO,CAACC,IAAR,CACI,iEADJ;AAGH,OAJD,MAIO;AACH7B,QAAAA,gBAAgB,CAAC3E,gBAAgB,CAACyG,qBAAlB,CAAhB,GACIb,WAAW,CAACO,QADhB;AAEAxB,QAAAA,gBAAgB,CAAC3E,gBAAgB,CAAC0G,qBAAlB,CAAhB,GACId,WAAW,CAACQ,QADhB;AAEH;AACJ;AACJ;;AAED,MAAIlG,aAAa,CAACyG,WAAlB,EAA+B;AAC3BzG,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAAC4G,eAAhD,IACI1G,aAAa,CAACyG,WADlB;AAEH;;AAED,MAAIzG,aAAa,CAAC2G,OAAlB,EAA2B;AACvB3G,IAAAA,aAAa,CAACyE,gBAAd,CAA+B3E,gBAAgB,CAAC8G,UAAhD,IAA+D,GAC3D5G,aAAa,CAAC2G,OACjB,GACG3G,aAAa,CAAC6G,aAAd,GACO,IAAG7G,aAAa,CAAC6G,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAI7G,aAAa,CAAC6G,aAAd,IAA+B,CAAC7G,aAAa,CAAC2G,OAAlD,EAA2D;AACvD3G,IAAAA,aAAa,CAACyE,gBAAd,CACI3E,gBAAgB,CAACgH,iBADrB,IAEK,IAAG9G,aAAa,CAAC6G,aAAc,EAFpC;AAGH;;AAED7G,EAAAA,aAAa,CAACyE,gBAAd,CACI,uBADJ,IAEI,0DAAsBzE,aAAa,CAACwC,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 { DdSdk } from './foundation';\nimport { DdLogs } from './logs/DdLogs';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\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 { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\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_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 async initialize(\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.trackFrustrations,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources\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 async setAttributes(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 async setUser(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 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 }\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,10 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.VitalsUpdateFrequency = void 0;
|
|
6
|
+
exports.InitializationMode = exports.DatadogProviderConfiguration = exports.buildConfigurationFromPartialConfiguration = exports.addDefaultValuesToAutoInstrumentationConfiguration = exports.DdSdkReactNativeConfiguration = exports.formatFirstPartyHosts = exports.VitalsUpdateFrequency = void 0;
|
|
7
7
|
|
|
8
8
|
var _TrackingConsent = require("./TrackingConsent");
|
|
9
9
|
|
|
10
|
+
var _types = require("./rum/types");
|
|
11
|
+
|
|
10
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
13
|
|
|
12
14
|
let VitalsUpdateFrequency;
|
|
@@ -19,6 +21,29 @@ exports.VitalsUpdateFrequency = VitalsUpdateFrequency;
|
|
|
19
21
|
VitalsUpdateFrequency["NEVER"] = "NEVER";
|
|
20
22
|
})(VitalsUpdateFrequency || (exports.VitalsUpdateFrequency = VitalsUpdateFrequency = {}));
|
|
21
23
|
|
|
24
|
+
const isLegacyFirstPartyHost = firstPartyHost => {
|
|
25
|
+
return typeof firstPartyHost === 'string';
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Defaults legacy first party hosts format to Datadog first party hosts to keep
|
|
29
|
+
* retro-compatibility before OTel support was introduced.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const formatFirstPartyHosts = firstPartyHosts => {
|
|
34
|
+
return firstPartyHosts.map(host => {
|
|
35
|
+
if (isLegacyFirstPartyHost(host)) {
|
|
36
|
+
return {
|
|
37
|
+
match: host,
|
|
38
|
+
propagatorTypes: [_types.PropagatorType.DATADOG]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return host;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.formatFirstPartyHosts = formatFirstPartyHosts;
|
|
22
47
|
const DEFAULTS = {
|
|
23
48
|
nativeCrashReportEnabled: false,
|
|
24
49
|
sessionSamplingRate: 100.0,
|
|
@@ -36,7 +61,8 @@ const DEFAULTS = {
|
|
|
36
61
|
logEventMapper: null,
|
|
37
62
|
errorEventMapper: null,
|
|
38
63
|
resourceEventMapper: null,
|
|
39
|
-
actionEventMapper: null
|
|
64
|
+
actionEventMapper: null,
|
|
65
|
+
trackFrustrations: true
|
|
40
66
|
};
|
|
41
67
|
/**
|
|
42
68
|
* The SDK configuration class.
|
|
@@ -135,6 +161,10 @@ class DdSdkReactNativeConfiguration {
|
|
|
135
161
|
/**
|
|
136
162
|
* Sets the preferred frequency for collecting mobile vitals.
|
|
137
163
|
*/
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Enables tracking of frustration signals (error taps). Defaults to `true`.
|
|
167
|
+
*/
|
|
138
168
|
constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = DEFAULTS.trackingConsent) {
|
|
139
169
|
this.clientToken = clientToken;
|
|
140
170
|
this.env = env;
|
|
@@ -178,6 +208,8 @@ class DdSdkReactNativeConfiguration {
|
|
|
178
208
|
|
|
179
209
|
_defineProperty(this, "vitalsUpdateFrequency", DEFAULTS.vitalsUpdateFrequency);
|
|
180
210
|
|
|
211
|
+
_defineProperty(this, "trackFrustrations", DEFAULTS.trackFrustrations);
|
|
212
|
+
|
|
181
213
|
_defineProperty(this, "logEventMapper", DEFAULTS.logEventMapper);
|
|
182
214
|
|
|
183
215
|
_defineProperty(this, "errorEventMapper", DEFAULTS.errorEventMapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["VitalsUpdateFrequency","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","TrackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","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":";;;;;;;AAQA;;;;IAMYA,qB;;;WAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,qCAAAA,qB;;AAOZ,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,mBAAmB,EAAE,CALR;AAMbC,EAAAA,yBAAyB,EAAE,GANd;AAObC,EAAAA,kBAAkB,EAAE,KAPP;AAQbC,EAAAA,yBAAyB,EAAE,KARd;AAS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AAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,6BADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAAC5B;AAFpB,GADqB,EAKrBqC,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AAAEI,IAAAA,IAAI,EAAE,iBAAR;AAA2BD,IAAAA,KAAK,EAAEL,QAAQ,CAACC;AAA3C,GADqB,EAErBQ,gBAFqB,CAAzB;AAIAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,gBADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACd;AAFpB,GADqB,EAKrBuB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,kBADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACb;AAFpB,GADqB,EAKrBsB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,qBADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACZ;AAFpB,GADqB,EAKrBqB,gBALqB,CAAzB;AAOAP,EAAAA,yBAAyB,CACrB;AACII,IAAAA,IAAI,EAAE,mBADV;AAEID,IAAAA,KAAK,EAAEL,QAAQ,CAACX;AAFpB,GADqB,EAKrBoB,gBALqB,CAAzB;AAQA,SAAOA,gBAAP;AACH,CAtEM;;;;AAwEA,MAAMI,4BAAN,SAA2CvB,6BAA3C,CAAyE;AAAA;AAAA;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;;;IAIpED,kB;;;WAAAA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,kCAAAA,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';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null\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 /**\n * Enables crash reporting for native plaforms (iOS, Android). Default `false`.\n */\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 /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\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 /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\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 readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\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 readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\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 === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper\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 nativeInteractionTracking?: 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 longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\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 setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\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\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL';\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["VitalsUpdateFrequency","isLegacyFirstPartyHost","firstPartyHost","formatFirstPartyHosts","firstPartyHosts","map","host","match","propagatorTypes","PropagatorType","DATADOG","DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","longTaskThresholdMs","nativeLongTaskThresholdMs","nativeViewTracking","nativeInteractionTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","TrackingConsent","GRANTED","telemetrySampleRate","vitalsUpdateFrequency","AVERAGE","logEventMapper","errorEventMapper","resourceEventMapper","actionEventMapper","trackFrustrations","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;;;;;;AAQA;;AAMA;;;;IAEYA,qB;;;WAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;AAAAA,EAAAA,qB;GAAAA,qB,qCAAAA,qB;;AAcZ,MAAMC,sBAAsB,GACxBC,cAD2B,IAEc;AACzC,SAAO,OAAOA,cAAP,KAA0B,QAAjC;AACH,CAJD;AAMA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAC9BC,eADiC,IAEd;AACnB,SAAOA,eAAe,CAACC,GAAhB,CAAoBC,IAAI,IAAI;AAC/B,QAAIL,sBAAsB,CAACK,IAAD,CAA1B,EAAkC;AAC9B,aAAO;AACHC,QAAAA,KAAK,EAAED,IADJ;AAEHE,QAAAA,eAAe,EAAE,CAACC,sBAAeC,OAAhB;AAFd,OAAP;AAIH;;AACD,WAAOJ,IAAP;AACH,GARM,CAAP;AASH,CAZM;;;AAcP,MAAMK,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,mBAAmB,EAAE,CALR;AAMbC,EAAAA,yBAAyB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A,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';\nimport type { LogEventMapper } from './logs/types';\nimport type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';\nimport type { FirstPartyHost } from './rum/types';\nimport { PropagatorType } from './rum/types';\n\nexport enum VitalsUpdateFrequency {\n FREQUENT = 'FREQUENT',\n AVERAGE = 'AVERAGE',\n RARE = 'RARE',\n NEVER = 'NEVER'\n}\n\nexport type FirstPartyHostsConfiguration = (\n | FirstPartyHost\n | LegacyFirstPartyHost\n)[];\n\nexport type LegacyFirstPartyHost = string;\n\nconst isLegacyFirstPartyHost = (\n firstPartyHost: FirstPartyHost | LegacyFirstPartyHost\n): firstPartyHost is LegacyFirstPartyHost => {\n return typeof firstPartyHost === 'string';\n};\n\n/**\n * Defaults legacy first party hosts format to Datadog first party hosts to keep\n * retro-compatibility before OTel support was introduced.\n */\nexport const formatFirstPartyHosts = (\n firstPartyHosts: FirstPartyHostsConfiguration\n): FirstPartyHost[] => {\n return firstPartyHosts.map(host => {\n if (isLegacyFirstPartyHost(host)) {\n return {\n match: host,\n propagatorTypes: [PropagatorType.DATADOG]\n };\n }\n return host;\n });\n};\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n longTaskThresholdMs: 0,\n nativeLongTaskThresholdMs: 200,\n nativeViewTracking: false,\n nativeInteractionTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0,\n vitalsUpdateFrequency: VitalsUpdateFrequency.AVERAGE,\n logEventMapper: null,\n errorEventMapper: null,\n resourceEventMapper: null,\n actionEventMapper: null,\n trackFrustrations: true\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 /**\n * Enables crash reporting for native plaforms (iOS, Android). Default `false`.\n */\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 /**\n * Verbosity for internal SDK logging.\n * Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.\n */\n public verbosity: SdkVerbosity | undefined = undefined;\n /**\n * Enables native views tracking.\n * Set to `true` if you use a custom navigation system relying on native views.\n */\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n /**\n * Enables native interaction tracking.\n * Set to `true` if you want to track interactions on native screens.\n */\n public nativeInteractionTracking: boolean =\n DEFAULTS.nativeInteractionTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n /**\n * List of your backends hosts to enable tracing with.\n * Regular expressions are NOT supported.\n *\n * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.\n */\n public firstPartyHosts: FirstPartyHostsConfiguration = 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 /**\n * The threshold for native long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables native long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `200`.\n */\n public nativeLongTaskThresholdMs: number | false =\n DEFAULTS.nativeLongTaskThresholdMs;\n\n /**\n * The threshold for javascript long tasks reporting in milliseconds.\n *\n * - Setting it to `0` or `false` disables javascript long task reporting.\n * - Values below `100` will be raised to `100`.\n * - Values above `5000` will be lowered to `5000`.\n *\n * Default value is `0`\n */\n public longTaskThresholdMs: number | false = DEFAULTS.longTaskThresholdMs;\n\n /**\n * Sets the preferred frequency for collecting mobile vitals.\n */\n public vitalsUpdateFrequency: VitalsUpdateFrequency =\n DEFAULTS.vitalsUpdateFrequency;\n\n /**\n * Enables tracking of frustration signals (error taps). Defaults to `true`.\n */\n public trackFrustrations: boolean = DEFAULTS.trackFrustrations;\n\n public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;\n\n public errorEventMapper: ErrorEventMapper | null =\n DEFAULTS.errorEventMapper;\n\n public resourceEventMapper: ResourceEventMapper | null =\n DEFAULTS.resourceEventMapper;\n\n public actionEventMapper: ActionEventMapper | null =\n DEFAULTS.actionEventMapper;\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?: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n readonly logEventMapper?: LogEventMapper | null;\n readonly errorEventMapper?: ErrorEventMapper | null;\n readonly resourceEventMapper?: ResourceEventMapper | null;\n readonly actionEventMapper?: ActionEventMapper | null;\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: FirstPartyHostsConfiguration;\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n readonly logEventMapper: LogEventMapper | null;\n readonly errorEventMapper: ErrorEventMapper | null;\n readonly resourceEventMapper: ResourceEventMapper | null;\n readonly actionEventMapper: ActionEventMapper | null;\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 === undefined\n ? DEFAULTS.resourceTracingSamplingRate\n : features.resourceTracingSamplingRate,\n logEventMapper:\n features.logEventMapper === undefined\n ? DEFAULTS.logEventMapper\n : features.logEventMapper,\n errorEventMapper:\n features.errorEventMapper === undefined\n ? DEFAULTS.errorEventMapper\n : features.errorEventMapper,\n resourceEventMapper:\n features.resourceEventMapper === undefined\n ? DEFAULTS.resourceEventMapper\n : features.resourceEventMapper,\n actionEventMapper:\n features.actionEventMapper === undefined\n ? DEFAULTS.actionEventMapper\n : features.actionEventMapper\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 nativeInteractionTracking?: 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 longTaskThresholdMs?: number | false;\n readonly nativeLongTaskThresholdMs?: number | false;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;\n readonly trackFrustrations?: boolean;\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 setConfigurationAttribute(\n {\n name: 'logEventMapper',\n value: features.logEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'errorEventMapper',\n value: features.errorEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'resourceEventMapper',\n value: features.resourceEventMapper\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n {\n name: 'actionEventMapper',\n value: features.actionEventMapper\n },\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\nexport type InitializationModeForTelemetry =\n | 'LEGACY'\n | 'SYNC'\n | 'ASYNC'\n | 'PARTIAL';\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "InitializationMode", {
|
|
|
21
21
|
return _DdSdkReactNativeConfiguration.InitializationMode;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "VitalsUpdateFrequency", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _DdSdkReactNativeConfiguration.VitalsUpdateFrequency;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "DdSdkReactNative", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -87,6 +93,12 @@ Object.defineProperty(exports, "ErrorSource", {
|
|
|
87
93
|
return _types.ErrorSource;
|
|
88
94
|
}
|
|
89
95
|
});
|
|
96
|
+
Object.defineProperty(exports, "PropagatorType", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _types.PropagatorType;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
90
102
|
Object.defineProperty(exports, "DatadogProvider", {
|
|
91
103
|
enumerable: true,
|
|
92
104
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","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 {\n DatadogProviderConfiguration,\n DdSdkReactNativeConfiguration,\n InitializationMode,\n VitalsUpdateFrequency\n} from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdTrace } from './foundation';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { RumActionType, ErrorSource, PropagatorType } from './rum/types';\nimport { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n InitializationMode,\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity,\n VitalsUpdateFrequency,\n PropagatorType\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
|
|
1
|
+
{"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n\n /**\n * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
|
|
@@ -9,13 +9,13 @@ var _InternalLog = require("../../../InternalLog");
|
|
|
9
9
|
|
|
10
10
|
var _SdkVerbosity = require("../../../SdkVerbosity");
|
|
11
11
|
|
|
12
|
-
var _firstPartyHosts = require("./
|
|
12
|
+
var _firstPartyHosts = require("./distributedTracing/firstPartyHosts");
|
|
13
13
|
|
|
14
|
-
var _ResourceReporter = require("./
|
|
14
|
+
var _ResourceReporter = require("./requestProxy/XHRProxy/DatadogRumResource/ResourceReporter");
|
|
15
15
|
|
|
16
|
-
var _internalDevResourceBlocklist = require("./
|
|
16
|
+
var _internalDevResourceBlocklist = require("./requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist");
|
|
17
17
|
|
|
18
|
-
var _XHRProxy = require("./
|
|
18
|
+
var _XHRProxy = require("./requestProxy/XHRProxy/XHRProxy");
|
|
19
19
|
|
|
20
20
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
21
|
|
|
@@ -43,7 +43,7 @@ class DdRumResourceTracking {
|
|
|
43
43
|
});
|
|
44
44
|
this.requestProxy.onTrackingStart({
|
|
45
45
|
tracingSamplingRate,
|
|
46
|
-
|
|
46
|
+
firstPartyHostsRegexMap: (0, _firstPartyHosts.firstPartyHostsRegexMapBuilder)(firstPartyHosts)
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
_InternalLog.InternalLog.log('Datadog SDK is tracking XHR resources', _SdkVerbosity.SdkVerbosity.INFO);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumResourceTracking.tsx"],"names":["DdRumResourceTracking","startTracking","tracingSamplingRate","firstPartyHosts","isTracking","InternalLog","log","SdkVerbosity","WARN","requestProxy","XHRProxy","xhrType","XMLHttpRequest","resourceReporter","ResourceReporter","filterDevResource","onTrackingStart","
|
|
1
|
+
{"version":3,"sources":["DdRumResourceTracking.tsx"],"names":["DdRumResourceTracking","startTracking","tracingSamplingRate","firstPartyHosts","isTracking","InternalLog","log","SdkVerbosity","WARN","requestProxy","XHRProxy","xhrType","XMLHttpRequest","resourceReporter","ResourceReporter","filterDevResource","onTrackingStart","firstPartyHostsRegexMap","INFO","stopTracking","onTrackingStop"],"mappings":";;;;;;;AAMA;;AACA;;AAGA;;AACA;;AACA;;AACA;;;;AAGA;AACA;AACA;AACO,MAAMA,qBAAN,CAA4B;AAI/B;AACJ;AACA;AACwB,SAAbC,aAAa,CAAC;AACjBC,IAAAA,mBADiB;AAEjBC,IAAAA;AAFiB,GAAD,EAMX;AACL;AACA,QAAIH,qBAAqB,CAACI,UAA1B,EAAsC;AAClCC,+BAAYC,GAAZ,CACI,+CADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,SAAKC,YAAL,GAAoB,IAAIC,kBAAJ,CAAa;AAC7BC,MAAAA,OAAO,EAAEC,cADoB;AAE7BC,MAAAA,gBAAgB,EAAE,IAAIC,kCAAJ,CAAqB,CAACC,+CAAD,CAArB;AAFW,KAAb,CAApB;AAIA,SAAKN,YAAL,CAAkBO,eAAlB,CAAkC;AAC9Bd,MAAAA,mBAD8B;AAE9Be,MAAAA,uBAAuB,EAAE,qDACrBd,eADqB;AAFK,KAAlC;;AAOAE,6BAAYC,GAAZ,CACI,uCADJ,EAEIC,2BAAaW,IAFjB;;AAIAlB,IAAAA,qBAAqB,CAACI,UAAtB,GAAmC,IAAnC;AACH;;AAEkB,SAAZe,YAAY,GAAS;AACxB,QAAInB,qBAAqB,CAACI,UAA1B,EAAsC;AAClCJ,MAAAA,qBAAqB,CAACI,UAAtB,GAAmC,KAAnC;;AACA,UAAI,KAAKK,YAAT,EAAuB;AACnB,aAAKA,YAAL,CAAkBW,cAAlB;AACH;;AACD,WAAKX,YAAL,GAAoB,IAApB;AACH;AACJ;;AAjD8B;;;;gBAAtBT,qB,gBACmB,K;;gBADnBA,qB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\nimport type { FirstPartyHost } from '../../types';\n\nimport { firstPartyHostsRegexMapBuilder } from './distributedTracing/firstPartyHosts';\nimport { ResourceReporter } from './requestProxy/XHRProxy/DatadogRumResource/ResourceReporter';\nimport { filterDevResource } from './requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist';\nimport { XHRProxy } from './requestProxy/XHRProxy/XHRProxy';\nimport type { RequestProxy } from './requestProxy/interfaces/RequestProxy';\n\n/**\n * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.\n */\nexport class DdRumResourceTracking {\n private static isTracking = false;\n private static requestProxy: RequestProxy | null;\n\n /**\n * Starts tracking resources and sends a RUM Resource event every time a network request is detected.\n */\n static startTracking({\n tracingSamplingRate,\n firstPartyHosts\n }: {\n tracingSamplingRate: number;\n firstPartyHosts: FirstPartyHost[];\n }): void {\n // extra safety to avoid proxying the XHR class twice\n if (DdRumResourceTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking XHR resources',\n SdkVerbosity.WARN\n );\n return;\n }\n\n this.requestProxy = new XHRProxy({\n xhrType: XMLHttpRequest,\n resourceReporter: new ResourceReporter([filterDevResource])\n });\n this.requestProxy.onTrackingStart({\n tracingSamplingRate,\n firstPartyHostsRegexMap: firstPartyHostsRegexMapBuilder(\n firstPartyHosts\n )\n });\n\n InternalLog.log(\n 'Datadog SDK is tracking XHR resources',\n SdkVerbosity.INFO\n );\n DdRumResourceTracking.isTracking = true;\n }\n\n static stopTracking(): void {\n if (DdRumResourceTracking.isTracking) {\n DdRumResourceTracking.isTracking = false;\n if (this.requestProxy) {\n this.requestProxy.onTrackingStop();\n }\n this.requestProxy = null;\n }\n }\n}\n"]}
|