@datadog/mobile-react-native 2.3.2 → 2.3.4
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 -0
- package/android/build.gradle +2 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +9 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +13 -2
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +3 -2
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +36 -13
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +3 -2
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +4 -2
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +1 -1
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +11 -2
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +4 -2
- package/datadog-sourcemaps.gradle +13 -2
- package/ios/Sources/DdRum.mm +11 -0
- package/ios/Sources/DdRumImplementation.swift +7 -0
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +9 -1
- package/lib/commonjs/DdSdkReactNative.js +11 -4
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +26 -12
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +14 -6
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
- package/lib/commonjs/trace/DdTrace.js +2 -2
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/utils/Timer.js +4 -4
- package/lib/commonjs/utils/Timer.js.map +1 -1
- package/lib/commonjs/utils/time-provider/DefaultTimeProvider.js +41 -0
- package/lib/commonjs/utils/time-provider/DefaultTimeProvider.js.map +1 -0
- package/lib/commonjs/utils/{TimeProvider.js → time-provider/TimeProvider.js} +4 -25
- package/lib/commonjs/utils/time-provider/TimeProvider.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +11 -4
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/DdRum.js +25 -11
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +14 -6
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/module/specs/NativeDdRum.js.map +1 -1
- package/lib/module/trace/DdTrace.js +2 -2
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/utils/Timer.js +4 -4
- package/lib/module/utils/Timer.js.map +1 -1
- package/lib/module/utils/time-provider/DefaultTimeProvider.js +36 -0
- package/lib/module/utils/time-provider/DefaultTimeProvider.js.map +1 -0
- package/lib/module/utils/{TimeProvider.js → time-provider/TimeProvider.js} +4 -25
- package/lib/module/utils/time-provider/TimeProvider.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +5 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +7 -7
- package/lib/typescript/index.d.ts +5 -1
- package/lib/typescript/logs/types.d.ts +10 -10
- package/lib/typescript/nativeModulesTypes.d.ts +5 -5
- package/lib/typescript/rum/DdRum.d.ts +4 -0
- package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts +4 -4
- package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
- package/lib/typescript/rum/eventMappers/resourceEventMapper.d.ts +4 -4
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +3 -3
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +1 -1
- package/lib/typescript/rum/types.d.ts +7 -3
- package/lib/typescript/sdk/AttributesSingleton/types.d.ts +1 -1
- package/lib/typescript/sdk/DatadogProvider/Buffer/BoundedBuffer.d.ts +2 -0
- package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts +2 -2
- package/lib/typescript/sdk/EventMappers/EventMapper.d.ts +1 -1
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +1 -1
- package/lib/typescript/specs/NativeDdRum.d.ts +4 -0
- package/lib/typescript/types.d.ts +2 -2
- package/lib/typescript/utils/Timer.d.ts +1 -1
- package/lib/typescript/utils/time-provider/DefaultTimeProvider.d.ts +7 -0
- package/lib/typescript/utils/{TimeProvider.d.ts → time-provider/TimeProvider.d.ts} +5 -7
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +10 -4
- package/src/__tests__/DdSdkReactNative.test.tsx +2 -2
- package/src/__tests__/mock.test.ts +1 -1
- package/src/index.tsx +7 -0
- package/src/rum/DdRum.ts +24 -12
- package/src/rum/__mocks__/MockTimeProvider.ts +26 -0
- package/src/rum/__tests__/DdRum.test.ts +39 -13
- package/src/rum/__tests__/DdRumTimeProvider.test.ts +23 -0
- package/src/rum/types.ts +5 -0
- package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +22 -14
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +7 -6
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +5 -5
- package/src/specs/NativeDdRum.ts +5 -0
- package/src/trace/DdTrace.ts +2 -2
- package/src/utils/Timer.ts +5 -5
- package/src/utils/__tests__/TimeProvider.test.tsx +24 -7
- package/src/utils/__tests__/Timer.test.ts +38 -22
- package/src/utils/time-provider/DefaultTimeProvider.tsx +31 -0
- package/src/utils/{TimeProvider.tsx → time-provider/TimeProvider.tsx} +8 -27
- package/src/version.ts +1 -1
- package/lib/commonjs/utils/TimeProvider.js.map +0 -1
- package/lib/module/utils/TimeProvider.js.map +0 -1
package/android/build.gradle
CHANGED
|
@@ -18,6 +18,8 @@ buildscript {
|
|
|
18
18
|
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
|
|
19
19
|
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0"
|
|
20
20
|
classpath 'com.github.bjoernq:unmockplugin:0.7.9'
|
|
21
|
+
// Uncomment here and in settings.gradle for getting rid of IDE errors for new architecture:
|
|
22
|
+
// classpath "com.facebook.react:react-native-gradle-plugin"
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -264,6 +264,15 @@ class DdRumImplementation(private val datadog: DatadogWrapper = DatadogSDKWrappe
|
|
|
264
264
|
promise.resolve(null)
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Returns current session ID, or null if unavailable.
|
|
269
|
+
*/
|
|
270
|
+
fun getCurrentSessionId(promise: Promise) {
|
|
271
|
+
datadog.getRumMonitor().getCurrentSessionId {
|
|
272
|
+
promise.resolve(it)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
267
276
|
// region Internal
|
|
268
277
|
|
|
269
278
|
private fun String.asRumActionType(): RumActionType {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
9
|
import android.util.Log
|
|
10
|
+
import com.facebook.react.bridge.Arguments
|
|
10
11
|
import com.facebook.react.bridge.ReadableArray
|
|
11
12
|
import com.facebook.react.bridge.ReadableMap
|
|
12
13
|
import com.facebook.react.bridge.ReadableType
|
|
@@ -186,8 +187,18 @@ internal fun ReadableArray.toList(): List<*> {
|
|
|
186
187
|
ReadableType.Boolean -> list.add(getBoolean(i))
|
|
187
188
|
ReadableType.Number -> list.add(getDouble(i))
|
|
188
189
|
ReadableType.String -> list.add(getString(i))
|
|
189
|
-
ReadableType.Map ->
|
|
190
|
-
|
|
190
|
+
ReadableType.Map -> {
|
|
191
|
+
// getMap() return type is nullable in previous RN versions
|
|
192
|
+
@Suppress("USELESS_ELVIS")
|
|
193
|
+
val readableMap = getMap(i) ?: Arguments.createMap()
|
|
194
|
+
list.add(readableMap.toMap())
|
|
195
|
+
}
|
|
196
|
+
ReadableType.Array -> {
|
|
197
|
+
// getArray() return type is nullable in previous RN versions
|
|
198
|
+
@Suppress("USELESS_ELVIS")
|
|
199
|
+
val readableArray = getArray(i) ?: Arguments.createArray()
|
|
200
|
+
list.add(readableArray.toList())
|
|
201
|
+
}
|
|
191
202
|
else -> Log.e(
|
|
192
203
|
javaClass.simpleName,
|
|
193
204
|
"toList(): Unhandled ReadableType: ${type.name}."
|
|
@@ -15,10 +15,11 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
15
15
|
* The entry point to use Datadog's Logs feature.
|
|
16
16
|
*/
|
|
17
17
|
class DdLogs(
|
|
18
|
-
reactContext: ReactApplicationContext
|
|
18
|
+
reactContext: ReactApplicationContext,
|
|
19
|
+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
|
|
19
20
|
) : NativeDdLogsSpec(reactContext) {
|
|
20
21
|
|
|
21
|
-
private val implementation = DdLogsImplementation()
|
|
22
|
+
private val implementation = DdLogsImplementation(datadog = datadogWrapper)
|
|
22
23
|
|
|
23
24
|
override fun getName(): String = DdLogsImplementation.NAME
|
|
24
25
|
|
|
@@ -15,9 +15,12 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
15
15
|
* The entry point to use Datadog's RUM feature.
|
|
16
16
|
*/
|
|
17
17
|
@Suppress("TooManyFunctions")
|
|
18
|
-
class DdRum(
|
|
18
|
+
class DdRum(
|
|
19
|
+
reactContext: ReactApplicationContext,
|
|
20
|
+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
|
|
21
|
+
) : NativeDdRumSpec(reactContext) {
|
|
19
22
|
|
|
20
|
-
private val implementation = DdRumImplementation()
|
|
23
|
+
private val implementation = DdRumImplementation(datadog = datadogWrapper)
|
|
21
24
|
|
|
22
25
|
override fun getName(): String = DdRumImplementation.NAME
|
|
23
26
|
|
|
@@ -26,7 +29,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
26
29
|
* @param key The view unique key identifier.
|
|
27
30
|
* @param name The view name.
|
|
28
31
|
* @param context The additional context to send.
|
|
29
|
-
* @param timestampMs The timestamp when the view started (in milliseconds). If not provided,
|
|
32
|
+
* @param timestampMs The timestamp when the view started (in milliseconds). If not provided,
|
|
33
|
+
* current timestamp will be used.
|
|
30
34
|
*/
|
|
31
35
|
@ReactMethod
|
|
32
36
|
override fun startView(
|
|
@@ -43,7 +47,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
43
47
|
* Stop tracking a RUM View.
|
|
44
48
|
* @param key The view unique key identifier.
|
|
45
49
|
* @param context The additional context to send.
|
|
46
|
-
* @param timestampMs The timestamp when the view stopped (in milliseconds).
|
|
50
|
+
* @param timestampMs The timestamp when the view stopped (in milliseconds).
|
|
51
|
+
* If not provided, current timestamp will be used.
|
|
47
52
|
*/
|
|
48
53
|
@ReactMethod
|
|
49
54
|
override fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
@@ -55,7 +60,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
55
60
|
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
56
61
|
* @param name The action name.
|
|
57
62
|
* @param context The additional context to send.
|
|
58
|
-
* @param timestampMs The timestamp when the action started (in milliseconds).
|
|
63
|
+
* @param timestampMs The timestamp when the action started (in milliseconds).
|
|
64
|
+
* If not provided, current timestamp will be used.
|
|
59
65
|
*/
|
|
60
66
|
@ReactMethod
|
|
61
67
|
override fun startAction(
|
|
@@ -73,7 +79,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
73
79
|
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
74
80
|
* @param name The action name.
|
|
75
81
|
* @param context The additional context to send.
|
|
76
|
-
* @param timestampMs The timestamp when the action stopped (in milliseconds).
|
|
82
|
+
* @param timestampMs The timestamp when the action stopped (in milliseconds).
|
|
83
|
+
* If not provided, current timestamp will be used.
|
|
77
84
|
*/
|
|
78
85
|
@ReactMethod
|
|
79
86
|
override fun stopAction(
|
|
@@ -91,7 +98,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
91
98
|
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
92
99
|
* @param name The action name.
|
|
93
100
|
* @param context The additional context to send.
|
|
94
|
-
* @param timestampMs The timestamp when the action occurred (in milliseconds).
|
|
101
|
+
* @param timestampMs The timestamp when the action occurred (in milliseconds).
|
|
102
|
+
* If not provided, current timestamp will be used.
|
|
95
103
|
*/
|
|
96
104
|
@ReactMethod
|
|
97
105
|
override fun addAction(
|
|
@@ -110,7 +118,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
110
118
|
* @param method The resource method (GET, POST, …).
|
|
111
119
|
* @param url The resource url.
|
|
112
120
|
* @param context The additional context to send.
|
|
113
|
-
* @param timestampMs The timestamp when the resource started (in milliseconds).
|
|
121
|
+
* @param timestampMs The timestamp when the resource started (in milliseconds).
|
|
122
|
+
* If not provided, current timestamp will be used.
|
|
114
123
|
*/
|
|
115
124
|
@Suppress("LongParameterList")
|
|
116
125
|
@ReactMethod
|
|
@@ -132,7 +141,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
132
141
|
* @param kind The resource's kind (xhr, document, image, css, font, …).
|
|
133
142
|
* @param size The resource size in bytes.
|
|
134
143
|
* @param context The additional context to send.
|
|
135
|
-
* @param timestampMs The timestamp when the resource stopped (in milliseconds).
|
|
144
|
+
* @param timestampMs The timestamp when the resource stopped (in milliseconds).
|
|
145
|
+
* If not provided, current timestamp will be used.
|
|
136
146
|
*/
|
|
137
147
|
@Suppress("LongParameterList")
|
|
138
148
|
@ReactMethod
|
|
@@ -154,7 +164,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
154
164
|
* @param source The error source (network, source, console, logger, …).
|
|
155
165
|
* @param stacktrace The error stacktrace.
|
|
156
166
|
* @param context The additional context to send.
|
|
157
|
-
* @param timestampMs The timestamp when the error occurred (in milliseconds).
|
|
167
|
+
* @param timestampMs The timestamp when the error occurred (in milliseconds).
|
|
168
|
+
* If not provided, current timestamp will be used.
|
|
158
169
|
*/
|
|
159
170
|
@Suppress("LongParameterList")
|
|
160
171
|
@ReactMethod
|
|
@@ -170,8 +181,11 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
170
181
|
}
|
|
171
182
|
|
|
172
183
|
/**
|
|
173
|
-
* Adds a specific timing in the active View. The timing duration will be computed as the
|
|
174
|
-
*
|
|
184
|
+
* Adds a specific timing in the active View. The timing duration will be computed as the
|
|
185
|
+
* difference between the time the View was started and the time this function was called.
|
|
186
|
+
* @param name The name of the new custom timing attribute.
|
|
187
|
+
* Timings can be nested up to 8 levels deep.
|
|
188
|
+
* Names using more than 8 levels will be sanitized by SDK.
|
|
175
189
|
*/
|
|
176
190
|
@ReactMethod
|
|
177
191
|
override fun addTiming(name: String, promise: Promise) {
|
|
@@ -188,7 +202,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
188
202
|
|
|
189
203
|
/**
|
|
190
204
|
* Adds result of evaluating a feature flag to the view.
|
|
191
|
-
* Feature flag evaluations are local to the active view and are cleared when the view
|
|
205
|
+
* Feature flag evaluations are local to the active view and are cleared when the view
|
|
206
|
+
* is stopped.
|
|
192
207
|
* @param name The name of the feature flag
|
|
193
208
|
* @param value The value the feature flag evaluated to, encapsulated in a Map
|
|
194
209
|
*/
|
|
@@ -196,4 +211,12 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
|
|
|
196
211
|
override fun addFeatureFlagEvaluation(name: String, value: ReadableMap, promise: Promise) {
|
|
197
212
|
implementation.addFeatureFlagEvaluation(name, value, promise)
|
|
198
213
|
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Returns current session ID, or null if unavailable.
|
|
217
|
+
*/
|
|
218
|
+
@ReactMethod
|
|
219
|
+
override fun getCurrentSessionId(promise: Promise) {
|
|
220
|
+
implementation.getCurrentSessionId(promise)
|
|
221
|
+
}
|
|
199
222
|
}
|
|
@@ -13,10 +13,11 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
13
13
|
|
|
14
14
|
/** The entry point to initialize Datadog's features. */
|
|
15
15
|
class DdSdk(
|
|
16
|
-
reactContext: ReactApplicationContext
|
|
16
|
+
reactContext: ReactApplicationContext,
|
|
17
|
+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
|
|
17
18
|
) : NativeDdSdkSpec(reactContext) {
|
|
18
19
|
|
|
19
|
-
private val implementation = DdSdkImplementation(reactContext)
|
|
20
|
+
private val implementation = DdSdkImplementation(reactContext, datadog = datadogWrapper)
|
|
20
21
|
|
|
21
22
|
override fun getName(): String = DdSdkImplementation.NAME
|
|
22
23
|
|
|
@@ -26,7 +26,8 @@ class DdTrace(
|
|
|
26
26
|
* Start a span, and returns a unique identifier for the span.
|
|
27
27
|
* @param operation The operation name of the span.
|
|
28
28
|
* @param context The additional context to send.
|
|
29
|
-
* @param timestampMs The timestamp when the operation started (in milliseconds).
|
|
29
|
+
* @param timestampMs The timestamp when the operation started (in milliseconds).
|
|
30
|
+
* If not provided, current timestamp will be used.
|
|
30
31
|
*/
|
|
31
32
|
@ReactMethod
|
|
32
33
|
override fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
@@ -37,7 +38,8 @@ class DdTrace(
|
|
|
37
38
|
* Finish a started span.
|
|
38
39
|
* @param spanId The unique identifier of the span.
|
|
39
40
|
* @param context The additional context to send.
|
|
40
|
-
* @param timestampMs The timestamp when the operation stopped (in milliseconds).
|
|
41
|
+
* @param timestampMs The timestamp when the operation stopped (in milliseconds).
|
|
42
|
+
* If not provided, current timestamp will be used.
|
|
41
43
|
*/
|
|
42
44
|
@ReactMethod
|
|
43
45
|
override fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
@@ -17,7 +17,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
17
17
|
*/
|
|
18
18
|
class DdLogs(
|
|
19
19
|
reactContext: ReactApplicationContext,
|
|
20
|
-
datadogWrapper: DatadogWrapper
|
|
20
|
+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
|
|
21
21
|
) : ReactContextBaseJavaModule(reactContext) {
|
|
22
22
|
|
|
23
23
|
private val implementation = DdLogsImplementation(datadog = datadogWrapper)
|
|
@@ -18,7 +18,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
18
18
|
@Suppress("TooManyFunctions")
|
|
19
19
|
class DdRum(
|
|
20
20
|
reactContext: ReactApplicationContext,
|
|
21
|
-
datadogWrapper: DatadogWrapper
|
|
21
|
+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
|
|
22
22
|
) : ReactContextBaseJavaModule(reactContext) {
|
|
23
23
|
|
|
24
24
|
private val implementation = DdRumImplementation(datadog = datadogWrapper)
|
|
@@ -30,7 +30,8 @@ class DdRum(
|
|
|
30
30
|
* @param key The view unique key identifier.
|
|
31
31
|
* @param name The view name.
|
|
32
32
|
* @param context The additional context to send.
|
|
33
|
-
* @param timestampMs The timestamp when the view started (in milliseconds).
|
|
33
|
+
* @param timestampMs The timestamp when the view started (in milliseconds).
|
|
34
|
+
* If not provided, current timestamp will be used.
|
|
34
35
|
*/
|
|
35
36
|
@ReactMethod
|
|
36
37
|
fun startView(
|
|
@@ -200,4 +201,12 @@ class DdRum(
|
|
|
200
201
|
fun addFeatureFlagEvaluation(name: String, value: ReadableMap, promise: Promise) {
|
|
201
202
|
implementation.addFeatureFlagEvaluation(name, value, promise)
|
|
202
203
|
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Returns current session ID, or null if unavailable.
|
|
207
|
+
*/
|
|
208
|
+
@ReactMethod
|
|
209
|
+
fun getCurrentSessionId(promise: Promise) {
|
|
210
|
+
implementation.getCurrentSessionId(promise)
|
|
211
|
+
}
|
|
203
212
|
}
|
|
@@ -27,7 +27,8 @@ class DdTrace(
|
|
|
27
27
|
* Start a span, and returns a unique identifier for the span.
|
|
28
28
|
* @param operation The operation name of the span.
|
|
29
29
|
* @param context The additional context to send.
|
|
30
|
-
* @param timestampMs The timestamp when the operation started (in milliseconds).
|
|
30
|
+
* @param timestampMs The timestamp when the operation started (in milliseconds).
|
|
31
|
+
* If not provided, current timestamp will be used.
|
|
31
32
|
*/
|
|
32
33
|
@ReactMethod
|
|
33
34
|
fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
@@ -38,7 +39,8 @@ class DdTrace(
|
|
|
38
39
|
* Finish a started span.
|
|
39
40
|
* @param spanId The unique identifier of the span.
|
|
40
41
|
* @param context The additional context to send.
|
|
41
|
-
* @param timestampMs The timestamp when the operation stopped (in milliseconds).
|
|
42
|
+
* @param timestampMs The timestamp when the operation stopped (in milliseconds).
|
|
43
|
+
* If not provided, current timestamp will be used.
|
|
42
44
|
*/
|
|
43
45
|
@ReactMethod
|
|
44
46
|
fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
@@ -18,7 +18,8 @@ afterEvaluate {
|
|
|
18
18
|
|
|
19
19
|
androidExtension.applicationVariants.all { variant ->
|
|
20
20
|
|
|
21
|
-
def releaseVersion = variant
|
|
21
|
+
def releaseVersion = getVersionName(variant)
|
|
22
|
+
|
|
22
23
|
def buildVersion = variant.versionCode
|
|
23
24
|
|
|
24
25
|
if (releaseVersion == null) {
|
|
@@ -44,6 +45,7 @@ afterEvaluate {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
def serviceName = getServiceName(variant)
|
|
48
|
+
logger.info("Release version used for the upload of variant=${targetName} is ${releaseVersion}.")
|
|
47
49
|
logger.info("Service name used for the upload of variant=${targetName} is ${serviceName}.")
|
|
48
50
|
|
|
49
51
|
def bundleAssetName = reactConfig.bundleAssetName
|
|
@@ -203,10 +205,19 @@ private def runShellCommand(
|
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
private def getServiceName(variant) {
|
|
206
|
-
if (project.hasProperty("datadog")) {
|
|
208
|
+
if (project.hasProperty("datadog") && project.datadog.hasProperty("serviceName")) {
|
|
207
209
|
if (project.datadog.serviceName) {
|
|
208
210
|
return project.datadog.serviceName
|
|
209
211
|
}
|
|
210
212
|
}
|
|
211
213
|
return variant.applicationId
|
|
212
214
|
}
|
|
215
|
+
|
|
216
|
+
private def getVersionName(variant) {
|
|
217
|
+
def envVersionName = System.getenv('DATADOG_RELEASE_VERSION')
|
|
218
|
+
if (envVersionName != null) {
|
|
219
|
+
return envVersionName;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return variant.versionName
|
|
223
|
+
}
|
package/ios/Sources/DdRum.mm
CHANGED
|
@@ -120,6 +120,13 @@ RCT_REMAP_METHOD(addFeatureFlagEvaluation, withName:(NSString*)name
|
|
|
120
120
|
[self addFeatureFlagEvaluation:name value:value resolve:resolve reject:reject];
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
RCT_REMAP_METHOD(getCurrentSessionId,
|
|
124
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
125
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
126
|
+
{
|
|
127
|
+
[self getCurrentSessionId:resolve reject:reject];
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
// Thanks to this guard, we won't compile this code when we build for the old architecture.
|
|
124
131
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
125
132
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
@@ -157,6 +164,10 @@ RCT_REMAP_METHOD(addFeatureFlagEvaluation, withName:(NSString*)name
|
|
|
157
164
|
[self.ddRumImplementation addFeatureFlagEvaluationWithName:name value:value resolve:resolve reject:reject];
|
|
158
165
|
}
|
|
159
166
|
|
|
167
|
+
- (void)getCurrentSessionId:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
168
|
+
[self.ddRumImplementation getCurrentSessionId:resolve reject:reject];
|
|
169
|
+
}
|
|
170
|
+
|
|
160
171
|
- (void)addTiming:(NSString *)name resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
161
172
|
[self.ddRumImplementation addTimingWithName:name resolve:resolve reject:reject];
|
|
162
173
|
}
|
|
@@ -181,6 +181,13 @@ public class DdRumImplementation: NSObject {
|
|
|
181
181
|
}
|
|
182
182
|
resolve(nil)
|
|
183
183
|
}
|
|
184
|
+
|
|
185
|
+
@objc
|
|
186
|
+
public func getCurrentSessionId(_ resolve: @escaping (Any?) -> Void, reject: RCTPromiseRejectBlock) -> Void {
|
|
187
|
+
nativeRUM.currentSessionID { sessionId in
|
|
188
|
+
resolve(sessionId)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
184
191
|
|
|
185
192
|
// MARK: - Private methods
|
|
186
193
|
|
package/jest/mock.js
CHANGED
|
@@ -26,6 +26,7 @@ module.exports = {
|
|
|
26
26
|
initialize: jest
|
|
27
27
|
.fn()
|
|
28
28
|
.mockImplementation(() => new Promise(resolve => resolve())),
|
|
29
|
+
isInitialized: jest.fn().mockImplementation(() => true),
|
|
29
30
|
setUser: jest
|
|
30
31
|
.fn()
|
|
31
32
|
.mockImplementation(() => new Promise(resolve => resolve())),
|
|
@@ -105,7 +106,14 @@ module.exports = {
|
|
|
105
106
|
.mockImplementation(() => new Promise(resolve => resolve())),
|
|
106
107
|
stopSession: jest
|
|
107
108
|
.fn()
|
|
108
|
-
.mockImplementation(() => new Promise(resolve => resolve()))
|
|
109
|
+
.mockImplementation(() => new Promise(resolve => resolve())),
|
|
110
|
+
getCurrentSessionId: jest
|
|
111
|
+
.fn()
|
|
112
|
+
.mockImplementation(
|
|
113
|
+
() => new Promise(resolve => resolve('test-session-id'))
|
|
114
|
+
),
|
|
115
|
+
setTimeProvider: jest.fn().mockImplementation(() => {}),
|
|
116
|
+
timeProvider: jest.fn().mockReturnValue(undefined)
|
|
109
117
|
},
|
|
110
118
|
|
|
111
119
|
DatadogProvider: DatadogProviderMock
|
|
@@ -98,6 +98,13 @@ class DdSdkReactNative {
|
|
|
98
98
|
*/
|
|
99
99
|
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Returns `true` if the SDK was initialized, `false` otherwise.
|
|
103
|
+
*/
|
|
104
|
+
static isInitialized() {
|
|
105
|
+
return DdSdkReactNative._isInitialized;
|
|
106
|
+
}
|
|
107
|
+
|
|
101
108
|
static enableFeatures(configuration) {
|
|
102
109
|
if (DdSdkReactNative.wasAutoInstrumented) {
|
|
103
110
|
_InternalLog.InternalLog.log("Can't auto instrument Datadog, SDK was already instrumented", _SdkVerbosity.SdkVerbosity.WARN);
|
|
@@ -153,12 +160,12 @@ _defineProperty(DdSdkReactNative, "DD_VERSION", '_dd.version');
|
|
|
153
160
|
|
|
154
161
|
_defineProperty(DdSdkReactNative, "DD_VERSION_SUFFIX", '_dd.version_suffix');
|
|
155
162
|
|
|
156
|
-
_defineProperty(DdSdkReactNative, "wasInitialized", false);
|
|
157
|
-
|
|
158
163
|
_defineProperty(DdSdkReactNative, "wasAutoInstrumented", false);
|
|
159
164
|
|
|
160
165
|
_defineProperty(DdSdkReactNative, "features", void 0);
|
|
161
166
|
|
|
167
|
+
_defineProperty(DdSdkReactNative, "_isInitialized", false);
|
|
168
|
+
|
|
162
169
|
_defineProperty(DdSdkReactNative, "initialize", async configuration => {
|
|
163
170
|
await DdSdkReactNative.initializeNativeSDK(configuration, {
|
|
164
171
|
initializationModeForTelemetry: 'LEGACY'
|
|
@@ -167,7 +174,7 @@ _defineProperty(DdSdkReactNative, "initialize", async configuration => {
|
|
|
167
174
|
});
|
|
168
175
|
|
|
169
176
|
_defineProperty(DdSdkReactNative, "initializeNativeSDK", async (configuration, params) => {
|
|
170
|
-
if (DdSdkReactNative.
|
|
177
|
+
if (DdSdkReactNative._isInitialized) {
|
|
171
178
|
_InternalLog.InternalLog.log("Can't initialize Datadog, SDK was already initialized", _SdkVerbosity.SdkVerbosity.WARN);
|
|
172
179
|
|
|
173
180
|
if (!__DEV__) {
|
|
@@ -182,7 +189,7 @@ _defineProperty(DdSdkReactNative, "initializeNativeSDK", async (configuration, p
|
|
|
182
189
|
|
|
183
190
|
_InternalLog.InternalLog.log('Datadog SDK was initialized', _SdkVerbosity.SdkVerbosity.INFO);
|
|
184
191
|
|
|
185
|
-
DdSdkReactNative.
|
|
192
|
+
DdSdkReactNative._isInitialized = true;
|
|
186
193
|
|
|
187
194
|
_BufferSingleton.BufferSingleton.onInitialization();
|
|
188
195
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","_initializeFromDatadogProvider","configuration","enableFeatures","FileBasedConfiguration","initializeNativeSDK","initializationModeForTelemetry","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","wasAutoInstrumented","InternalLog","log","SdkVerbosity","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","actionNameAttribute","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","DdSdk","telemetryDebug","Promise","resolve","verbosity","initialize","buildConfiguration","INFO","BufferSingleton","onInitialization","attributes","JSON","stringify","DEBUG","setAttributes","AttributesSingleton","getInstance","user","setUser","UserInfoSingleton","setUserInfo","consent","setTrackingConsent","clearAllData","additionalConfiguration","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","version","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","customEndpoints","initializationType","trackNetworkRequests","reactNativeVersion","require","reactVersion","nativeViewTracking","nativeInteractionTracking","proxyConfig","serviceName","bundleLogsWithRum","bundleLogsWithTraces"],"mappings":";;;;;;;AAMA;;AAEA;;AAcA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,gBAAN,CAAuB;AAU1B;AACJ;AACA;AACA;AACA;;AAuCI;AACJ;AACA;AAC+C,eAA9BC,8BAA8B,CACvCC,aADuC,EAE1B;AACbF,IAAAA,gBAAgB,CAACG,cAAjB,CAAgCD,aAAhC;;AACA,QAAIA,aAAa,YAAYE,8CAA7B,EAAqD;AACjD,aAAOJ,gBAAgB,CAACK,mBAAjB,CAAqCH,aAArC,EAAoD;AACvDI,QAAAA,8BAA8B,EAAE;AADuB,OAApD,CAAP;AAGH;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F,mBAArC,CANG,EAOHjF,aAAa,CAACkF,UAAd,KAA6BC,SAA7B,GACMnF,aAAa,CAACoF,mBADpB,GAEMpF,aAAa,CAACkF,UATjB,EAUHlF,aAAa,CAACqF,IAVX,EAWHrF,aAAa,CAACsF,eAXX,EAYHtF,aAAa,CAACmE,uBAZX,EAaHnE,aAAa,CAACuF,mBAbX,EAcHvF,aAAa,CAACwF,qBAdX,EAeHxF,aAAa,CAACyF,eAfX,EAgBHzF,aAAa,CAAC0F,SAhBX,EAiBH1F,aAAa,CAAC2F,iBAjBX,EAkBH3F,aAAa,CAAC4F,qBAlBX,EAmBH5F,aAAa,CAAC6F,eAnBX,EAoBH;AACIC,IAAAA,kBAAkB,EAAEtD,MAAM,CAACpC,8BAD/B;AAEIwB,IAAAA,WAAW,EAAE5B,aAAa,CAAC4B,WAF/B;AAGIT,IAAAA,iBAAiB,EAAEnB,aAAa,CAACmB,iBAHrC;AAII4E,IAAAA,oBAAoB,EAAE/F,aAAa,CAACuB,cAJxC;AAKI;AACAyE,IAAAA,kBAAkB,EAAEC,OAAO,CAAC,2BAAD,CAAP,CACf1B,OAPT;AAQI;AACA2B,IAAAA,YAAY,EAAED,OAAO,CAAC,oBAAD,CAAP,CAA8B1B;AAThD,GApBG,EA+BHvE,aAAa,CAACmG,kBA/BX,EAgCHnG,aAAa,CAACoG,yBAhCX,EAiCHpG,aAAa,CAAC+C,SAjCX,EAkCH/C,aAAa,CAACqG,WAlCX,EAmCHrG,aAAa,CAACsG,WAnCX,EAoCH,0DAAsBtG,aAAa,CAAC2B,eAApC,CApCG,EAqCH3B,aAAa,CAACuG,iBArCX,EAsCHvG,aAAa,CAACwG,oBAtCX,CAAP;AAwCH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { FileBasedConfiguration } from './sdk/FileBasedConfiguration/FileBasedConfiguration';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { adaptLongTaskThreshold } from './utils/longTasksUtils';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n\n private static wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize = async (\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> => {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n };\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n await DdSdk.initialize(\n DdSdkReactNative.buildConfiguration(configuration, params)\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration instanceof FileBasedConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'FILE'\n });\n }\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes = async (attributes: Attributes): Promise<void> => {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().setAttributes(attributes);\n };\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser = async (user: UserInfo): Promise<void> => {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(user);\n };\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent = (consent: TrackingConsent): Promise<void> => {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n };\n\n /**\n * Clears all data that has not already been sent to Datadog servers\n * @returns a Promise\n */\n static clearAllData = (): Promise<void> => {\n InternalLog.log('Clearing all data', SdkVerbosity.DEBUG);\n return DdSdk.clearAllData();\n };\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): DdSdkConfiguration => {\n configuration.additionalConfiguration[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n\n if (configuration.version) {\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_VERSION\n ] = `${configuration.version}${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n return new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfiguration,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n configuration.customEndpoints,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n },\n configuration.nativeViewTracking,\n configuration.nativeInteractionTracking,\n configuration.verbosity,\n configuration.proxyConfig,\n configuration.serviceName,\n formatFirstPartyHosts(configuration.firstPartyHosts),\n configuration.bundleLogsWithRum,\n configuration.bundleLogsWithTraces\n );\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking({\n actionNameAttribute: configuration.actionNameAttribute\n });\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkReactNative","_initializeFromDatadogProvider","configuration","enableFeatures","FileBasedConfiguration","initializeNativeSDK","initializationModeForTelemetry","initializationMode","InitializationMode","SYNC","ASYNC","InteractionManager","runAfterInteractions","DdSdkReactNativeConfiguration","_enableFeaturesFromDatadogProvider","features","isInitialized","_isInitialized","wasAutoInstrumented","InternalLog","log","SdkVerbosity","WARN","trackInteractions","DdRumUserInteractionTracking","startTracking","actionNameAttribute","trackResources","DdRumResourceTracking","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","DdRumErrorTracking","logEventMapper","DdLogs","registerLogEventMapper","errorEventMapper","DdRum","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","__DEV__","DdSdk","telemetryDebug","Promise","resolve","verbosity","initialize","buildConfiguration","INFO","BufferSingleton","onInitialization","attributes","JSON","stringify","DEBUG","setAttributes","AttributesSingleton","getInstance","user","setUser","UserInfoSingleton","setUserInfo","consent","setTrackingConsent","clearAllData","additionalConfiguration","DD_SOURCE_KEY","DD_SDK_VERSION","sdkVersion","version","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX","DdSdkConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","customEndpoints","initializationType","trackNetworkRequests","reactNativeVersion","require","reactVersion","nativeViewTracking","nativeInteractionTracking","proxyConfig","serviceName","bundleLogsWithRum","bundleLogsWithTraces"],"mappings":";;;;;;;AAMA;;AAEA;;AAcA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,gBAAN,CAAuB;AAS1B;AACJ;AACA;AACA;AACA;;AAuCI;AACJ;AACA;AAC+C,eAA9BC,8BAA8B,CACvCC,aADuC,EAE1B;AACbF,IAAAA,gBAAgB,CAACG,cAAjB,CAAgCD,aAAhC;;AACA,QAAIA,aAAa,YAAYE,8CAA7B,EAAqD;AACjD,aAAOJ,gBAAgB,CAACK,mBAAjB,CAAqCH,aAArC,EAAoD;AACvDI,QAAAA,8BAA8B,EAAE;AADuB,OAApD,CAAP;AAGH;;AACD,QAAIJ,aAAa,CAACK,kBAAd,KAAqCC,kDAAmBC,IAA5D,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uBjF,aAAa,CAACkF,mBAArC,CANG,EAOHlF,aAAa,CAACmF,UAAd,KAA6BC,SAA7B,GACMpF,aAAa,CAACqF,mBADpB,GAEMrF,aAAa,CAACmF,UATjB,EAUHnF,aAAa,CAACsF,IAVX,EAWHtF,aAAa,CAACuF,eAXX,EAYHvF,aAAa,CAACoE,uBAZX,EAaHpE,aAAa,CAACwF,mBAbX,EAcHxF,aAAa,CAACyF,qBAdX,EAeHzF,aAAa,CAAC0F,eAfX,EAgBH1F,aAAa,CAAC2F,SAhBX,EAiBH3F,aAAa,CAAC4F,iBAjBX,EAkBH5F,aAAa,CAAC6F,qBAlBX,EAmBH7F,aAAa,CAAC8F,eAnBX,EAoBH;AACIC,IAAAA,kBAAkB,EAAErD,MAAM,CAACtC,8BAD/B;AAEI0B,IAAAA,WAAW,EAAE9B,aAAa,CAAC8B,WAF/B;AAGIT,IAAAA,iBAAiB,EAAErB,aAAa,CAACqB,iBAHrC;AAII2E,IAAAA,oBAAoB,EAAEhG,aAAa,CAACyB,cAJxC;AAKI;AACAwE,IAAAA,kBAAkB,EAAEC,OAAO,CAAC,2BAAD,CAAP,CACf1B,OAPT;AAQI;AACA2B,IAAAA,YAAY,EAAED,OAAO,CAAC,oBAAD,CAAP,CAA8B1B;AAThD,GApBG,EA+BHxE,aAAa,CAACoG,kBA/BX,EAgCHpG,aAAa,CAACqG,yBAhCX,EAiCHrG,aAAa,CAACgD,SAjCX,EAkCHhD,aAAa,CAACsG,WAlCX,EAmCHtG,aAAa,CAACuG,WAnCX,EAoCH,0DAAsBvG,aAAa,CAAC6B,eAApC,CApCG,EAqCH7B,aAAa,CAACwG,iBArCX,EAsCHxG,aAAa,CAACyG,oBAtCX,CAAP;AAwCH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { FileBasedConfiguration } from './sdk/FileBasedConfiguration/FileBasedConfiguration';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\nimport { DdSdkConfiguration } from './types';\nimport { adaptLongTaskThreshold } from './utils/longTasksUtils';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n private static _isInitialized = 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 = async (\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> => {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n };\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative._isInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n await DdSdk.initialize(\n DdSdkReactNative.buildConfiguration(configuration, params)\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative._isInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration instanceof FileBasedConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'FILE'\n });\n }\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes = async (attributes: Attributes): Promise<void> => {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().setAttributes(attributes);\n };\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser = async (user: UserInfo): Promise<void> => {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(user);\n };\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent = (consent: TrackingConsent): Promise<void> => {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n };\n\n /**\n * Clears all data that has not already been sent to Datadog servers\n * @returns a Promise\n */\n static clearAllData = (): Promise<void> => {\n InternalLog.log('Clearing all data', SdkVerbosity.DEBUG);\n return DdSdk.clearAllData();\n };\n\n /**\n * Returns `true` if the SDK was initialized, `false` otherwise.\n */\n public static isInitialized() {\n return DdSdkReactNative._isInitialized;\n }\n\n private static buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): DdSdkConfiguration => {\n configuration.additionalConfiguration[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n\n if (configuration.version) {\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_VERSION\n ] = `${configuration.version}${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfiguration[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n return new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfiguration,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.uploadFrequency,\n configuration.batchSize,\n configuration.trackFrustrations,\n configuration.trackBackgroundEvents,\n configuration.customEndpoints,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n },\n configuration.nativeViewTracking,\n configuration.nativeInteractionTracking,\n configuration.verbosity,\n configuration.proxyConfig,\n configuration.serviceName,\n formatFirstPartyHosts(configuration.firstPartyHosts),\n configuration.bundleLogsWithRum,\n configuration.bundleLogsWithTraces\n );\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking({\n actionNameAttribute: configuration.actionNameAttribute\n });\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -141,6 +141,18 @@ Object.defineProperty(exports, "DdTrace", {
|
|
|
141
141
|
return _DdTrace.DdTrace;
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
|
+
Object.defineProperty(exports, "DefaultTimeProvider", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return _DefaultTimeProvider.DefaultTimeProvider;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "TimeProvider", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return _TimeProvider.TimeProvider;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
144
156
|
|
|
145
157
|
var _DdSdkReactNativeConfiguration = require("./DdSdkReactNativeConfiguration");
|
|
146
158
|
|
|
@@ -167,4 +179,8 @@ var _DatadogProvider = require("./sdk/DatadogProvider/DatadogProvider");
|
|
|
167
179
|
var _FileBasedConfiguration = require("./sdk/FileBasedConfiguration/FileBasedConfiguration");
|
|
168
180
|
|
|
169
181
|
var _DdTrace = require("./trace/DdTrace");
|
|
182
|
+
|
|
183
|
+
var _DefaultTimeProvider = require("./utils/time-provider/DefaultTimeProvider");
|
|
184
|
+
|
|
185
|
+
var _TimeProvider = require("./utils/time-provider/TimeProvider");
|
|
170
186
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;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 UploadFrequency,\n BatchSize\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 { DdLogs } from './logs/DdLogs';\nimport { DdRum } from './rum/DdRum';\nimport {\n DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,\n DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,\n DATADOG_GRAPH_QL_VARIABLES_HEADER\n} from './rum/instrumentation/resourceTracking/graphql/graphqlHeaders';\nimport { RumActionType, ErrorSource, PropagatorType } from './rum/types';\nimport { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';\nimport { FileBasedConfiguration } from './sdk/FileBasedConfiguration/FileBasedConfiguration';\nimport { DdTrace } from './trace/DdTrace';\nimport { DefaultTimeProvider } from './utils/time-provider/DefaultTimeProvider';\nimport { TimeProvider } from './utils/time-provider/TimeProvider';\nimport type { Timestamp } from './utils/time-provider/TimeProvider';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n FileBasedConfiguration,\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 UploadFrequency,\n BatchSize,\n TimeProvider,\n DefaultTimeProvider,\n DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,\n DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,\n DATADOG_GRAPH_QL_VARIABLES_HEADER\n};\n\nexport type { Timestamp };\n"]}
|