@@ -175,36 +175,44 @@ enum NetworkBodyWarning: String {
175175
176176 // MARK: - ObjC Setters
177177
178- /// Sets request details from raw components.
178+ /// Sets request details from raw body data.
179+ ///
180+ /// Parses the body data based on content type (JSON, form-urlencoded, text)
181+ /// and applies size limits and truncation warnings automatically.
179182 ///
180183 /// - Parameters:
181184 /// - size: Request body size in bytes, or nil if unknown.
182- /// - body: Pre-parsed body content (dictionary, array, or string), or nil if not captured.
185+ /// - bodyData: Raw body bytes, or nil if body capture is disabled or unavailable.
186+ /// - contentType: MIME content type for body parsing (e.g. "application/json").
183187 /// - allHeaders: All headers from the request (e.g. from `NSURLRequest.allHTTPHeaderFields`).
184188 /// - configuredHeaders: Header names to extract, matched case-insensitively.
185189 @objc
186- public func setRequest( size: NSNumber ? , body : Any ? , allHeaders: [ String : Any ] ? , configuredHeaders: [ String ] ? ) {
190+ public func setRequest( size: NSNumber ? , bodyData : Data ? , contentType : String ? , allHeaders: [ String : Any ] ? , configuredHeaders: [ String ] ? ) {
187191 self . request = Detail (
188192 size: size,
189- body: body . map { Body ( content : $0) } ,
193+ body: bodyData . flatMap { Body ( data : $0, contentType : contentType ) } ,
190194 headers: SentryReplayNetworkDetails . extractHeaders ( from: allHeaders, matching: configuredHeaders)
191195 )
192196 }
193197
194- /// Sets response details from raw components.
198+ /// Sets response details from raw body data.
199+ ///
200+ /// Parses the body data based on content type (JSON, form-urlencoded, text)
201+ /// and applies size limits and truncation warnings automatically.
195202 ///
196203 /// - Parameters:
197204 /// - statusCode: HTTP status code.
198205 /// - size: Response body size in bytes, or nil if unknown.
199- /// - body: Pre-parsed body content (dictionary, array, or string), or nil if not captured.
206+ /// - bodyData: Raw body bytes, or nil if body capture is disabled or unavailable.
207+ /// - contentType: MIME content type for body parsing (e.g. "application/json").
200208 /// - allHeaders: All headers from the response (e.g. from `NSHTTPURLResponse.allHeaderFields`).
201209 /// - configuredHeaders: Header names to extract, matched case-insensitively.
202210 @objc
203- public func setResponse( statusCode: Int , size: NSNumber ? , body : Any ? , allHeaders: [ String : Any ] ? , configuredHeaders: [ String ] ? ) {
211+ public func setResponse( statusCode: Int , size: NSNumber ? , bodyData : Data ? , contentType : String ? , allHeaders: [ String : Any ] ? , configuredHeaders: [ String ] ? ) {
204212 self . statusCode = NSNumber ( value: statusCode)
205213 self . response = Detail (
206214 size: size,
207- body: body . map { Body ( content : $0) } ,
215+ body: bodyData . flatMap { Body ( data : $0, contentType : contentType ) } ,
208216 headers: SentryReplayNetworkDetails . extractHeaders ( from: allHeaders, matching: configuredHeaders)
209217 )
210218 }
0 commit comments