Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Sep 12, 2024
2 parents 689676b + ef274d6 commit 321b2e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Next

- recording: missing import for url session extensions ([#194](https://github.com/PostHog/posthog-ios/pull/194))
- recording: network logs not counting the request transferSize but only the response transferSize ([#193](https://github.com/PostHog/posthog-ios/pull/193))

## 3.12.0 - 2024-09-12

Expand Down
7 changes: 6 additions & 1 deletion PostHog/Replay/URLSessionExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,14 @@
"name": request?.url?.absoluteString ?? (response?.url?.absoluteString ?? ""),
"initiatorType": "fetch",
"entryType": "resource",
"transferSize": response?.expectedContentLength ?? 0,
"timestamp": timestamp.toMillis()]

// the UI special case if the transferSize is 0 as coming from cache
let transferSize = Int64(request?.httpBody?.count ?? 0) + (response?.expectedContentLength ?? 0)
if transferSize > 0 {
requestsData["transferSize"] = transferSize
}

if let urlResponse = response as? HTTPURLResponse {
requestsData["responseStatus"] = urlResponse.statusCode
}
Expand Down
7 changes: 5 additions & 2 deletions PostHog/Replay/URLSessionInterceptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@
sample.httpMethod = request.httpMethod
sample.initiatorType = "fetch"
sample.duration = (date.toMillis() - sample.timeOrigin.toMillis())
if let response = task.response {
sample.decodedBodySize = response.expectedContentLength

// the UI special case if the transferSize is 0 as coming from cache
let transferSize = Int64(request.httpBody?.count ?? 0) + (task.response?.expectedContentLength ?? 0)
if transferSize > 0 {
sample.decodedBodySize = transferSize
}

self.finish(task: task, sample: sample)
Expand Down

0 comments on commit 321b2e9

Please sign in to comment.