Skip to content

[RUM 10972] Expose to JS method to send telemetry logs with custom attributes#944

Merged
cdn34dd merged 1 commit into
developfrom
carlosnogueira/RUM-10972/rn-telemetry-logs-with-attributes
Jul 23, 2025
Merged

[RUM 10972] Expose to JS method to send telemetry logs with custom attributes#944
cdn34dd merged 1 commit into
developfrom
carlosnogueira/RUM-10972/rn-telemetry-logs-with-attributes

Conversation

@cdn34dd

@cdn34dd cdn34dd commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Exposes method similar to to the ones found on the native Android and iOS sdks that will allow for telemetry events with custom attributes to be more easily send from React Native.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@cdn34dd cdn34dd requested a review from a team as a code owner July 22, 2025 16:57
@cdn34dd cdn34dd force-pushed the carlosnogueira/RUM-10972/rn-telemetry-logs-with-attributes branch from c2925c3 to 3ba0f0c Compare July 23, 2025 07:48
Comment on lines +7 to +43
class Utils {
/**
* Convert React Native's ReadableMap to Map.
* @param readableMap ReadableMap
*/
fun convertReadableMapToMap(readableMap: ReadableMap): Map<String, Any?> {
val result = mutableMapOf<String, Any?>()

val iterator = readableMap.keySetIterator()
while (iterator.hasNextKey()) {
val key = iterator.nextKey()
when (readableMap.getType(key)) {
ReadableType.Null -> result[key] = null
ReadableType.Boolean -> result[key] = readableMap.getBoolean(key)
ReadableType.Number -> result[key] = readableMap.getDouble(key)
ReadableType.String -> result[key] = readableMap.getString(key)
ReadableType.Map -> result[key] = readableMap.getMap(key)
?.let { convertReadableMapToMap(it) }
ReadableType.Array -> result[key] = readableMap.getArray(key)
?.let { convertReadableArrayToList(it) }
}
}

return result
}


/**
* Convert React Native's ReadableArray to List.
* @param readableArray ReadableArray
*/
fun convertReadableArrayToList(readableArray: ReadableArray): List<Any?> {
val result = mutableListOf<Any?>()

for (i in 0 until readableArray.size()) {
when (readableArray.getType(i)) {
ReadableType.Null -> result.add(null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have utils for converting ReadableMap and ReadableArray.

Here:

Comment on lines +101 to +102


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change

@cdn34dd cdn34dd force-pushed the carlosnogueira/RUM-10972/rn-telemetry-logs-with-attributes branch from 3ba0f0c to 492032b Compare July 23, 2025 10:38
@cdn34dd cdn34dd force-pushed the carlosnogueira/RUM-10972/rn-telemetry-logs-with-attributes branch from 492032b to 3f6d1d2 Compare July 23, 2025 11:51
@cdn34dd cdn34dd merged commit 4a975f0 into develop Jul 23, 2025
3 of 10 checks passed
@cdn34dd cdn34dd deleted the carlosnogueira/RUM-10972/rn-telemetry-logs-with-attributes branch July 23, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants