[RUM-11711]: Extend resource handling to support multiple MIME types#2914
Conversation
| val data: ByteArray, | ||
| val metadata: ByteArray = EMPTY_BYTE_ARRAY | ||
| val metadata: ByteArray = EMPTY_BYTE_ARRAY, | ||
| val mimeType: String? = null |
There was a problem hiding this comment.
we need to revert this change, because this class is holding the data which is supposed to be written and is generic for all features (feature-agnostic).
mimeType is not going to be written as per this PR and currently serves only for the SR needs, so I suppose that the change should be local to the SR module only.
549eefc to
0a3966b
Compare
| * @param resourceData The raw content of the resource. | ||
| * @param mimeType Optional MIME type describing the resource data (e.g. `"image/png"` or `"image/svg+xml"`). | ||
| */ | ||
| fun addResourceItem(identifier: String, resourceData: ByteArray, mimeType: String? = null) |
There was a problem hiding this comment.
It's used by the react-native sdk
There was a problem hiding this comment.
Can you please give an short snippet of how these changes are supposed to be used at the RN SDK?
There was a problem hiding this comment.
The idea is to be able to access the resouceQueue, so we can from the react-native side, call addResourceItem, with SVG content we extracted and transformed from the Users' JSX code.
class ReactNativeInternalCallback(
private val reactContext: ReactContext
) : SessionReplayInternalCallback {
private var resourceQueue: SessionReplayInternalResourceQueue? = null
(....)
override fun addResourceItem(identifier: String, resourceData: ByteArray, mimeType: String?) {
resourceQueue?.addResourceItem(identifier, resourceData, mimeType)
}
override fun setResourceQueue(resourceQueue: SessionReplayInternalResourceQueue) {
this.resourceQueue = resourceQueue
}
}
------
val internalCallback = ReactNativeInternalCallback(reactContext)
val configuration = SessionReplayConfiguration.Builder(replaySampleRate.toFloat())
(....)
.addExtensionSupport(ReactNativeSessionReplayExtensionSupport(textViewUtils, internalCallback))
.let {
_SessionReplayInternalProxy(it).setInternalCallback(internalCallback)
}
sessionReplayProvider().enable(configuration.build(), sdkCore)
------
// custom mapper
internalCallback.addResourceItem(
id,
content,
mimeType // "image/svg+xml"
)
0a3966b to
b2004d1
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release/2.26.0 #2914 +/- ##
==================================================
- Coverage 70.04% 69.88% -0.16%
==================================================
Files 846 850 +4
Lines 31492 31522 +30
Branches 5291 5293 +2
==================================================
- Hits 22056 22028 -28
- Misses 7973 8009 +36
- Partials 1463 1485 +22
🚀 New features to boost your workflow:
|
jonathanmos
left a comment
There was a problem hiding this comment.
This looks good overall, but isn't it missing test coverage?
- Add optional mimeType parameter to resource handling APIs to support more image formats like SVG. Maintains backward compatibility with default value for existing resources.
b2004d1 to
2bc303f
Compare
What does this PR do?
Adds optional mimeType parameter to resource handling APIs to support more image formats like SVG. Maintains backward compatibility with default value for existing resources.
Motivation
Allow React Native clients to handle SVG resources.
Review checklist (to be filled by reviewers)