@datadog/mobile-react-native 1.0.0-rc3 → 1.0.0-rc6

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.
Files changed (137) hide show
  1. package/DatadogSDKReactNative.podspec +1 -1
  2. package/README.md +47 -16
  3. package/android/build.gradle +2 -3
  4. package/android/gradle.properties +4 -4
  5. package/android/src/main/java/com/datadog/reactnative/DdRum.kt +25 -24
  6. package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +6 -6
  7. package/ios/Sources/DdRum.m +10 -9
  8. package/ios/Sources/DdRum.swift +24 -24
  9. package/ios/Sources/DdTrace.m +2 -2
  10. package/ios/Sources/DdTrace.swift +6 -6
  11. package/lib/commonjs/DdSdkReactNative.js +42 -22
  12. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  13. package/lib/commonjs/DdSdkReactNativeConfiguration.js +17 -2
  14. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  15. package/lib/commonjs/InternalLog.js +51 -0
  16. package/lib/commonjs/InternalLog.js.map +1 -0
  17. package/lib/commonjs/ProxyConfiguration.js.map +1 -1
  18. package/lib/commonjs/SdkVerbosity.js +26 -0
  19. package/lib/commonjs/SdkVerbosity.js.map +1 -0
  20. package/lib/commonjs/TimeProvider.js +72 -0
  21. package/lib/commonjs/TimeProvider.js.map +1 -0
  22. package/lib/commonjs/Timer.js +10 -23
  23. package/lib/commonjs/Timer.js.map +1 -1
  24. package/lib/commonjs/TrackingConsent.js.map +1 -1
  25. package/lib/commonjs/foundation.js +62 -40
  26. package/lib/commonjs/foundation.js.map +1 -1
  27. package/lib/commonjs/index.js +26 -18
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/commonjs/internal.js +14 -0
  30. package/lib/commonjs/internal.js.map +1 -0
  31. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +14 -5
  32. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  33. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +51 -20
  34. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  35. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +141 -30
  36. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
  37. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +46 -7
  38. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  39. package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
  40. package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js +34 -0
  41. package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
  42. package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +1 -1
  43. package/lib/commonjs/types.js.map +1 -1
  44. package/lib/commonjs/version.js +10 -0
  45. package/lib/commonjs/version.js.map +1 -0
  46. package/lib/module/DdSdkReactNative.js +34 -22
  47. package/lib/module/DdSdkReactNative.js.map +1 -1
  48. package/lib/module/DdSdkReactNativeConfiguration.js +18 -3
  49. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  50. package/lib/module/InternalLog.js +46 -0
  51. package/lib/module/InternalLog.js.map +1 -0
  52. package/lib/module/ProxyConfiguration.js.map +1 -1
  53. package/lib/module/SdkVerbosity.js +18 -0
  54. package/lib/module/SdkVerbosity.js.map +1 -0
  55. package/lib/module/TimeProvider.js +63 -0
  56. package/lib/module/TimeProvider.js.map +1 -0
  57. package/lib/module/Timer.js +14 -23
  58. package/lib/module/Timer.js.map +1 -1
  59. package/lib/module/TrackingConsent.js.map +1 -1
  60. package/lib/module/foundation.js +42 -40
  61. package/lib/module/foundation.js.map +1 -1
  62. package/lib/module/index.js +3 -2
  63. package/lib/module/index.js.map +1 -1
  64. package/lib/module/internal.js +2 -0
  65. package/lib/module/internal.js.map +1 -0
  66. package/lib/module/rum/instrumentation/DdEventsInterceptor.js +11 -5
  67. package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  68. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +46 -20
  69. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  70. package/lib/module/rum/instrumentation/DdRumResourceTracking.js +133 -29
  71. package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
  72. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +41 -6
  73. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  74. package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
  75. package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js +25 -0
  76. package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
  77. package/lib/module/rum/instrumentation/TraceIdentifier.js.map +1 -1
  78. package/lib/module/types.js.map +1 -1
  79. package/lib/module/version.js +3 -0
  80. package/lib/module/version.js.map +1 -0
  81. package/lib/typescript/DdSdkReactNative.d.ts +7 -6
  82. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +15 -4
  83. package/lib/typescript/InternalLog.d.ts +6 -0
  84. package/lib/typescript/SdkVerbosity.d.ts +9 -0
  85. package/lib/typescript/TimeProvider.d.ts +20 -0
  86. package/lib/typescript/Timer.d.ts +3 -2
  87. package/lib/typescript/index.d.ts +3 -2
  88. package/lib/typescript/internal.d.ts +1 -0
  89. package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
  90. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +3 -2
  91. package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +13 -8
  92. package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -3
  93. package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +13 -3
  94. package/lib/typescript/rum/instrumentation/ShallowObjectEqualityChecker.d.ts +4 -0
  95. package/lib/typescript/types.d.ts +12 -11
  96. package/lib/typescript/version.d.ts +1 -0
  97. package/package.json +7 -4
  98. package/src/DdSdkReactNative.tsx +112 -58
  99. package/src/DdSdkReactNativeConfiguration.tsx +22 -14
  100. package/src/InternalLog.tsx +45 -0
  101. package/src/ProxyConfiguration.tsx +5 -5
  102. package/src/{NativeSdkVerbosity.tsx → SdkVerbosity.tsx} +6 -6
  103. package/src/TimeProvider.tsx +64 -0
  104. package/src/Timer.ts +20 -35
  105. package/src/TrackingConsent.tsx +3 -3
  106. package/src/__mocks__/InternalLog.tsx +9 -0
  107. package/src/__tests__/DdRumWrapper.test.tsx +98 -0
  108. package/src/__tests__/DdSdkReactNative.test.tsx +699 -500
  109. package/src/__tests__/InternalLog.test.tsx +379 -0
  110. package/src/__tests__/TimeProvider.test.tsx +75 -0
  111. package/src/__tests__/Timer.test.ts +148 -57
  112. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +151 -92
  113. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +243 -76
  114. package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +723 -403
  115. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +239 -85
  116. package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +31 -0
  117. package/src/__tests__/rum/instrumentation/TraceIdentifier.test.tsx +13 -15
  118. package/src/__tests__/rum/instrumentation/__utils__/XMLHttpRequestMock.ts +97 -0
  119. package/src/foundation.tsx +55 -42
  120. package/src/index.tsx +13 -3
  121. package/src/internal.tsx +1 -0
  122. package/src/rum/instrumentation/DdEventsInterceptor.tsx +51 -35
  123. package/src/rum/instrumentation/DdRumErrorTracking.tsx +75 -42
  124. package/src/rum/instrumentation/DdRumResourceTracking.tsx +312 -166
  125. package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +72 -25
  126. package/src/rum/instrumentation/DdRumXhr.tsx +21 -11
  127. package/src/rum/instrumentation/EventsInterceptor.tsx +3 -3
  128. package/src/rum/instrumentation/NoOpEventsInterceptor.tsx +2 -2
  129. package/src/rum/instrumentation/ShallowObjectEqualityChecker.ts +24 -0
  130. package/src/rum/instrumentation/TraceIdentifier.tsx +19 -19
  131. package/src/types.tsx +199 -157
  132. package/src/version.ts +2 -0
  133. package/lib/commonjs/NativeSdkVerbosity.js +0 -26
  134. package/lib/commonjs/NativeSdkVerbosity.js.map +0 -1
  135. package/lib/module/NativeSdkVerbosity.js +0 -18
  136. package/lib/module/NativeSdkVerbosity.js.map +0 -1
  137. 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", "~> 0.4.7"
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
@@ -1,6 +1,6 @@
1
1
  # React-Native Monitoring
2
2
 
3
- Datadog *Real User Monitoring (RUM)* enables you to visualize and analyze the real-time performance and user journeys of your application’s individual users.
3
+ Datadog Real User Monitoring (RUM) enables you to visualize and analyze the real-time performance and user journeys of your application’s individual users.
4
4
 
5
5
  ## Setup
6
6
 
@@ -18,6 +18,8 @@ yarn add @datadog/mobile-react-native
18
18
 
19
19
  **Minimum React Native version**: SDK supports React Native version 0.63.4 or higher. Compatibility with older versions is not guaranteed out of the box.
20
20
 
21
+ Versions `1.0.0-rc5` and higher require you to have `compileSdkVersion = 31` in the Android application setup, which implies that you should use Build Tools version 31, Android Gradle Plugin version 7, and Gradle version 7 or higher. To modify the versions, change the values in the `buildscript.ext` block of your application's top-level `build.gradle` file. Datadog recommends using React Native version 0.67 or higher.
22
+
21
23
  ### Specify application details in UI
22
24
 
23
25
  1. In the [Datadog app][1], select **UX Monitoring > RUM Applications > New Application**.
@@ -31,27 +33,33 @@ To ensure the safety of your data, you must use a client token. You cannot use o
31
33
  ### Initialize the library with application context
32
34
 
33
35
  ```js
34
- import { DdSdkReactNative, DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';
35
-
36
+ import {
37
+ DdSdkReactNative,
38
+ DdSdkReactNativeConfiguration
39
+ } from '@datadog/mobile-react-native';
36
40
 
37
41
  const config = new DdSdkReactNativeConfiguration(
38
- "<CLIENT_TOKEN>",
39
- "<ENVIRONMENT_NAME>",
40
- "<RUM_APPLICATION_ID>",
42
+ '<CLIENT_TOKEN>',
43
+ '<ENVIRONMENT_NAME>',
44
+ '<RUM_APPLICATION_ID>',
41
45
  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
46
  true, // track XHR Resources
43
47
  true // track Errors
44
- )
48
+ );
45
49
  // Optional: Select your Datadog website (one of "US1", "US3", "US5", EU1", or "US1_FED"). Default is "US1".
46
- config.site = "US1"
50
+ config.site = 'US1';
47
51
  // Optional: enable or disable native crash reports
48
- config.nativeCrashReportEnabled = true
52
+ config.nativeCrashReportEnabled = true;
49
53
  // Optional: sample RUM sessions (here, 80% of session will be sent to Datadog. Default = 100%)
50
- config.sampleRate = 80
54
+ config.sessionSamplingRate = 80;
55
+ // Optional: sample tracing integrations for network calls between your app and your backend (here, 80% of calls to your instrumented backend will be linked from the RUM view to the APM view. Default = 20%)
56
+ config.resourceTracingSamplingRate = 80;
51
57
  // 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"
58
+ config.serviceName = 'com.example.reactnative';
59
+ // Optional: let the SDK print internal logs (above or equal to the provided level. Default = undefined (meaning no logs))
60
+ config.verbosity = SdkVerbosity.WARN;
53
61
 
54
- await DdSdkReactNative.initialize(config)
62
+ await DdSdkReactNative.initialize(config);
55
63
 
56
64
  // Once SDK is initialized you need to setup view tracking to be able to see data in the RUM Dashboard.
57
65
  ```
@@ -60,14 +68,37 @@ await DdSdkReactNative.initialize(config)
60
68
 
61
69
  Because React Native offers a wide range of libraries to create screen navigation, by default only manual View tracking is supported. You can manually start and stop a View using the following `startView()` and `stopView` methods.
62
70
 
63
-
64
71
  ```js
65
- import { DdSdkReactNative, DdSdkReactNativeConfiguration, DdLogs, DdRum } from '@datadog/mobile-react-native';
66
-
72
+ import {
73
+ DdSdkReactNative,
74
+ DdSdkReactNativeConfiguration,
75
+ DdLogs,
76
+ DdRum
77
+ } from '@datadog/mobile-react-native';
67
78
 
68
79
  // Start a view with a unique view identifier, a custom view url, and an object to attach additional attributes to the view
69
- DdRum.startView('<view-key>', '/view/url', Date.now(), { 'custom.foo': "something" });
80
+ DdRum.startView('<view-key>', '/view/url', Date.now(), {
81
+ 'custom.foo': 'something'
82
+ });
70
83
  // Stops a previously started view with the same unique view identifier, and an object to attach additional attributes to the view
71
84
  DdRum.stopView('<view-key>', Date.now(), { 'custom.bar': 42 });
72
85
  ```
73
86
 
87
+ ## Data Storage
88
+
89
+ ### Android
90
+
91
+ Before data is uploaded to Datadog, it is stored in cleartext in your application's cache directory.
92
+ This cache folder is protected by [Android's Application Sandbox][3], meaning that on most devices
93
+ this data can't be read by other applications. However, if the mobile device is rooted, or someone
94
+ tempers with the linux kernel, the stored data might become readable.
95
+
96
+ ### iOS
97
+
98
+ Before data is uploaded to Datadog, it is stored in cleartext in the cache directory (`Library/Caches`)
99
+ of your [application sandbox](4), which can't be read by any other app installed on the device.
100
+
101
+ [1]: https://app.datadoghq.com/rum/application/create
102
+ [2]: https://raw.githubusercontent.com/DataDog/dd-sdk-reactnative/main/docs/image_reactnative.png
103
+ [3]: https://source.android.com/security/app-sandbox
104
+ [4]: https://support.apple.com/guide/security/security-of-runtime-process-sec15bfe098e/web
@@ -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.4.6"
131
+ implementation "com.datadoghq:dd-bridge-android:0.5.3"
133
132
 
134
133
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
135
134
  }
@@ -1,4 +1,4 @@
1
- DdSdkReactNative_kotlinVersion=1.3.50
2
- DdSdkReactNative_compileSdkVersion=28
3
- DdSdkReactNative_buildToolsVersion=28.0.3
4
- DdSdkReactNative_targetSdkVersion=28
1
+ DdSdkReactNative_kotlinVersion=1.5.31
2
+ DdSdkReactNative_compileSdkVersion=31
3
+ DdSdkReactNative_buildToolsVersion=31.0.0
4
+ DdSdkReactNative_targetSdkVersion=31
@@ -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, timestampMs: Double, context: ReadableMap, promise: Promise) {
36
- nativeInstance.startView(key, name, timestampMs.toLong(), context.toHashMap())
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, timestampMs: Double, context: ReadableMap, promise: Promise) {
48
- nativeInstance.stopView(key, timestampMs.toLong(), context.toHashMap())
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, timestampMs: Double, context: ReadableMap, promise: Promise) {
61
- nativeInstance.startAction(type, name, timestampMs.toLong(), context.toHashMap())
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(timestampMs: Double, context: ReadableMap, promise: Promise) {
72
- nativeInstance.stopAction(timestampMs.toLong(), context.toHashMap())
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, timestampMs: Double, context: ReadableMap, promise: Promise) {
85
- nativeInstance.addAction(type, name, timestampMs.toLong(), context.toHashMap())
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, timestampMs: Double, context: ReadableMap, promise: Promise) {
99
- nativeInstance.startResource(key, method, url, timestampMs.toLong(), context.toHashMap())
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 timestampMs The timestamp when the resource stopped (in milliseconds).
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, timestampMs: Double, context: ReadableMap, promise: Promise) {
113
- nativeInstance.stopResource(key, statusCode.toLong(), kind, timestampMs.toLong(), context.toHashMap())
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, timestampMs: Double, context: ReadableMap, promise: Promise) {
127
- nativeInstance.addError(message, source, stacktrace, timestampMs.toLong(), context.toHashMap())
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, timestampMs: Double, context: ReadableMap, promise: Promise) {
35
- val result = nativeInstance.startSpan(operation, timestampMs.toLong(), context.toHashMap())
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, timestampMs: Double, context: ReadableMap, promise: Promise) {
47
- nativeInstance.finishSpan(spanId, timestampMs.toLong(), context.toHashMap())
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
 
@@ -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:(NSInteger)timestampMs
32
- withContext:(NSDictionary)context
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
- withTimestampms:(NSInteger)timestampMs
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
 
@@ -20,51 +20,51 @@ class RNDdRum: NSObject {
20
20
  @objc(methodQueue)
21
21
  let methodQueue: DispatchQueue = sharedQueue
22
22
 
23
- @objc(startView:withName:withTimestampms:withContext:withResolver:withRejecter:)
24
- func startView(key: NSString, name: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
25
- nativeInstance.startView(key: key, name: name, timestampMs: timestampMs, context: context)
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:withContext:withResolver:withRejecter:)
30
- func stopView(key: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
31
- nativeInstance.stopView(key: key, timestampMs: timestampMs, context: context)
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:withContext:withResolver:withRejecter:)
36
- func startAction(type: NSString, name: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
37
- nativeInstance.startAction(type: type, name: name, timestampMs: timestampMs, context: context)
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:withContext:withResolver:withRejecter:)
42
- func stopAction(timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
43
- nativeInstance.stopAction(timestampMs: timestampMs, context: context)
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:withContext:withResolver:withRejecter:)
48
- func addAction(type: NSString, name: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
49
- nativeInstance.addAction(type: type, name: name, timestampMs: timestampMs, context: context)
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:withContext:withResolver:withRejecter:)
54
- func startResource(key: NSString, method: NSString, url: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
55
- nativeInstance.startResource(key: key, method: method, url: url, timestampMs: timestampMs, context: context)
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:withTimestampms:withContext:withResolver:withRejecter:)
60
- func stopResource(key: NSString, statusCode: Int64, kind: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
61
- nativeInstance.stopResource(key: key, statusCode: statusCode, kind: kind, timestampMs: timestampMs, context: context)
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:withContext:withResolver:withRejecter:)
66
- func addError(message: NSString, source: NSString, stacktrace: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
67
- nativeInstance.addError(message: message, source: source, stacktrace: stacktrace, timestampMs: timestampMs, context: context)
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
 
@@ -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:withContext:withResolver:withRejecter:)
24
- func startSpan(operation: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
25
- let result = nativeInstance.startSpan(operation: operation, timestampMs: timestampMs, context: context)
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:withContext:withResolver:withRejecter:)
30
- func finishSpan(spanId: NSString, timestampMs: Int64, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
31
- nativeInstance.finishSpan(spanId: spanId, timestampMs: timestampMs, context: context)
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