@@ -187,36 +187,44 @@ enum NetworkBodyWarning: String {
187187
188188 // MARK: - ObjC Setters
189189
190- /// Sets request details from raw components.
190+ /// Sets request details from raw body data.
191+ ///
192+ /// Parses the body data based on content type (JSON, form-urlencoded, text)
193+ /// and applies size limits and truncation warnings automatically.
191194 ///
192195 /// - Parameters:
193196 /// - size: Request body size in bytes, or nil if unknown.
194- /// - body: Pre-parsed body content (dictionary, array, or string), or nil if not captured.
197+ /// - bodyData: Raw body bytes, or nil if body capture is disabled or unavailable.
198+ /// - contentType: MIME content type for body parsing (e.g. "application/json").
195199 /// - allHeaders: All headers from the request (e.g. from `NSURLRequest.allHTTPHeaderFields`).
196200 /// - configuredHeaders: Header names to extract, matched case-insensitively.
197201 @objc
198- public func setRequest( size: NSNumber ? , body : Any ? , allHeaders: [ String : Any ] ? , configuredHeaders: [ String ] ? ) {
202+ public func setRequest( size: NSNumber ? , bodyData : Data ? , contentType : String ? , allHeaders: [ String : Any ] ? , configuredHeaders: [ String ] ? ) {
199203 self . request = Detail (
200204 size: size,
201- body: body . map { Body ( content : $0) } ,
205+ body: bodyData . flatMap { Body ( data : $0, contentType : contentType ) } ,
202206 headers: SentryReplayNetworkDetails . extractHeaders ( from: allHeaders, matching: configuredHeaders)
203207 )
204208 }
205209
206- /// Sets response details from raw components.
210+ /// Sets response details from raw body data.
211+ ///
212+ /// Parses the body data based on content type (JSON, form-urlencoded, text)
213+ /// and applies size limits and truncation warnings automatically.
207214 ///
208215 /// - Parameters:
209216 /// - statusCode: HTTP status code.
210217 /// - size: Response body size in bytes, or nil if unknown.
211- /// - body: Pre-parsed body content (dictionary, array, or string), or nil if not captured.
218+ /// - bodyData: Raw body bytes, or nil if body capture is disabled or unavailable.
219+ /// - contentType: MIME content type for body parsing (e.g. "application/json").
212220 /// - allHeaders: All headers from the response (e.g. from `NSHTTPURLResponse.allHeaderFields`).
213221 /// - configuredHeaders: Header names to extract, matched case-insensitively.
214222 @objc
215- public func setResponse( statusCode: Int , size: NSNumber ? , body : Any ? , allHeaders: [ String : Any ] ? , configuredHeaders: [ String ] ? ) {
223+ public func setResponse( statusCode: Int , size: NSNumber ? , bodyData : Data ? , contentType : String ? , allHeaders: [ String : Any ] ? , configuredHeaders: [ String ] ? ) {
216224 self . statusCode = NSNumber ( value: statusCode)
217225 self . response = Detail (
218226 size: size,
219- body: body . map { Body ( content : $0) } ,
227+ body: bodyData . flatMap { Body ( data : $0, contentType : contentType ) } ,
220228 headers: SentryReplayNetworkDetails . extractHeaders ( from: allHeaders, matching: configuredHeaders)
221229 )
222230 }
0 commit comments