[RUM 10972] Expose to JS method to send telemetry logs with custom attributes#944
Merged
cdn34dd merged 1 commit intoJul 23, 2025
Conversation
c2925c3 to
3ba0f0c
Compare
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) |
Member
There was a problem hiding this comment.
We already have utils for converting ReadableMap and ReadableArray.
Here:
Comment on lines
+101
to
+102
|
|
||
|
|
Member
There was a problem hiding this comment.
nit
Suggested change
3ba0f0c to
492032b
Compare
marco-saia-datadog
approved these changes
Jul 23, 2025
492032b to
3f6d1d2
Compare
This was referenced Jul 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)