Skip to content

[RUM-11711]: Extend resource handling to support multiple MIME types#2914

Merged
cdn34dd merged 1 commit into
release/2.26.0from
carlosnogueira/RUM-11711/session-replay-svg-support-android
Oct 8, 2025
Merged

[RUM-11711]: Extend resource handling to support multiple MIME types#2914
cdn34dd merged 1 commit into
release/2.26.0from
carlosnogueira/RUM-11711/session-replay-svg-support-android

Conversation

@cdn34dd

@cdn34dd cdn34dd commented Oct 6, 2025

Copy link
Copy Markdown
Contributor

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)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • 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)

@cdn34dd
cdn34dd requested review from a team as code owners October 6, 2025 12:19
val data: ByteArray,
val metadata: ByteArray = EMPTY_BYTE_ARRAY
val metadata: ByteArray = EMPTY_BYTE_ARRAY,
val mimeType: String? = 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 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.

@cdn34dd
cdn34dd force-pushed the carlosnogueira/RUM-11711/session-replay-svg-support-android branch from 549eefc to 0a3966b Compare October 6, 2025 13:18
* @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)

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.

it seems this method is not used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's used by the react-native sdk

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.

Can you please give an short snippet of how these changes are supposed to be used at the RN SDK?

@cdn34dd cdn34dd Oct 6, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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"
)

@cdn34dd
cdn34dd force-pushed the carlosnogueira/RUM-11711/session-replay-svg-support-android branch from 0a3966b to b2004d1 Compare October 6, 2025 15:15
@codecov-commenter

codecov-commenter commented Oct 6, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.86207% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.88%. Comparing base (bffec75) to head (2bc303f).
⚠️ Report is 8 commits behind head on release/2.26.0.

Files with missing lines Patch % Lines
...nreplay/internal/net/ResourceRequestBodyFactory.kt 80.00% 1 Missing and 1 partial ⚠️
...ssionreplay/internal/processor/EnrichedResource.kt 50.00% 1 Missing and 1 partial ⚠️
...oid/sessionreplay/SessionReplayInternalCallback.kt 0.00% 1 Missing ⚠️
...essionreplay/SessionReplayInternalResourceQueue.kt 0.00% 1 Missing ⚠️
...sionreplay/internal/processor/ResourceQueueImpl.kt 66.67% 1 Missing ⚠️
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     
Files with missing lines Coverage Δ
...d/sessionreplay/internal/async/DataQueueHandler.kt 100.00% <100.00%> (ø)
...ssionreplay/internal/async/NoopDataQueueHandler.kt 0.00% <ø> (ø)
...nreplay/internal/async/RecordedDataQueueHandler.kt 95.29% <100.00%> (+0.06%) ⬆️
...ay/internal/async/ResourceRecordedDataQueueItem.kt 100.00% <100.00%> (ø)
...ndroid/sessionreplay/internal/net/ResourceEvent.kt 85.71% <100.00%> (ø)
...replay/internal/processor/RecordedDataProcessor.kt 97.67% <100.00%> (+0.03%) ⬆️
...nreplay/internal/recorder/SessionReplayRecorder.kt 95.00% <100.00%> (+0.04%) ⬆️
...oid/sessionreplay/SessionReplayInternalCallback.kt 0.00% <0.00%> (ø)
...essionreplay/SessionReplayInternalResourceQueue.kt 0.00% <0.00%> (ø)
...sionreplay/internal/processor/ResourceQueueImpl.kt 66.67% <66.67%> (ø)
... and 2 more

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

0xnm
0xnm previously approved these changes Oct 7, 2025

@jonathanmos jonathanmos left a comment

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.

This looks good overall, but isn't it missing test coverage?

ambushwork
ambushwork previously approved these changes Oct 8, 2025
- Add optional mimeType parameter to resource handling APIs to support
more image formats like SVG. Maintains backward compatibility with
default value for existing resources.
@cdn34dd
cdn34dd dismissed stale reviews from ambushwork and 0xnm via 2bc303f October 8, 2025 14:37
@cdn34dd
cdn34dd force-pushed the carlosnogueira/RUM-11711/session-replay-svg-support-android branch from b2004d1 to 2bc303f Compare October 8, 2025 14:37
@cdn34dd
cdn34dd merged commit 4972cdc into release/2.26.0 Oct 8, 2025
25 of 26 checks passed
@cdn34dd
cdn34dd deleted the carlosnogueira/RUM-11711/session-replay-svg-support-android branch October 8, 2025 15:44
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.

5 participants