@datadog/mobile-react-native 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +2 -1
- package/android/build.gradle +73 -3
- package/android/gradle.properties +1 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +86 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdLogs.kt +27 -11
- package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +305 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +280 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkBridgeExt.kt +2 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +29 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -4
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdTrace.kt +86 -0
- package/android/src/main/kotlin/com/datadog/reactnative/GlobalState.kt +32 -0
- package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +23 -0
- package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +60 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +170 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +408 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +1547 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +306 -0
- package/android/src/test/kotlin/com/datadog/reactnative/GlobalStateTest.kt +118 -0
- package/android/src/test/kotlin/com/datadog/reactnative/ProxyAuthenticatorTest.kt +123 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +43 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +22 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +267 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +26 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +20 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/Throwable.kt +31 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
- package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
- package/ios/Sources/AnyEncodable.swift +138 -0
- package/ios/Sources/Attributes.swift +101 -0
- package/ios/Sources/DdLogs.swift +35 -11
- package/ios/Sources/DdRum.m +3 -1
- package/ios/Sources/DdRum.swift +184 -22
- package/ios/Sources/DdSdk.swift +190 -10
- package/ios/Sources/DdSdkConfiguration.swift +51 -0
- package/ios/Sources/DdTrace.swift +41 -6
- package/ios/Sources/GlobalState.swift +28 -0
- package/ios/Sources/QueueHolder.swift +10 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +5 -6
- package/lib/commonjs/DdSdkReactNative.js +14 -0
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/foundation.js +36 -2
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +36 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +4 -17
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/types.js +26 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +14 -0
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/foundation.js +36 -2
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +26 -0
- package/lib/module/nativeModulesTypes.js.map +1 -0
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +2 -14
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +3 -4
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/types.js +23 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +2 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +20 -0
- package/lib/typescript/foundation.d.ts +3 -2
- package/lib/typescript/nativeModulesTypes.d.ts +168 -0
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +0 -15
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +2 -1
- package/lib/typescript/types.d.ts +42 -7
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/DdSdkReactNative.tsx +20 -0
- package/src/DdSdkReactNativeConfiguration.tsx +20 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +76 -0
- package/src/__tests__/foundation.test.ts +79 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +8 -8
- package/src/foundation.tsx +40 -11
- package/src/nativeModulesTypes.ts +258 -0
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +2 -17
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +3 -4
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +2 -1
- package/src/types.tsx +62 -7
- package/src/version.ts +1 -1
- package/android/src/main/java/com/datadog/reactnative/DdRum.kt +0 -142
- package/android/src/main/java/com/datadog/reactnative/DdSdk.kt +0 -67
- package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +0 -51
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type { ResourceKind } from '../../../../../../../core/src/types';
|
|
7
8
|
import type { DdRumResourceTracingAttributes } from '../distributedTracing';
|
|
8
9
|
|
|
9
10
|
export interface RUMResource {
|
|
@@ -11,7 +12,7 @@ export interface RUMResource {
|
|
|
11
12
|
request: {
|
|
12
13
|
method: string;
|
|
13
14
|
url: string;
|
|
14
|
-
kind:
|
|
15
|
+
kind: ResourceKind;
|
|
15
16
|
};
|
|
16
17
|
tracingAttributes: DdRumResourceTracingAttributes;
|
|
17
18
|
response: {
|
package/src/types.tsx
CHANGED
|
@@ -143,13 +143,13 @@ export type DdRumType = {
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Start tracking a RUM Action.
|
|
146
|
-
* @param type: The action type (tap, scroll, swipe,
|
|
146
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
147
147
|
* @param name: The action name.
|
|
148
148
|
* @param context: The additional context to send.
|
|
149
149
|
* @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
150
150
|
*/
|
|
151
151
|
startAction(
|
|
152
|
-
type:
|
|
152
|
+
type: RumActionType,
|
|
153
153
|
name: string,
|
|
154
154
|
context?: object,
|
|
155
155
|
timestampMs?: number
|
|
@@ -157,6 +157,24 @@ export type DdRumType = {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* Stop tracking the ongoing RUM Action.
|
|
160
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
161
|
+
* @param name: The action name.
|
|
162
|
+
* @param context: The additional context to send.
|
|
163
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
164
|
+
*/
|
|
165
|
+
stopAction(
|
|
166
|
+
type: RumActionType,
|
|
167
|
+
name: string,
|
|
168
|
+
context?: object,
|
|
169
|
+
timestampMs?: number
|
|
170
|
+
): Promise<void>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Stop tracking the ongoing RUM Action.
|
|
174
|
+
*
|
|
175
|
+
* Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.
|
|
176
|
+
*
|
|
177
|
+
* @deprecated add the `type` and `name` of the action as first two arguments.
|
|
160
178
|
* @param context: The additional context to send.
|
|
161
179
|
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
162
180
|
*/
|
|
@@ -164,13 +182,13 @@ export type DdRumType = {
|
|
|
164
182
|
|
|
165
183
|
/**
|
|
166
184
|
* Add a RUM Action.
|
|
167
|
-
* @param type: The action type (tap, scroll, swipe,
|
|
185
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
168
186
|
* @param name: The action name.
|
|
169
187
|
* @param context: The additional context to send.
|
|
170
188
|
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
171
189
|
*/
|
|
172
190
|
addAction(
|
|
173
|
-
type:
|
|
191
|
+
type: RumActionType,
|
|
174
192
|
name: string,
|
|
175
193
|
context?: object,
|
|
176
194
|
timestampMs?: number
|
|
@@ -204,7 +222,7 @@ export type DdRumType = {
|
|
|
204
222
|
stopResource(
|
|
205
223
|
key: string,
|
|
206
224
|
statusCode: number,
|
|
207
|
-
kind:
|
|
225
|
+
kind: ResourceKind,
|
|
208
226
|
size?: number,
|
|
209
227
|
context?: object,
|
|
210
228
|
timestampMs?: number
|
|
@@ -213,14 +231,14 @@ export type DdRumType = {
|
|
|
213
231
|
/**
|
|
214
232
|
* Add a RUM Error.
|
|
215
233
|
* @param message: The error message.
|
|
216
|
-
* @param source: The error source (network, source, console,
|
|
234
|
+
* @param source: The error source (network, source, console, webview, custom).
|
|
217
235
|
* @param stacktrace: The error stacktrace.
|
|
218
236
|
* @param context: The additional context to send.
|
|
219
237
|
* @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
220
238
|
*/
|
|
221
239
|
addError(
|
|
222
240
|
message: string,
|
|
223
|
-
source:
|
|
241
|
+
source: ErrorSource,
|
|
224
242
|
stacktrace: string,
|
|
225
243
|
context?: object,
|
|
226
244
|
timestampMs?: number
|
|
@@ -232,3 +250,40 @@ export type DdRumType = {
|
|
|
232
250
|
*/
|
|
233
251
|
addTiming(name: string): Promise<void>;
|
|
234
252
|
};
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Describe the type of a RUM Action.
|
|
256
|
+
*/
|
|
257
|
+
export enum RumActionType {
|
|
258
|
+
/** User tapped on a widget. */
|
|
259
|
+
TAP = 'TAP',
|
|
260
|
+
/** User scrolled a view. */
|
|
261
|
+
SCROLL = 'SCROLL',
|
|
262
|
+
/** User swiped on a view. */
|
|
263
|
+
SWIPE = 'SWIPE',
|
|
264
|
+
/** User pressed hardware back button (Android only). */
|
|
265
|
+
BACK = 'BACK',
|
|
266
|
+
/** A custom action. */
|
|
267
|
+
CUSTOM = 'CUSTOM'
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export type ResourceKind =
|
|
271
|
+
| 'image'
|
|
272
|
+
| 'xhr'
|
|
273
|
+
| 'beacon'
|
|
274
|
+
| 'css'
|
|
275
|
+
| 'document'
|
|
276
|
+
| 'fetch'
|
|
277
|
+
| 'font'
|
|
278
|
+
| 'js'
|
|
279
|
+
| 'media'
|
|
280
|
+
| 'other'
|
|
281
|
+
| 'native';
|
|
282
|
+
|
|
283
|
+
export enum ErrorSource {
|
|
284
|
+
NETWORK = 'NETWORK',
|
|
285
|
+
SOURCE = 'SOURCE',
|
|
286
|
+
CONSOLE = 'CONSOLE',
|
|
287
|
+
WEBVIEW = 'WEBVIEW',
|
|
288
|
+
CUSTOM = 'CUSTOM'
|
|
289
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.1.0';
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
-
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
-
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
package com.datadog.reactnative
|
|
8
|
-
|
|
9
|
-
import com.datadog.android.bridge.DdBridge
|
|
10
|
-
import com.datadog.android.bridge.DdRum as SDKDdRum
|
|
11
|
-
import com.facebook.react.bridge.Promise
|
|
12
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
14
|
-
import com.facebook.react.bridge.ReactMethod
|
|
15
|
-
import com.facebook.react.bridge.ReadableArray
|
|
16
|
-
import com.facebook.react.bridge.ReadableMap
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The entry point to use Datadog's RUM feature.
|
|
20
|
-
*/
|
|
21
|
-
class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
22
|
-
|
|
23
|
-
private val nativeInstance: SDKDdRum = DdBridge.getDdRum(reactContext)
|
|
24
|
-
|
|
25
|
-
override fun getName(): String = "DdRum"
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Start tracking a RUM View.
|
|
29
|
-
* @param key The view unique key identifier.
|
|
30
|
-
* @param name The view name.
|
|
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
|
-
*/
|
|
34
|
-
@ReactMethod
|
|
35
|
-
fun startView(key: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
36
|
-
nativeInstance.startView(key, name, context.toHashMap(), timestampMs.toLong())
|
|
37
|
-
promise.resolve(null)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Stop tracking a RUM View.
|
|
42
|
-
* @param key The view unique key identifier.
|
|
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
|
-
*/
|
|
46
|
-
@ReactMethod
|
|
47
|
-
fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
48
|
-
nativeInstance.stopView(key, context.toHashMap(), timestampMs.toLong())
|
|
49
|
-
promise.resolve(null)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Start tracking a RUM Action.
|
|
54
|
-
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
55
|
-
* @param name The action name.
|
|
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
|
-
*/
|
|
59
|
-
@ReactMethod
|
|
60
|
-
fun startAction(type: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
61
|
-
nativeInstance.startAction(type, name, context.toHashMap(), timestampMs.toLong())
|
|
62
|
-
promise.resolve(null)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Stop tracking the ongoing RUM Action.
|
|
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
|
-
*/
|
|
70
|
-
@ReactMethod
|
|
71
|
-
fun stopAction(context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
72
|
-
nativeInstance.stopAction(context.toHashMap(), timestampMs.toLong())
|
|
73
|
-
promise.resolve(null)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Add a RUM Action.
|
|
78
|
-
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
79
|
-
* @param name The action name.
|
|
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
|
-
*/
|
|
83
|
-
@ReactMethod
|
|
84
|
-
fun addAction(type: String, name: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
85
|
-
nativeInstance.addAction(type, name, context.toHashMap(), timestampMs.toLong())
|
|
86
|
-
promise.resolve(null)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Start tracking a RUM Resource.
|
|
91
|
-
* @param key The resource unique key identifier.
|
|
92
|
-
* @param method The resource method (GET, POST, …).
|
|
93
|
-
* @param url The resource url.
|
|
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
|
-
*/
|
|
97
|
-
@ReactMethod
|
|
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
|
-
promise.resolve(null)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Stop tracking a RUM Resource.
|
|
105
|
-
* @param key The resource unique key identifier.
|
|
106
|
-
* @param statusCode The resource status code.
|
|
107
|
-
* @param kind The resource's kind (xhr, document, image, css, font, …).
|
|
108
|
-
* @param size The resource size in bytes.
|
|
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.
|
|
111
|
-
*/
|
|
112
|
-
@ReactMethod
|
|
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())
|
|
115
|
-
promise.resolve(null)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Add a RUM Error.
|
|
120
|
-
* @param message The error message.
|
|
121
|
-
* @param source The error source (network, source, console, logger, …).
|
|
122
|
-
* @param stacktrace The error stacktrace.
|
|
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.
|
|
125
|
-
*/
|
|
126
|
-
@ReactMethod
|
|
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())
|
|
129
|
-
promise.resolve(null)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
|
|
134
|
-
* @param name The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
|
|
135
|
-
*/
|
|
136
|
-
@ReactMethod
|
|
137
|
-
fun addTiming(name: String, promise: Promise) {
|
|
138
|
-
nativeInstance.addTiming(name)
|
|
139
|
-
promise.resolve(null)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
-
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
-
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
package com.datadog.reactnative
|
|
8
|
-
|
|
9
|
-
import com.datadog.android.bridge.DdBridge
|
|
10
|
-
import com.datadog.android.bridge.DdSdk as SDKDdSdk
|
|
11
|
-
import com.facebook.react.bridge.Promise
|
|
12
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
14
|
-
import com.facebook.react.bridge.ReactMethod
|
|
15
|
-
import com.facebook.react.bridge.ReadableArray
|
|
16
|
-
import com.facebook.react.bridge.ReadableMap
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The entry point to initialize Datadog's features.
|
|
20
|
-
*/
|
|
21
|
-
class DdSdk(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
22
|
-
|
|
23
|
-
private val nativeInstance: SDKDdSdk = DdBridge.getDdSdk(reactContext)
|
|
24
|
-
|
|
25
|
-
override fun getName(): String = "DdSdk"
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Initializes Datadog's features.
|
|
29
|
-
* @param configuration The configuration to use.
|
|
30
|
-
*/
|
|
31
|
-
@ReactMethod
|
|
32
|
-
fun initialize(configuration: ReadableMap, promise: Promise) {
|
|
33
|
-
nativeInstance.initialize(configuration.asDdSdkConfiguration())
|
|
34
|
-
promise.resolve(null)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
|
|
39
|
-
* @param attributes The global context attributes.
|
|
40
|
-
*/
|
|
41
|
-
@ReactMethod
|
|
42
|
-
fun setAttributes(attributes: ReadableMap, promise: Promise) {
|
|
43
|
-
nativeInstance.setAttributes(attributes.toHashMap())
|
|
44
|
-
promise.resolve(null)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Set the user information.
|
|
49
|
-
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
50
|
-
*/
|
|
51
|
-
@ReactMethod
|
|
52
|
-
fun setUser(user: ReadableMap, promise: Promise) {
|
|
53
|
-
nativeInstance.setUser(user.toHashMap())
|
|
54
|
-
promise.resolve(null)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Set the tracking consent regarding the data collection.
|
|
59
|
-
* @param trackingConsent Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
60
|
-
*/
|
|
61
|
-
@ReactMethod
|
|
62
|
-
fun setTrackingConsent(trackingConsent: String, promise: Promise) {
|
|
63
|
-
nativeInstance.setTrackingConsent(trackingConsent)
|
|
64
|
-
promise.resolve(null)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
-
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
-
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
package com.datadog.reactnative
|
|
8
|
-
|
|
9
|
-
import com.datadog.android.bridge.DdBridge
|
|
10
|
-
import com.datadog.android.bridge.DdTrace as SDKDdTrace
|
|
11
|
-
import com.facebook.react.bridge.Promise
|
|
12
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
14
|
-
import com.facebook.react.bridge.ReactMethod
|
|
15
|
-
import com.facebook.react.bridge.ReadableArray
|
|
16
|
-
import com.facebook.react.bridge.ReadableMap
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The entry point to use Datadog's Trace feature.
|
|
20
|
-
*/
|
|
21
|
-
class DdTrace(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
22
|
-
|
|
23
|
-
private val nativeInstance: SDKDdTrace = DdBridge.getDdTrace(reactContext)
|
|
24
|
-
|
|
25
|
-
override fun getName(): String = "DdTrace"
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Start a span, and returns a unique identifier for the span.
|
|
29
|
-
* @param operation The operation name of the span.
|
|
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
|
-
*/
|
|
33
|
-
@ReactMethod
|
|
34
|
-
fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
35
|
-
val result = nativeInstance.startSpan(operation, context.toHashMap(), timestampMs.toLong())
|
|
36
|
-
promise.resolve(result)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Finish a started span.
|
|
41
|
-
* @param spanId The unique identifier of the span.
|
|
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
|
-
*/
|
|
45
|
-
@ReactMethod
|
|
46
|
-
fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
47
|
-
nativeInstance.finishSpan(spanId, context.toHashMap(), timestampMs.toLong())
|
|
48
|
-
promise.resolve(null)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|