@datadog/mobile-react-native 1.0.0-rc2 → 1.0.0-rc5
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 +8 -121
- 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 +63 -0
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +9 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/InternalLog.js +51 -0
- package/lib/commonjs/InternalLog.js.map +1 -0
- package/lib/commonjs/ProxyConfiguration.js +53 -0
- package/lib/commonjs/ProxyConfiguration.js.map +1 -0
- package/lib/commonjs/SdkVerbosity.js +26 -0
- package/lib/commonjs/SdkVerbosity.js.map +1 -0
- package/lib/commonjs/Timer.js +99 -0
- package/lib/commonjs/Timer.js.map +1 -0
- package/lib/commonjs/foundation.js +102 -45
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +28 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +6 -2
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +61 -14
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +110 -17
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +16 -4
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumXhr.js +4 -0
- package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js +1 -1
- package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.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 +54 -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/InternalLog.js +46 -0
- package/lib/module/InternalLog.js.map +1 -0
- package/lib/module/ProxyConfiguration.js +46 -0
- package/lib/module/ProxyConfiguration.js.map +1 -0
- package/lib/module/SdkVerbosity.js +18 -0
- package/lib/module/SdkVerbosity.js.map +1 -0
- package/lib/module/Timer.js +90 -0
- package/lib/module/Timer.js.map +1 -0
- package/lib/module/foundation.js +69 -44
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +5 -1
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +56 -14
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +99 -17
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +12 -4
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumXhr.js +1 -1
- package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js +1 -1
- package/lib/module/rum/instrumentation/NoOpEventsInterceptor.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 +9 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +5 -2
- package/lib/typescript/InternalLog.d.ts +6 -0
- package/lib/typescript/ProxyConfiguration.d.ts +56 -0
- package/lib/typescript/SdkVerbosity.d.ts +9 -0
- package/lib/typescript/Timer.d.ts +20 -0
- package/lib/typescript/index.d.ts +3 -1
- 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 +12 -11
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +3 -3
- package/src/DdSdkReactNative.tsx +57 -8
- package/src/DdSdkReactNativeConfiguration.tsx +6 -3
- package/src/InternalLog.tsx +48 -0
- package/src/ProxyConfiguration.tsx +37 -0
- package/src/{NativeSdkVerbosity.tsx → SdkVerbosity.tsx} +2 -2
- package/src/Timer.ts +96 -0
- package/src/__tests__/DdRumWrapper.test.tsx +91 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +213 -13
- package/src/__tests__/InternalLog.test.tsx +382 -0
- package/src/__tests__/Timer.test.ts +145 -0
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +155 -12
- package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +270 -26
- package/src/foundation.tsx +43 -33
- package/src/index.tsx +4 -2
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +68 -27
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +96 -22
- package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +4 -0
- package/src/rum/instrumentation/DdRumXhr.tsx +6 -5
- package/src/types.tsx +12 -11
- package/src/version.ts +2 -0
- package/lib/commonjs/NativeSdkVerbosity.js +0 -26
- package/lib/commonjs/NativeSdkVerbosity.js.map +0 -1
- package/lib/module/NativeSdkVerbosity.js +0 -18
- package/lib/module/NativeSdkVerbosity.js.map +0 -1
- package/lib/typescript/NativeSdkVerbosity.d.ts +0 -9
|
@@ -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.2"
|
|
21
21
|
|
|
22
22
|
s.test_spec 'Tests' do |test_spec|
|
|
23
23
|
test_spec.source_files = 'ios/Tests/*.swift'
|
package/README.md
CHANGED
|
@@ -35,19 +35,23 @@ import { DdSdkReactNative, DdSdkReactNativeConfiguration } from '@datadog/mobile
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
const config = new DdSdkReactNativeConfiguration(
|
|
38
|
-
"<CLIENT_TOKEN>",
|
|
39
|
-
"<ENVIRONMENT_NAME>",
|
|
38
|
+
"<CLIENT_TOKEN>",
|
|
39
|
+
"<ENVIRONMENT_NAME>",
|
|
40
40
|
"<RUM_APPLICATION_ID>",
|
|
41
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
42
|
true, // track XHR Resources
|
|
43
43
|
true // track Errors
|
|
44
44
|
)
|
|
45
|
-
// Optional: Select your Datadog website (one of "
|
|
46
|
-
config.site = "
|
|
45
|
+
// Optional: Select your Datadog website (one of "US1", "US3", "US5", EU1", or "US1_FED"). Default is "US1".
|
|
46
|
+
config.site = "US1"
|
|
47
47
|
// Optional: enable or disable native crash reports
|
|
48
48
|
config.nativeCrashReportEnabled = true
|
|
49
49
|
// Optional: sample RUM sessions (here, 80% of session will be sent to Datadog. Default = 100%)
|
|
50
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
|
+
// Optional: let the SDK print internal logs (above or equal to the provided level. Default = undefined (meaning no logs))
|
|
54
|
+
config.verbosity = SdkVerbosity.WARN
|
|
51
55
|
|
|
52
56
|
await DdSdkReactNative.initialize(config)
|
|
53
57
|
|
|
@@ -69,120 +73,3 @@ DdRum.startView('<view-key>', '/view/url', Date.now(), { 'custom.foo': "somethin
|
|
|
69
73
|
DdRum.stopView('<view-key>', Date.now(), { 'custom.bar': 42 });
|
|
70
74
|
```
|
|
71
75
|
|
|
72
|
-
## Track custom attributes
|
|
73
|
-
|
|
74
|
-
You can attach user information to all RUM events to get more detailed information from your RUM sessions.
|
|
75
|
-
|
|
76
|
-
### User information
|
|
77
|
-
|
|
78
|
-
For user-specific information, use the following code wherever you want in your app (after the SDK has been initialized). The `id`, `name`, and `email` attributes are built into Datadog, and you can add other attributes that makes sense for your app.
|
|
79
|
-
|
|
80
|
-
```js
|
|
81
|
-
import { DdSdkReactNative } from '@datadog/mobile-react-native';
|
|
82
|
-
|
|
83
|
-
DdSdkReactNative.setUser({
|
|
84
|
-
id: "1337",
|
|
85
|
-
name: "John Smith",
|
|
86
|
-
email: "john@example.com",
|
|
87
|
-
type: "premium"
|
|
88
|
-
})
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Global attributes
|
|
92
|
-
|
|
93
|
-
You can also keep global attributes to track information about a specific session, such as A/B testing configuration, ad campaign origin, or cart status.
|
|
94
|
-
|
|
95
|
-
```js
|
|
96
|
-
import { DdSdkReactNative } from '@datadog/mobile-react-native';
|
|
97
|
-
|
|
98
|
-
DdSdkReactNative.setAttributes({
|
|
99
|
-
profile_mode: "wall",
|
|
100
|
-
chat_enabled: true,
|
|
101
|
-
campaign_origin: "example_ad_network"
|
|
102
|
-
})
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Manual instrumentation
|
|
106
|
-
|
|
107
|
-
If automatic instrumentation doesn't suit your needs, you can manually create any type of events:
|
|
108
|
-
|
|
109
|
-
### RUM Events
|
|
110
|
-
|
|
111
|
-
In addition to manually creating Views (as mentioned above), you can also create custom Actions, Resources and Errors
|
|
112
|
-
|
|
113
|
-
```js
|
|
114
|
-
import { DdRum } from '@datadog/mobile-react-native';
|
|
115
|
-
|
|
116
|
-
// Track RUM Views manually
|
|
117
|
-
DdRum.startView('<view-key>', 'View Url', {}, Date.now());
|
|
118
|
-
//…
|
|
119
|
-
DdRum.stopView('<view-key>', { 'custom': 42 }, Date.now());
|
|
120
|
-
|
|
121
|
-
// Track RUM Actions manually
|
|
122
|
-
DdRum.addAction('TAP', 'button name', {}, Date.now());
|
|
123
|
-
// or in case of continuous action
|
|
124
|
-
DdRum.startAction('TAP', 'button name', {}, Date.now());
|
|
125
|
-
// to stop action above
|
|
126
|
-
DdRum.stopAction({}, Date.now());
|
|
127
|
-
|
|
128
|
-
// Add custom timings
|
|
129
|
-
DdRum.addTiming('<timing-name>');
|
|
130
|
-
|
|
131
|
-
// Track RUM Errors manually
|
|
132
|
-
DdRum.addError('<message>', 'source', '<stacktrace>', {}, Date.now());
|
|
133
|
-
|
|
134
|
-
// Track RUM Resource manually
|
|
135
|
-
DdRum.startResource('<res-key>', 'GET', 'http://www.example.com/api/v1/test', {}, Date.now());
|
|
136
|
-
//…
|
|
137
|
-
DdRum.stopResource('<res-key>', 200, 'xhr', {}, Date.now());
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Logs
|
|
141
|
-
|
|
142
|
-
You can send custom log messages from anywhere in your application using the following commands:
|
|
143
|
-
|
|
144
|
-
```js
|
|
145
|
-
import { DdLogs } from '@datadog/mobile-react-native';
|
|
146
|
-
|
|
147
|
-
// Send logs (use the debug, info, warn or error methods) with object to attach additional attributes to the log
|
|
148
|
-
DdLogs.debug("Lorem ipsum dolor sit amet…", { 'custom': 42 });
|
|
149
|
-
DdLogs.info("Lorem ipsum dolor sit amet…", { 'custom': 42 });
|
|
150
|
-
DdLogs.warn("Lorem ipsum dolor sit amet…", { 'custom': 42 });
|
|
151
|
-
DdLogs.error("Lorem ipsum dolor sit amet…", { 'custom': 42 });
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### Spans
|
|
155
|
-
|
|
156
|
-
You can use spans to trace local computation performance, using the following commands:
|
|
157
|
-
|
|
158
|
-
```js
|
|
159
|
-
import { DdTrace } from '@datadog/mobile-react-native';
|
|
160
|
-
|
|
161
|
-
// Start a span with an object to attach additional attributes to the span
|
|
162
|
-
const spanId = await DdTrace.startSpan("<operation-name>", { 'custom.x': 42 }, Date.now());
|
|
163
|
-
|
|
164
|
-
// perform some computation...
|
|
165
|
-
|
|
166
|
-
// Stop the previously started span
|
|
167
|
-
DdTrace.finishSpan(spanId, { 'custom.y': 23 }, Date.now());
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## Resource timings
|
|
171
|
-
|
|
172
|
-
Resource tracking is able to provide the following timings:
|
|
173
|
-
|
|
174
|
-
* `First Byte` - The time between the scheduled request and the first byte of the response. This includes time for the request preparation on the native level, network latency, and the time it took the server to prepare the response.
|
|
175
|
-
* `Download` - The time it took to receive a response.
|
|
176
|
-
|
|
177
|
-
## License
|
|
178
|
-
|
|
179
|
-
[Apache License, v2.0](LICENSE)
|
|
180
|
-
|
|
181
|
-
## Further Reading
|
|
182
|
-
|
|
183
|
-
{{< partial name="whats-next/whats-next.html" >}}
|
|
184
|
-
|
|
185
|
-
[1]: https://app.datadoghq.com/rum/application/create
|
|
186
|
-
[2]: https://raw.githubusercontent.com/DataDog/dd-sdk-reactnative/main/docs/image_reactnative.png
|
|
187
|
-
[3]: https://docs.datadoghq.com/account_management/api-app-keys/#api-keys
|
|
188
|
-
[4]: https://docs.datadoghq.com/account_management/api-app-keys/#client-tokens
|
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.3"
|
|
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
|
|