Skip to content

Commit 631660e

Browse files
Merge remote-tracking branch 'origin' into jmoskovich/rum-2575/update-to-0.73
2 parents 5e5282b + 5b8a26c commit 631660e

File tree

12 files changed

+65
-26
lines changed

12 files changed

+65
-26
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"react": "18.2.0",
5959
"react-native": "0.73.6",
6060
"react-native-builder-bob": "0.17.1",
61+
"react-native-gradle-plugin": "^0.71.19",
6162
"react-native-webview": "11.26.1",
6263
"react-test-renderer": "18.1.0",
6364
"typescript": "5.0.4"

packages/core/android/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ buildscript {
1818
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
1919
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0"
2020
classpath 'com.github.bjoernq:unmockplugin:0.7.9'
21+
// Uncomment here and in settings.gradle for getting rid of IDE errors for new architecture:
22+
// classpath "com.facebook.react:react-native-gradle-plugin"
2123
}
2224
}
2325

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Uncomment here and in build.gradle for getting rid of IDE errors for new architecture:
2+
//includeBuild('../../../node_modules/react-native-gradle-plugin')

packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package com.datadog.reactnative
88

99
import android.util.Log
10+
import com.facebook.react.bridge.Arguments
1011
import com.facebook.react.bridge.ReadableArray
1112
import com.facebook.react.bridge.ReadableMap
1213
import com.facebook.react.bridge.ReadableType
@@ -186,8 +187,18 @@ internal fun ReadableArray.toList(): List<*> {
186187
ReadableType.Boolean -> list.add(getBoolean(i))
187188
ReadableType.Number -> list.add(getDouble(i))
188189
ReadableType.String -> list.add(getString(i))
189-
ReadableType.Map -> list.add(getMap(i).toMap())
190-
ReadableType.Array -> list.add(getArray(i).toList())
190+
ReadableType.Map -> {
191+
// getMap() return type is nullable in previous RN versions
192+
@Suppress("USELESS_ELVIS")
193+
val readableMap = getMap(i) ?: Arguments.createMap()
194+
list.add(readableMap.toMap())
195+
}
196+
ReadableType.Array -> {
197+
// getArray() return type is nullable in previous RN versions
198+
@Suppress("USELESS_ELVIS")
199+
val readableArray = getArray(i) ?: Arguments.createArray()
200+
list.add(readableArray.toList())
201+
}
191202
else -> Log.e(
192203
javaClass.simpleName,
193204
"toList(): Unhandled ReadableType: ${type.name}."

packages/core/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import com.facebook.react.bridge.ReadableMap
1515
* The entry point to use Datadog's Logs feature.
1616
*/
1717
class DdLogs(
18-
reactContext: ReactApplicationContext
18+
reactContext: ReactApplicationContext,
19+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
1920
) : NativeDdLogsSpec(reactContext) {
2021

21-
private val implementation = DdLogsImplementation()
22+
private val implementation = DdLogsImplementation(datadog = datadogWrapper)
2223

2324
override fun getName(): String = DdLogsImplementation.NAME
2425

packages/core/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ import com.facebook.react.bridge.ReadableMap
1515
* The entry point to use Datadog's RUM feature.
1616
*/
1717
@Suppress("TooManyFunctions")
18-
class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContext) {
18+
class DdRum(
19+
reactContext: ReactApplicationContext,
20+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
21+
) : NativeDdRumSpec(reactContext) {
1922

20-
private val implementation = DdRumImplementation()
23+
private val implementation = DdRumImplementation(datadog = datadogWrapper)
2124

2225
override fun getName(): String = DdRumImplementation.NAME
2326

@@ -26,7 +29,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
2629
* @param key The view unique key identifier.
2730
* @param name The view name.
2831
* @param context The additional context to send.
29-
* @param timestampMs The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
32+
* @param timestampMs The timestamp when the view started (in milliseconds). If not provided,
33+
* current timestamp will be used.
3034
*/
3135
@ReactMethod
3236
override fun startView(
@@ -43,7 +47,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
4347
* Stop tracking a RUM View.
4448
* @param key The view unique key identifier.
4549
* @param context The additional context to send.
46-
* @param timestampMs The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
50+
* @param timestampMs The timestamp when the view stopped (in milliseconds).
51+
* If not provided, current timestamp will be used.
4752
*/
4853
@ReactMethod
4954
override fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
@@ -55,7 +60,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
5560
* @param type The action type (tap, scroll, swipe, click, custom).
5661
* @param name The action name.
5762
* @param context The additional context to send.
58-
* @param timestampMs The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
63+
* @param timestampMs The timestamp when the action started (in milliseconds).
64+
* If not provided, current timestamp will be used.
5965
*/
6066
@ReactMethod
6167
override fun startAction(
@@ -73,7 +79,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
7379
* @param type The action type (tap, scroll, swipe, click, custom).
7480
* @param name The action name.
7581
* @param context The additional context to send.
76-
* @param timestampMs The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
82+
* @param timestampMs The timestamp when the action stopped (in milliseconds).
83+
* If not provided, current timestamp will be used.
7784
*/
7885
@ReactMethod
7986
override fun stopAction(
@@ -91,7 +98,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
9198
* @param type The action type (tap, scroll, swipe, click, custom).
9299
* @param name The action name.
93100
* @param context The additional context to send.
94-
* @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
101+
* @param timestampMs The timestamp when the action occurred (in milliseconds).
102+
* If not provided, current timestamp will be used.
95103
*/
96104
@ReactMethod
97105
override fun addAction(
@@ -110,7 +118,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
110118
* @param method The resource method (GET, POST, …).
111119
* @param url The resource url.
112120
* @param context The additional context to send.
113-
* @param timestampMs The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
121+
* @param timestampMs The timestamp when the resource started (in milliseconds).
122+
* If not provided, current timestamp will be used.
114123
*/
115124
@Suppress("LongParameterList")
116125
@ReactMethod
@@ -132,7 +141,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
132141
* @param kind The resource's kind (xhr, document, image, css, font, …).
133142
* @param size The resource size in bytes.
134143
* @param context The additional context to send.
135-
* @param timestampMs The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
144+
* @param timestampMs The timestamp when the resource stopped (in milliseconds).
145+
* If not provided, current timestamp will be used.
136146
*/
137147
@Suppress("LongParameterList")
138148
@ReactMethod
@@ -154,7 +164,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
154164
* @param source The error source (network, source, console, logger, …).
155165
* @param stacktrace The error stacktrace.
156166
* @param context The additional context to send.
157-
* @param timestampMs The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
167+
* @param timestampMs The timestamp when the error occurred (in milliseconds).
168+
* If not provided, current timestamp will be used.
158169
*/
159170
@Suppress("LongParameterList")
160171
@ReactMethod
@@ -170,8 +181,11 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
170181
}
171182

172183
/**
173-
* 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.
174-
* @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.
184+
* Adds a specific timing in the active View. The timing duration will be computed as the
185+
* difference between the time the View was started and the time this function was called.
186+
* @param name The name of the new custom timing attribute.
187+
* Timings can be nested up to 8 levels deep.
188+
* Names using more than 8 levels will be sanitized by SDK.
175189
*/
176190
@ReactMethod
177191
override fun addTiming(name: String, promise: Promise) {
@@ -188,7 +202,8 @@ class DdRum(reactContext: ReactApplicationContext) : NativeDdRumSpec(reactContex
188202

189203
/**
190204
* Adds result of evaluating a feature flag to the view.
191-
* Feature flag evaluations are local to the active view and are cleared when the view is stopped.
205+
* Feature flag evaluations are local to the active view and are cleared when the view
206+
* is stopped.
192207
* @param name The name of the feature flag
193208
* @param value The value the feature flag evaluated to, encapsulated in a Map
194209
*/

packages/core/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import com.facebook.react.bridge.ReadableMap
1313

1414
/** The entry point to initialize Datadog's features. */
1515
class DdSdk(
16-
reactContext: ReactApplicationContext
16+
reactContext: ReactApplicationContext,
17+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
1718
) : NativeDdSdkSpec(reactContext) {
1819

19-
private val implementation = DdSdkImplementation(reactContext)
20+
private val implementation = DdSdkImplementation(reactContext, datadog = datadogWrapper)
2021

2122
override fun getName(): String = DdSdkImplementation.NAME
2223

packages/core/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class DdTrace(
2626
* Start a span, and returns a unique identifier for the span.
2727
* @param operation The operation name of the span.
2828
* @param context The additional context to send.
29-
* @param timestampMs The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
29+
* @param timestampMs The timestamp when the operation started (in milliseconds).
30+
* If not provided, current timestamp will be used.
3031
*/
3132
@ReactMethod
3233
override fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
@@ -37,7 +38,8 @@ class DdTrace(
3738
* Finish a started span.
3839
* @param spanId The unique identifier of the span.
3940
* @param context The additional context to send.
40-
* @param timestampMs The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
41+
* @param timestampMs The timestamp when the operation stopped (in milliseconds).
42+
* If not provided, current timestamp will be used.
4143
*/
4244
@ReactMethod
4345
override fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {

packages/core/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import com.facebook.react.bridge.ReadableMap
1717
*/
1818
class DdLogs(
1919
reactContext: ReactApplicationContext,
20-
datadogWrapper: DatadogWrapper
20+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
2121
) : ReactContextBaseJavaModule(reactContext) {
2222

2323
private val implementation = DdLogsImplementation(datadog = datadogWrapper)

packages/core/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import com.facebook.react.bridge.ReadableMap
1818
@Suppress("TooManyFunctions")
1919
class DdRum(
2020
reactContext: ReactApplicationContext,
21-
datadogWrapper: DatadogWrapper
21+
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
2222
) : ReactContextBaseJavaModule(reactContext) {
2323

2424
private val implementation = DdRumImplementation(datadog = datadogWrapper)
@@ -30,7 +30,8 @@ class DdRum(
3030
* @param key The view unique key identifier.
3131
* @param name The view name.
3232
* @param context The additional context to send.
33-
* @param timestampMs The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
33+
* @param timestampMs The timestamp when the view started (in milliseconds).
34+
* If not provided, current timestamp will be used.
3435
*/
3536
@ReactMethod
3637
fun startView(

0 commit comments

Comments
 (0)