@datadog/mobile-react-native 1.0.0-beta4 → 1.0.0-rc4
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 +1 -1
- package/README.md +73 -1
- package/android/build.gradle +2 -3
- package/android/src/main/java/com/datadog/reactnative/DdRum.kt +25 -24
- package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +6 -6
- package/ios/Sources/DdRum.m +10 -9
- package/ios/Sources/DdRum.swift +24 -24
- package/ios/Sources/DdTrace.m +2 -2
- package/ios/Sources/DdTrace.swift +6 -6
- package/ios/Sources/QueueHolder.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +57 -0
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +8 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/NativeSdkVerbosity.js +26 -0
- package/lib/commonjs/NativeSdkVerbosity.js.map +1 -0
- package/lib/commonjs/ProxyConfiguration.js +53 -0
- package/lib/commonjs/ProxyConfiguration.js.map +1 -0
- package/lib/commonjs/Timer.js +99 -0
- package/lib/commonjs/Timer.js.map +1 -0
- package/lib/commonjs/TrackingConsent.js +6 -0
- package/lib/commonjs/TrackingConsent.js.map +1 -1
- package/lib/commonjs/foundation.js +88 -8
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +51 -11
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +38 -6
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +103 -18
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +10 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/DdSdkReactNative.js +56 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +9 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/NativeSdkVerbosity.js +18 -0
- package/lib/module/NativeSdkVerbosity.js.map +1 -0
- package/lib/module/ProxyConfiguration.js +46 -0
- package/lib/module/ProxyConfiguration.js.map +1 -0
- package/lib/module/Timer.js +90 -0
- package/lib/module/Timer.js.map +1 -0
- package/lib/module/TrackingConsent.js +6 -0
- package/lib/module/TrackingConsent.js.map +1 -1
- package/lib/module/foundation.js +89 -3
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +51 -11
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +37 -6
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +96 -18
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +3 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/DdSdkReactNative.d.ts +11 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +6 -0
- package/lib/typescript/NativeSdkVerbosity.d.ts +9 -0
- package/lib/typescript/ProxyConfiguration.d.ts +56 -0
- package/lib/typescript/Timer.d.ts +20 -0
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +2 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +2 -0
- package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +2 -2
- package/lib/typescript/types.d.ts +25 -24
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +12 -13
- package/src/DdSdkReactNative.tsx +47 -0
- package/src/DdSdkReactNativeConfiguration.tsx +7 -1
- package/src/NativeSdkVerbosity.tsx +15 -0
- package/src/ProxyConfiguration.tsx +37 -0
- package/src/Timer.ts +96 -0
- package/src/TrackingConsent.tsx +6 -0
- package/src/__tests__/DdRumWrapper.test.tsx +91 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +541 -0
- package/src/__tests__/Timer.test.ts +145 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +222 -0
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +314 -0
- package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +677 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +188 -0
- package/src/__tests__/rum/instrumentation/TraceIdentifier.test.tsx +33 -0
- package/src/foundation.tsx +83 -3
- package/src/index.tsx +3 -2
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +40 -10
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +56 -25
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +92 -22
- package/src/rum/instrumentation/DdRumXhr.tsx +6 -5
- package/src/types.tsx +25 -24
- package/src/version.ts +2 -0
- package/android/.project +0 -17
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -104
- package/ios/DdSdkReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Tests/ModulesTest.swift +0 -43
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.source_files = "ios/Sources/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
|
-
s.dependency "DatadogSDKBridge", "
|
|
20
|
+
s.dependency "DatadogSDKBridge", "0.5.1"
|
|
21
21
|
|
|
22
22
|
s.test_spec 'Tests' do |test_spec|
|
|
23
23
|
test_spec.source_files = 'ios/Tests/*.swift'
|
package/README.md
CHANGED
|
@@ -1 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
# React-Native Monitoring
|
|
2
|
+
|
|
3
|
+
Datadog *Real User Monitoring (RUM)* enables you to visualize and analyze the real-time performance and user journeys of your application’s individual users.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
To install with NPM, run:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @datadog/mobile-react-native
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
To install with Yarn, run:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
yarn add @datadog/mobile-react-native
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Minimum React Native version**: SDK supports React Native version 0.63.4 or higher. Compatibility with older versions is not guaranteed out of the box.
|
|
20
|
+
|
|
21
|
+
### Specify application details in UI
|
|
22
|
+
|
|
23
|
+
1. In the [Datadog app][1], select **UX Monitoring > RUM Applications > New Application**.
|
|
24
|
+
2. Choose `react-native` as your Application Type.
|
|
25
|
+
3. Provide a new application name to generate a unique Datadog application ID and client token.
|
|
26
|
+
|
|
27
|
+
![image][2]
|
|
28
|
+
|
|
29
|
+
To ensure the safety of your data, you must use a client token. You cannot use only [Datadog API keys][3] to configure the `@datadog/mobile-react-native` library, because they would be exposed client-side. For more information about setting up a client token, see the [Client Token documentation][4].
|
|
30
|
+
|
|
31
|
+
### Initialize the library with application context
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { DdSdkReactNative, DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
const config = new DdSdkReactNativeConfiguration(
|
|
38
|
+
"<CLIENT_TOKEN>",
|
|
39
|
+
"<ENVIRONMENT_NAME>",
|
|
40
|
+
"<RUM_APPLICATION_ID>",
|
|
41
|
+
true, // track User interactions (e.g.: Tap on buttons. You can use 'accessibilityLabel' element property to give tap action the name, otherwise element type will be reported)
|
|
42
|
+
true, // track XHR Resources
|
|
43
|
+
true // track Errors
|
|
44
|
+
)
|
|
45
|
+
// Optional: Select your Datadog website (one of "US1", "US3", "US5", EU1", or "US1_FED"). Default is "US1".
|
|
46
|
+
config.site = "US1"
|
|
47
|
+
// Optional: enable or disable native crash reports
|
|
48
|
+
config.nativeCrashReportEnabled = true
|
|
49
|
+
// Optional: sample RUM sessions (here, 80% of session will be sent to Datadog. Default = 100%)
|
|
50
|
+
config.sampleRate = 80
|
|
51
|
+
// Optional: set the reported service name (by default, it'll use the package name / bundleIdentifier of your Android / iOS app respectively)
|
|
52
|
+
config.serviceName = "com.example.reactnative"
|
|
53
|
+
|
|
54
|
+
await DdSdkReactNative.initialize(config)
|
|
55
|
+
|
|
56
|
+
// Once SDK is initialized you need to setup view tracking to be able to see data in the RUM Dashboard.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Track view navigation
|
|
60
|
+
|
|
61
|
+
Because React Native offers a wide range of libraries to create screen navigation, by default only manual View tracking is supported. You can manually start and stop a View using the following `startView()` and `stopView` methods.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import { DdSdkReactNative, DdSdkReactNativeConfiguration, DdLogs, DdRum } from '@datadog/mobile-react-native';
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// Start a view with a unique view identifier, a custom view url, and an object to attach additional attributes to the view
|
|
69
|
+
DdRum.startView('<view-key>', '/view/url', Date.now(), { 'custom.foo': "something" });
|
|
70
|
+
// Stops a previously started view with the same unique view identifier, and an object to attach additional attributes to the view
|
|
71
|
+
DdRum.stopView('<view-key>', Date.now(), { 'custom.bar': 42 });
|
|
72
|
+
```
|
|
73
|
+
|
package/android/build.gradle
CHANGED
|
@@ -3,8 +3,8 @@ buildscript {
|
|
|
3
3
|
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['DdSdkReactNative_kotlinVersion']
|
|
4
4
|
|
|
5
5
|
repositories {
|
|
6
|
+
mavenCentral()
|
|
6
7
|
google()
|
|
7
|
-
jcenter()
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
dependencies {
|
|
@@ -52,7 +52,6 @@ android {
|
|
|
52
52
|
|
|
53
53
|
repositories {
|
|
54
54
|
mavenCentral()
|
|
55
|
-
jcenter()
|
|
56
55
|
google()
|
|
57
56
|
maven { url "https://jitpack.io" }
|
|
58
57
|
mavenLocal()
|
|
@@ -129,7 +128,7 @@ dependencies {
|
|
|
129
128
|
// noinspection GradleDynamicVersion
|
|
130
129
|
api 'com.facebook.react:react-native:+'
|
|
131
130
|
|
|
132
|
-
implementation "com.datadoghq:dd-bridge-android:0.
|
|
131
|
+
implementation "com.datadoghq:dd-bridge-android:0.5.2"
|
|
133
132
|
|
|
134
133
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
135
134
|
}
|
|
@@ -28,24 +28,24 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
28
28
|
* Start tracking a RUM View.
|
|
29
29
|
* @param key The view unique key identifier.
|
|
30
30
|
* @param name The view name.
|
|
31
|
-
* @param timestampMs The timestamp when the view started (in milliseconds).
|
|
32
31
|
* @param context The additional context to send.
|
|
32
|
+
* @param timestampMs The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
|
|
33
33
|
*/
|
|
34
34
|
@ReactMethod
|
|
35
|
-
fun startView(key: String, name: String,
|
|
36
|
-
nativeInstance.startView(key, name,
|
|
35
|
+
fun startView(key: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
36
|
+
nativeInstance.startView(key, name, context.toHashMap(), timestampMs.toLong())
|
|
37
37
|
promise.resolve(null)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Stop tracking a RUM View.
|
|
42
42
|
* @param key The view unique key identifier.
|
|
43
|
-
* @param timestampMs The timestamp when the view stopped (in milliseconds).
|
|
44
43
|
* @param context The additional context to send.
|
|
44
|
+
* @param timestampMs The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
45
45
|
*/
|
|
46
46
|
@ReactMethod
|
|
47
|
-
fun stopView(key: String,
|
|
48
|
-
nativeInstance.stopView(key,
|
|
47
|
+
fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
48
|
+
nativeInstance.stopView(key, context.toHashMap(), timestampMs.toLong())
|
|
49
49
|
promise.resolve(null)
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -53,23 +53,23 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
53
53
|
* Start tracking a RUM Action.
|
|
54
54
|
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
55
55
|
* @param name The action name.
|
|
56
|
-
* @param timestampMs The timestamp when the action started (in milliseconds).
|
|
57
56
|
* @param context The additional context to send.
|
|
57
|
+
* @param timestampMs The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
58
58
|
*/
|
|
59
59
|
@ReactMethod
|
|
60
|
-
fun startAction(type: String, name: String,
|
|
61
|
-
nativeInstance.startAction(type, name,
|
|
60
|
+
fun startAction(type: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
61
|
+
nativeInstance.startAction(type, name, context.toHashMap(), timestampMs.toLong())
|
|
62
62
|
promise.resolve(null)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Stop tracking the ongoing RUM Action.
|
|
67
|
-
* @param timestampMs The timestamp when the action stopped (in milliseconds).
|
|
68
67
|
* @param context The additional context to send.
|
|
68
|
+
* @param timestampMs The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
69
69
|
*/
|
|
70
70
|
@ReactMethod
|
|
71
|
-
fun stopAction(
|
|
72
|
-
nativeInstance.stopAction(
|
|
71
|
+
fun stopAction(context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
72
|
+
nativeInstance.stopAction(context.toHashMap(), timestampMs.toLong())
|
|
73
73
|
promise.resolve(null)
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -77,12 +77,12 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
77
77
|
* Add a RUM Action.
|
|
78
78
|
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
79
79
|
* @param name The action name.
|
|
80
|
-
* @param timestampMs The timestamp when the action occurred (in milliseconds).
|
|
81
80
|
* @param context The additional context to send.
|
|
81
|
+
* @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
82
82
|
*/
|
|
83
83
|
@ReactMethod
|
|
84
|
-
fun addAction(type: String, name: String,
|
|
85
|
-
nativeInstance.addAction(type, name,
|
|
84
|
+
fun addAction(type: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
85
|
+
nativeInstance.addAction(type, name, context.toHashMap(), timestampMs.toLong())
|
|
86
86
|
promise.resolve(null)
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -91,12 +91,12 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
91
91
|
* @param key The resource unique key identifier.
|
|
92
92
|
* @param method The resource method (GET, POST, …).
|
|
93
93
|
* @param url The resource url.
|
|
94
|
-
* @param timestampMs The timestamp when the resource started (in milliseconds).
|
|
95
94
|
* @param context The additional context to send.
|
|
95
|
+
* @param timestampMs The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
|
|
96
96
|
*/
|
|
97
97
|
@ReactMethod
|
|
98
|
-
fun startResource(key: String, method: String, url: String,
|
|
99
|
-
nativeInstance.startResource(key, method, url,
|
|
98
|
+
fun startResource(key: String, method: String, url: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
99
|
+
nativeInstance.startResource(key, method, url, context.toHashMap(), timestampMs.toLong())
|
|
100
100
|
promise.resolve(null)
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -105,12 +105,13 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
105
105
|
* @param key The resource unique key identifier.
|
|
106
106
|
* @param statusCode The resource status code.
|
|
107
107
|
* @param kind The resource's kind (xhr, document, image, css, font, …).
|
|
108
|
-
* @param
|
|
108
|
+
* @param size The resource size in bytes.
|
|
109
109
|
* @param context The additional context to send.
|
|
110
|
+
* @param timestampMs The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
110
111
|
*/
|
|
111
112
|
@ReactMethod
|
|
112
|
-
fun stopResource(key: String, statusCode: Double, kind: String,
|
|
113
|
-
nativeInstance.stopResource(key, statusCode.toLong(), kind,
|
|
113
|
+
fun stopResource(key: String, statusCode: Double, kind: String, size: Double, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
114
|
+
nativeInstance.stopResource(key, statusCode.toLong(), kind, size.toLong(), context.toHashMap(), timestampMs.toLong())
|
|
114
115
|
promise.resolve(null)
|
|
115
116
|
}
|
|
116
117
|
|
|
@@ -119,12 +120,12 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
119
120
|
* @param message The error message.
|
|
120
121
|
* @param source The error source (network, source, console, logger, …).
|
|
121
122
|
* @param stacktrace The error stacktrace.
|
|
122
|
-
* @param timestampMs The timestamp when the error occurred (in milliseconds).
|
|
123
123
|
* @param context The additional context to send.
|
|
124
|
+
* @param timestampMs The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
124
125
|
*/
|
|
125
126
|
@ReactMethod
|
|
126
|
-
fun addError(message: String, source: String, stacktrace: String,
|
|
127
|
-
nativeInstance.addError(message, source, stacktrace,
|
|
127
|
+
fun addError(message: String, source: String, stacktrace: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
128
|
+
nativeInstance.addError(message, source, stacktrace, context.toHashMap(), timestampMs.toLong())
|
|
128
129
|
promise.resolve(null)
|
|
129
130
|
}
|
|
130
131
|
|
|
@@ -27,24 +27,24 @@ class DdTrace(reactContext: ReactApplicationContext) : ReactContextBaseJavaModul
|
|
|
27
27
|
/**
|
|
28
28
|
* Start a span, and returns a unique identifier for the span.
|
|
29
29
|
* @param operation The operation name of the span.
|
|
30
|
-
* @param timestampMs The timestamp when the operation started (in milliseconds).
|
|
31
30
|
* @param context The additional context to send.
|
|
31
|
+
* @param timestampMs The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
|
|
32
32
|
*/
|
|
33
33
|
@ReactMethod
|
|
34
|
-
fun startSpan(operation: String,
|
|
35
|
-
val result = nativeInstance.startSpan(operation,
|
|
34
|
+
fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
35
|
+
val result = nativeInstance.startSpan(operation, context.toHashMap(), timestampMs.toLong())
|
|
36
36
|
promise.resolve(result)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Finish a started span.
|
|
41
41
|
* @param spanId The unique identifier of the span.
|
|
42
|
-
* @param timestampMs The timestamp when the operation stopped (in milliseconds).
|
|
43
42
|
* @param context The additional context to send.
|
|
43
|
+
* @param timestampMs The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
44
44
|
*/
|
|
45
45
|
@ReactMethod
|
|
46
|
-
fun finishSpan(spanId: String,
|
|
47
|
-
nativeInstance.finishSpan(spanId,
|
|
46
|
+
fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
47
|
+
nativeInstance.finishSpan(spanId, context.toHashMap(), timestampMs.toLong())
|
|
48
48
|
promise.resolve(null)
|
|
49
49
|
}
|
|
50
50
|
|
package/ios/Sources/DdRum.m
CHANGED
|
@@ -10,57 +10,58 @@
|
|
|
10
10
|
|
|
11
11
|
RCT_EXTERN_METHOD(startView:(NSString)key
|
|
12
12
|
withName:(NSString)name
|
|
13
|
-
withTimestampms:(NSInteger)timestampMs
|
|
14
13
|
withContext:(NSDictionary)context
|
|
14
|
+
withTimestampms:(NSInteger)timestampMs
|
|
15
15
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
16
16
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
17
17
|
|
|
18
18
|
RCT_EXTERN_METHOD(stopView:(NSString)key
|
|
19
|
-
withTimestampms:(NSInteger)timestampMs
|
|
20
19
|
withContext:(NSDictionary)context
|
|
20
|
+
withTimestampms:(NSInteger)timestampMs
|
|
21
21
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
22
22
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
23
23
|
|
|
24
24
|
RCT_EXTERN_METHOD(startAction:(NSString)type
|
|
25
25
|
withName:(NSString)name
|
|
26
|
-
withTimestampms:(NSInteger)timestampMs
|
|
27
26
|
withContext:(NSDictionary)context
|
|
27
|
+
withTimestampms:(NSInteger)timestampMs
|
|
28
28
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
29
29
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
30
30
|
|
|
31
|
-
RCT_EXTERN_METHOD(stopAction:(
|
|
32
|
-
|
|
31
|
+
RCT_EXTERN_METHOD(stopAction:(NSDictionary)context
|
|
32
|
+
withTimestampms:(NSInteger)timestampMs
|
|
33
33
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
34
34
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
35
35
|
|
|
36
36
|
RCT_EXTERN_METHOD(addAction:(NSString)type
|
|
37
37
|
withName:(NSString)name
|
|
38
|
-
withTimestampms:(NSInteger)timestampMs
|
|
39
38
|
withContext:(NSDictionary)context
|
|
39
|
+
withTimestampms:(NSInteger)timestampMs
|
|
40
40
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
41
41
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
42
42
|
|
|
43
43
|
RCT_EXTERN_METHOD(startResource:(NSString)key
|
|
44
44
|
withMethod:(NSString)method
|
|
45
45
|
withUrl:(NSString)url
|
|
46
|
-
withTimestampms:(NSInteger)timestampMs
|
|
47
46
|
withContext:(NSDictionary)context
|
|
47
|
+
withTimestampms:(NSInteger)timestampMs
|
|
48
48
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
49
49
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
50
50
|
|
|
51
51
|
RCT_EXTERN_METHOD(stopResource:(NSString)key
|
|
52
52
|
withStatuscode:(NSInteger)statusCode
|
|
53
53
|
withKind:(NSString)kind
|
|
54
|
-
|
|
54
|
+
withSize:(NSInteger)size
|
|
55
55
|
withContext:(NSDictionary)context
|
|
56
|
+
withTimestampms:(NSInteger)timestampMs
|
|
56
57
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
57
58
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
58
59
|
|
|
59
60
|
RCT_EXTERN_METHOD(addError:(NSString)message
|
|
60
61
|
withSource:(NSString)source
|
|
61
62
|
withStacktrace:(NSString)stacktrace
|
|
62
|
-
withTimestampms:(NSInteger)timestampMs
|
|
63
63
|
withContext:(NSDictionary)context
|
|
64
|
+
withTimestampms:(NSInteger)timestampMs
|
|
64
65
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
65
66
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
66
67
|
|
package/ios/Sources/DdRum.swift
CHANGED
|
@@ -20,51 +20,51 @@ class RNDdRum: NSObject {
|
|
|
20
20
|
@objc(methodQueue)
|
|
21
21
|
let methodQueue: DispatchQueue = sharedQueue
|
|
22
22
|
|
|
23
|
-
@objc(startView:withName:withTimestampms:
|
|
24
|
-
func startView(key: NSString, name: NSString,
|
|
25
|
-
nativeInstance.startView(key: key, name: name,
|
|
23
|
+
@objc(startView:withName:withContext:withTimestampms:withResolver:withRejecter:)
|
|
24
|
+
func startView(key: NSString, name: NSString, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
25
|
+
nativeInstance.startView(key: key, name: name, context: context, timestampMs: timestampMs)
|
|
26
26
|
resolve(nil)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
@objc(stopView:withTimestampms:
|
|
30
|
-
func stopView(key: NSString,
|
|
31
|
-
nativeInstance.stopView(key: key,
|
|
29
|
+
@objc(stopView:withContext:withTimestampms:withResolver:withRejecter:)
|
|
30
|
+
func stopView(key: NSString, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
31
|
+
nativeInstance.stopView(key: key, context: context, timestampMs: timestampMs)
|
|
32
32
|
resolve(nil)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
@objc(startAction:withName:withTimestampms:
|
|
36
|
-
func startAction(type: NSString, name: NSString,
|
|
37
|
-
nativeInstance.startAction(type: type, name: name,
|
|
35
|
+
@objc(startAction:withName:withContext:withTimestampms:withResolver:withRejecter:)
|
|
36
|
+
func startAction(type: NSString, name: NSString, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
37
|
+
nativeInstance.startAction(type: type, name: name, context: context, timestampMs: timestampMs)
|
|
38
38
|
resolve(nil)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
@objc(stopAction:
|
|
42
|
-
func stopAction(
|
|
43
|
-
nativeInstance.stopAction(
|
|
41
|
+
@objc(stopAction:withTimestampms:withResolver:withRejecter:)
|
|
42
|
+
func stopAction(context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
43
|
+
nativeInstance.stopAction(context: context, timestampMs: timestampMs)
|
|
44
44
|
resolve(nil)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
@objc(addAction:withName:withTimestampms:
|
|
48
|
-
func addAction(type: NSString, name: NSString,
|
|
49
|
-
nativeInstance.addAction(type: type, name: name,
|
|
47
|
+
@objc(addAction:withName:withContext:withTimestampms:withResolver:withRejecter:)
|
|
48
|
+
func addAction(type: NSString, name: NSString, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
49
|
+
nativeInstance.addAction(type: type, name: name, context: context, timestampMs: timestampMs)
|
|
50
50
|
resolve(nil)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
@objc(startResource:withMethod:withUrl:withTimestampms:
|
|
54
|
-
func startResource(key: NSString, method: NSString, url: NSString,
|
|
55
|
-
nativeInstance.startResource(key: key, method: method, url: url,
|
|
53
|
+
@objc(startResource:withMethod:withUrl:withContext:withTimestampms:withResolver:withRejecter:)
|
|
54
|
+
func startResource(key: NSString, method: NSString, url: NSString, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
55
|
+
nativeInstance.startResource(key: key, method: method, url: url, context: context, timestampMs: timestampMs)
|
|
56
56
|
resolve(nil)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
@objc(stopResource:withStatuscode:withKind:
|
|
60
|
-
func stopResource(key: NSString, statusCode: Int64, kind: NSString,
|
|
61
|
-
nativeInstance.stopResource(key: key, statusCode: statusCode, kind: kind,
|
|
59
|
+
@objc(stopResource:withStatuscode:withKind:withSize:withContext:withTimestampms:withResolver:withRejecter:)
|
|
60
|
+
func stopResource(key: NSString, statusCode: Int64, kind: NSString, size: Int64, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
61
|
+
nativeInstance.stopResource(key: key, statusCode: statusCode, kind: kind, size: size, context: context, timestampMs: timestampMs)
|
|
62
62
|
resolve(nil)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
@objc(addError:withSource:withStacktrace:withTimestampms:
|
|
66
|
-
func addError(message: NSString, source: NSString, stacktrace: NSString,
|
|
67
|
-
nativeInstance.addError(message: message, source: source, stacktrace: stacktrace,
|
|
65
|
+
@objc(addError:withSource:withStacktrace:withContext:withTimestampms:withResolver:withRejecter:)
|
|
66
|
+
func addError(message: NSString, source: NSString, stacktrace: NSString, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
67
|
+
nativeInstance.addError(message: message, source: source, stacktrace: stacktrace, context: context, timestampMs: timestampMs)
|
|
68
68
|
resolve(nil)
|
|
69
69
|
}
|
|
70
70
|
|
package/ios/Sources/DdTrace.m
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
@interface RCT_EXTERN_MODULE(DdTrace, NSObject)
|
|
10
10
|
|
|
11
11
|
RCT_EXTERN_METHOD(startSpan:(NSString)operation
|
|
12
|
-
withTimestampms:(NSInteger)timestampMs
|
|
13
12
|
withContext:(NSDictionary)context
|
|
13
|
+
withTimestampms:(NSInteger)timestampMs
|
|
14
14
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
15
15
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
16
16
|
|
|
17
17
|
RCT_EXTERN_METHOD(finishSpan:(NSString)spanId
|
|
18
|
-
withTimestampms:(NSInteger)timestampMs
|
|
19
18
|
withContext:(NSDictionary)context
|
|
19
|
+
withTimestampms:(NSInteger)timestampMs
|
|
20
20
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
21
21
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
22
22
|
|
|
@@ -20,15 +20,15 @@ class RNDdTrace: NSObject {
|
|
|
20
20
|
@objc(methodQueue)
|
|
21
21
|
let methodQueue: DispatchQueue = sharedQueue
|
|
22
22
|
|
|
23
|
-
@objc(startSpan:withTimestampms:
|
|
24
|
-
func startSpan(operation: NSString,
|
|
25
|
-
let result = nativeInstance.startSpan(operation: operation,
|
|
23
|
+
@objc(startSpan:withContext:withTimestampms:withResolver:withRejecter:)
|
|
24
|
+
func startSpan(operation: NSString, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
25
|
+
let result = nativeInstance.startSpan(operation: operation, context: context, timestampMs: timestampMs)
|
|
26
26
|
resolve(result)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
@objc(finishSpan:withTimestampms:
|
|
30
|
-
func finishSpan(spanId: NSString,
|
|
31
|
-
nativeInstance.finishSpan(spanId: spanId,
|
|
29
|
+
@objc(finishSpan:withContext:withTimestampms:withResolver:withRejecter:)
|
|
30
|
+
func finishSpan(spanId: NSString, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
|
|
31
|
+
nativeInstance.finishSpan(spanId: spanId, context: context, timestampMs: timestampMs)
|
|
32
32
|
resolve(nil)
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -15,12 +15,18 @@ var _DdRumErrorTracking = require("./rum/instrumentation/DdRumErrorTracking");
|
|
|
15
15
|
|
|
16
16
|
var _DdRumResourceTracking = require("./rum/instrumentation/DdRumResourceTracking");
|
|
17
17
|
|
|
18
|
+
var _ProxyConfiguration = require("./ProxyConfiguration");
|
|
19
|
+
|
|
20
|
+
var _version = require("./version");
|
|
21
|
+
|
|
18
22
|
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; }
|
|
19
23
|
|
|
20
24
|
/**
|
|
21
25
|
* This class initializes the Datadog SDK, and sets up communication with the server.
|
|
22
26
|
*/
|
|
23
27
|
class DdSdkReactNative {
|
|
28
|
+
// Proxy
|
|
29
|
+
|
|
24
30
|
/**
|
|
25
31
|
* Initializes the Datadog SDK.
|
|
26
32
|
* @param configuration the configuration for the SDK library
|
|
@@ -34,6 +40,35 @@ class DdSdkReactNative {
|
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] = 'react-native';
|
|
43
|
+
configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERSION] = _version.version;
|
|
44
|
+
configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY] = configuration.nativeViewTracking;
|
|
45
|
+
|
|
46
|
+
if (configuration.verbosity != undefined) {
|
|
47
|
+
configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERBOSITY_KEY] = configuration.verbosity;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (configuration.proxyConfig) {
|
|
51
|
+
const additionalConfig = configuration.additionalConfig;
|
|
52
|
+
const proxyConfig = configuration.proxyConfig;
|
|
53
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] = proxyConfig.type;
|
|
54
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] = proxyConfig.address;
|
|
55
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] = proxyConfig.port;
|
|
56
|
+
|
|
57
|
+
if (proxyConfig.username && proxyConfig.password) {
|
|
58
|
+
if (proxyConfig.type == _ProxyConfiguration.ProxyType.SOCKS) {
|
|
59
|
+
console.warn("SOCKS proxy configuration doesn't support Basic authentication.");
|
|
60
|
+
} else {
|
|
61
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] = proxyConfig.username;
|
|
62
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] = proxyConfig.password;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (configuration.serviceName) {
|
|
68
|
+
configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] = configuration.serviceName;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;
|
|
37
72
|
|
|
38
73
|
_foundation.DdSdk.initialize(new _types.DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig)).then(() => {
|
|
39
74
|
DdSdkReactNative.enableFeatures(configuration);
|
|
@@ -97,5 +132,27 @@ exports.DdSdkReactNative = DdSdkReactNative;
|
|
|
97
132
|
|
|
98
133
|
_defineProperty(DdSdkReactNative, "DD_SOURCE_KEY", "_dd.source");
|
|
99
134
|
|
|
135
|
+
_defineProperty(DdSdkReactNative, "DD_SDK_VERSION", "_dd.sdk_version");
|
|
136
|
+
|
|
137
|
+
_defineProperty(DdSdkReactNative, "DD_SERVICE_NAME", "_dd.service_name");
|
|
138
|
+
|
|
139
|
+
_defineProperty(DdSdkReactNative, "DD_SDK_VERBOSITY_KEY", "_dd.sdk_verbosity");
|
|
140
|
+
|
|
141
|
+
_defineProperty(DdSdkReactNative, "DD_NATIVE_VIEW_TRACKING_KEY", "_dd.native_view_tracking");
|
|
142
|
+
|
|
143
|
+
_defineProperty(DdSdkReactNative, "DD_PROXY_TYPE_KEY", "_dd.proxy.type");
|
|
144
|
+
|
|
145
|
+
_defineProperty(DdSdkReactNative, "DD_PROXY_ADDRESS_KEY", "_dd.proxy.address");
|
|
146
|
+
|
|
147
|
+
_defineProperty(DdSdkReactNative, "DD_PROXY_PORT_KEY", "_dd.proxy.port");
|
|
148
|
+
|
|
149
|
+
_defineProperty(DdSdkReactNative, "DD_PROXY_USERNAME_KEY", "_dd.proxy.username");
|
|
150
|
+
|
|
151
|
+
_defineProperty(DdSdkReactNative, "DD_PROXY_PASSWORD_KEY", "_dd.proxy.password");
|
|
152
|
+
|
|
153
|
+
_defineProperty(DdSdkReactNative, "DD_NATIVE_LONG_TASK_THRESHOLD_KEY", "_dd.long_task.threshold");
|
|
154
|
+
|
|
155
|
+
_defineProperty(DdSdkReactNative, "NATIVE_LONG_TASK_THRESHOLD_MS", 200);
|
|
156
|
+
|
|
100
157
|
_defineProperty(DdSdkReactNative, "wasInitialized", false);
|
|
101
158
|
//# sourceMappingURL=DdSdkReactNative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","initialize","configuration","Promise","resolve","reject","wasInitialized","additionalConfig","DD_SOURCE_KEY","DdSdk","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","then","enableFeatures","rejection","setAttributes","attributes","setUser","user","setTrackingConsent","consent","trackInteractions","DdRumUserInteractionTracking","startTracking","trackResources","DdRumResourceTracking","trackErrors","DdRumErrorTracking"],"mappings":";;;;;;;AAOA;;AACA;;AACA;;AACA;;AACA;;;;AAGA;AACA;AACA;AACO,MAAMA,gBAAN,CAAuB;AAM1B;AACJ;AACA;AACA;AACA;AACqB,SAAVC,UAAU,CAACC,aAAD,EAA8D;AAC3E,WAAO,IAAIC,OAAJ,CAAkB,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAC1C,UAAIL,gBAAgB,CAACM,cAArB,EAAqC;AACjCF,QAAAA,OAAO;AACP;AACH;;AAEDF,MAAAA,aAAa,CAACK,gBAAd,CAA+BP,gBAAgB,CAACQ,aAAhD,IAAiE,cAAjE;;AAEAC,wBAAMR,UAAN,CACI,IAAIS,yBAAJ,CACIR,aAAa,CAACS,WADlB,EAEIT,aAAa,CAACU,GAFlB,EAGIV,aAAa,CAACW,aAHlB,EAIIX,aAAa,CAACY,wBAJlB,EAKIZ,aAAa,CAACa,UALlB,EAMIb,aAAa,CAACc,IANlB,EAOId,aAAa,CAACe,eAPlB,EAQIf,aAAa,CAACK,gBARlB,CADJ,EAWEW,IAXF,CAWO,MAAM;AACTlB,QAAAA,gBAAgB,CAACmB,cAAjB,CAAgCjB,aAAhC;AACAF,QAAAA,gBAAgB,CAACM,cAAjB,GAAkC,IAAlC;AACAF,QAAAA,OAAO;AACV,OAfD,EAeIgB,SAAD,IAAe;AACdf,QAAAA,MAAM,CAACe,SAAD,CAAN;AACH,OAjBD;AAkBH,KA1BM,CAAP;AA2BH;AAED;AACJ;AACA;AACA;AACA;AACI;;;AACoB,SAAbC,aAAa,CAACC,UAAD,EAAoC;AACpD,WAAOb,kBAAMY,aAAN,CAAoBC,UAApB,CAAP;AACH;AAED;AACJ;AACA;AACA;AACA;AACI;;;AACc,SAAPC,OAAO,CAACC,IAAD,EAA8B;AACxC,WAAOf,kBAAMc,OAAN,CAAcC,IAAd,CAAP;AACH;AAED;AACJ;AACA;AACA;AACA;;;AAC6B,SAAlBC,kBAAkB,CAACC,OAAD,EAA0C;AAC/D,WAAOjB,kBAAMgB,kBAAN,CAAyBC,OAAzB,CAAP;AACH;;AAE4B,SAAdP,cAAc,CAACjB,aAAD,EAA+C;AACxE,QAAIA,aAAa,CAACyB,iBAAlB,EAAqC;AACjCC,iEAA6BC,aAA7B;AACH;;AAED,QAAI3B,aAAa,CAAC4B,cAAlB,EAAkC;AAC9BC,mDAAsBF,aAAtB;AACH;;AAED,QAAI3B,aAAa,CAAC8B,WAAlB,EAA+B;AAC3BC,6CAAmBJ,aAAnB;AACH;AACJ;;AAlFyB;;;;gBAAjB7B,gB,mBAE+B,Y;;gBAF/BA,gB,oBAIuB,K","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { DdSdkReactNativeConfiguration } from \"./DdSdkReactNativeConfiguration\"\nimport { DdSdkConfiguration } from \"./types\"\nimport { DdSdk } from \"./foundation\"\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking'\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking'\nimport { DdRumResourceTracking } from './rum/instrumentation/DdRumResourceTracking'\nimport type { TrackingConsent } from \"./TrackingConsent\"\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n\n private static readonly DD_SOURCE_KEY = \"_dd.source\";\n\n private static wasInitialized = false\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize(configuration: DdSdkReactNativeConfiguration): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (DdSdkReactNative.wasInitialized) {\n resolve()\n return\n }\n\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] = 'react-native';\n\n DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig\n )\n ).then(() => {\n DdSdkReactNative.enableFeatures(configuration)\n DdSdkReactNative.wasInitialized = true\n resolve()\n }, (rejection) => {\n reject(rejection)\n })\n })\n }\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n return DdSdk.setAttributes(attributes)\n }\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser(user: object): Promise<void> {\n return DdSdk.setUser(user)\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n return DdSdk.setTrackingConsent(consent)\n }\n\n private static enableFeatures(configuration: DdSdkReactNativeConfiguration) {\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking();\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","initialize","configuration","Promise","resolve","reject","wasInitialized","additionalConfig","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","verbosity","undefined","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","ProxyType","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_NATIVE_LONG_TASK_THRESHOLD_KEY","NATIVE_LONG_TASK_THRESHOLD_MS","DdSdk","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","then","enableFeatures","rejection","setAttributes","attributes","setUser","user","setTrackingConsent","consent","trackInteractions","DdRumUserInteractionTracking","startTracking","trackResources","DdRumResourceTracking","trackErrors","DdRumErrorTracking"],"mappings":"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","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { DdSdkReactNativeConfiguration } from \"./DdSdkReactNativeConfiguration\"\nimport { DdSdkConfiguration } from \"./types\"\nimport { DdSdk } from \"./foundation\"\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking'\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking'\nimport { DdRumResourceTracking } from './rum/instrumentation/DdRumResourceTracking'\nimport type { TrackingConsent } from \"./TrackingConsent\"\nimport { ProxyType } from \"./ProxyConfiguration\"\n\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\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 = \"_dd.native_view_tracking\";\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = \"_dd.proxy.type\";\n private static readonly DD_PROXY_ADDRESS_KEY = \"_dd.proxy.address\";\n private static readonly DD_PROXY_PORT_KEY = \"_dd.proxy.port\";\n private static readonly DD_PROXY_USERNAME_KEY = \"_dd.proxy.username\";\n private static readonly DD_PROXY_PASSWORD_KEY = \"_dd.proxy.password\";\n\n private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY = \"_dd.long_task.threshold\"\n private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200\n\n\n private static wasInitialized = false\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize(configuration: DdSdkReactNativeConfiguration): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (DdSdkReactNative.wasInitialized) {\n resolve()\n return\n }\n\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] = 'react-native';\n configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERSION] = sdkVersion;\n configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY] = configuration.nativeViewTracking;\n if (configuration.verbosity != undefined) {\n configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERBOSITY_KEY] = 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] = proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] = proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] = proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type == ProxyType.SOCKS) {\n console.warn(\"SOCKS proxy configuration doesn't support Basic authentication.\")\n } else {\n additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] = proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] = proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] = configuration.serviceName;\n }\n\n configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY]\n = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS\n\n DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig\n )\n ).then(() => {\n DdSdkReactNative.enableFeatures(configuration)\n DdSdkReactNative.wasInitialized = true\n resolve()\n }, (rejection) => {\n reject(rejection)\n })\n })\n }\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n return DdSdk.setAttributes(attributes)\n }\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser(user: object): Promise<void> {\n return DdSdk.setUser(user)\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n return DdSdk.setTrackingConsent(consent)\n }\n\n private static enableFeatures(configuration: DdSdkReactNativeConfiguration) {\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking();\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n }\n}"]}
|
|
@@ -29,6 +29,14 @@ class DdSdkReactNativeConfiguration {
|
|
|
29
29
|
|
|
30
30
|
_defineProperty(this, "site", "US");
|
|
31
31
|
|
|
32
|
+
_defineProperty(this, "verbosity", undefined);
|
|
33
|
+
|
|
34
|
+
_defineProperty(this, "nativeViewTracking", false);
|
|
35
|
+
|
|
36
|
+
_defineProperty(this, "proxyConfig", undefined);
|
|
37
|
+
|
|
38
|
+
_defineProperty(this, "serviceName", undefined);
|
|
39
|
+
|
|
32
40
|
_defineProperty(this, "additionalConfig", {});
|
|
33
41
|
}
|
|
34
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","TrackingConsent","GRANTED"],"mappings":";;;;;;;AAMA;;;;
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","TrackingConsent","GRANTED","undefined"],"mappings":";;;;;;;AAMA;;;;AAIA;AACA;AACA;AACA;AACO,MAAMA,6BAAN,CAAoC;AAYvCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEC,eAAgC,GAAGC,iCAAgBC,OAPrD,EAQT;AAAA,SAPWR,WAOX,GAPWA,WAOX;AAAA,SANWC,GAMX,GANWA,GAMX;AAAA,SALWC,aAKX,GALWA,aAKX;AAAA,SAJWC,iBAIX,GAJWA,iBAIX;AAAA,SAHWC,cAGX,GAHWA,cAGX;AAAA,SAFWC,WAEX,GAFWA,WAEX;AAAA,SADWC,eACX,GADWA,eACX;;AAAA,sDAlByC,KAkBzC;;AAAA,wCAjB0B,KAiB1B;;AAAA,kCAhBoB,IAgBpB;;AAAA,uCAf+CG,SAe/C;;AAAA,gDAdmC,KAcnC;;AAAA,yCAbwCA,SAaxC;;AAAA,yCAZ4BA,SAY5B;;AAAA,8CAV4C,EAU5C;AAED;;AAtBsC","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 { TrackingConsent } from './TrackingConsent'\nimport type { NativeSdkVerbosity } from './NativeSdkVerbosity'\nimport type { ProxyConfiguration } from './ProxyConfiguration';\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 public nativeCrashReportEnabled: boolean = false;\n public sampleRate: number = 100.0;\n public site: string = \"US\"\n public verbosity: NativeSdkVerbosity|undefined = undefined\n public nativeViewTracking: boolean = false\n public proxyConfig?: ProxyConfiguration = undefined\n public serviceName?: string = undefined\n \n public additionalConfig: {[k: string]: any} = {};\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = TrackingConsent.GRANTED\n ) {\n\n }\n}\n"]}
|