Skip to content

Commit 99dbb48

Browse files
authored
Merge branch 'develop' into ncreated/RUMM-3374/fix-manual-trace-injection-impossible
2 parents 599f27a + e21b0f5 commit 99dbb48

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Unreleased
22

33
- [BUGFIX] Manual trace injection APIs are not available in DatadogTrace. See [#1415][].
4+
- [BUGFIX] Fix session replay uploads to AP1 site. See [#1418][].
45
- [BUGFIX] Allow instantiating custom instance of the SDK after default one. See [#1413][].
56
- [BUGFIX] Do not propagate attributes from Errors and LongTasks to Views.
67
- [IMPROVEMENT] Upgrade to PLCrashReporter 1.11.1.
@@ -498,6 +499,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
498499
[#1410]: https://github.com/DataDog/dd-sdk-ios/pull/1410
499500
[#1413]: https://github.com/DataDog/dd-sdk-ios/pull/1413
500501
[#1415]: https://github.com/DataDog/dd-sdk-ios/pull/1415
502+
[#1418]: https://github.com/DataDog/dd-sdk-ios/pull/1418
501503
[#1419]: https://github.com/DataDog/dd-sdk-ios/pull/1419
502504
[@00fa9a]: https://github.com/00FA9A
503505
[@britton-earnin]: https://github.com/Britton-Earnin

DatadogRUM/Sources/Feature/RequestBuilder.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ internal struct RequestBuilder: FeatureRequestBuilder {
5656
return builder.uploadRequest(with: data)
5757
}
5858

59-
func url(with context: DatadogContext) -> URL {
59+
private func url(with context: DatadogContext) -> URL {
6060
customIntakeURL ?? context.site.endpoint.appendingPathComponent("api/v2/rum")
6161
}
6262
}

DatadogSessionReplay/Sources/Feature/RequestBuilder/RequestBuilder.swift

+7-23
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,15 @@ internal struct RequestBuilder: FeatureRequestBuilder {
3030
// error to let the core delete the batch:
3131
let records = try events.map { try EnrichedRecordJSON(jsonObjectData: $0.data) }
3232
let segment = try segmentBuilder.createSegmentJSON(from: records)
33-
let url = customUploadURL ?? intakeURL(for: context.site)
3433

35-
return try createRequest(url: url, segment: segment, context: context)
34+
return try createRequest(segment: segment, context: context)
3635
}
3736

38-
private func intakeURL(for site: DatadogSite) -> URL {
39-
// swiftlint:disable force_unwrapping
40-
switch site {
41-
case .us1:
42-
return URL(string: "https://session-replay.browser-intake-datadoghq.com/api/v2/replay")!
43-
case .us3:
44-
return URL(string: "https://session-replay.browser-intake-us3-datadoghq.com/api/v2/replay")!
45-
case .us5:
46-
return URL(string: "https://session-replay.browser-intake-us5-datadoghq.com/api/v2/replay")!
47-
case .eu1:
48-
return URL(string: "https://session-replay.browser-intake-datadoghq.eu/api/v2/replay")!
49-
case .ap1:
50-
return URL(string: "https://session-replay.browser-intake-datadoghq.eu/api/v2/replay")!
51-
case .us1_fed:
52-
return URL(string: "https://session-replay.browser-intake-ddog-gov.com/api/v2/replay")!
53-
}
54-
// swiftlint:enable force_unwrapping
55-
}
56-
57-
private func createRequest(url: URL, segment: SegmentJSON, context: DatadogContext) throws -> URLRequest {
37+
private func createRequest(segment: SegmentJSON, context: DatadogContext) throws -> URLRequest {
5838
var multipart = multipartBuilder
5939

6040
let builder = URLRequestBuilder(
61-
url: url,
41+
url: url(with: context),
6242
queryItems: [],
6343
headers: [
6444
.contentTypeHeader(contentType: .multipartFormData(boundary: multipart.boundary.uuidString)),
@@ -97,4 +77,8 @@ internal struct RequestBuilder: FeatureRequestBuilder {
9777
// Data is already compressed, so request building request w/o compression:
9878
return builder.uploadRequest(with: multipart.data, compress: false)
9979
}
80+
81+
private func url(with context: DatadogContext) -> URL {
82+
customUploadURL ?? context.site.endpoint.appendingPathComponent("api/v2/replay")
83+
}
10084
}

DatadogSessionReplay/Tests/Feature/RequestBuilder/RequestBuilderTests.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class RequestBuilderTests: XCTestCase {
4242
}
4343

4444
// Then
45-
XCTAssertEqual(try url(for: .us1), "https://session-replay.browser-intake-datadoghq.com/api/v2/replay")
46-
XCTAssertEqual(try url(for: .us3), "https://session-replay.browser-intake-us3-datadoghq.com/api/v2/replay")
47-
XCTAssertEqual(try url(for: .us5), "https://session-replay.browser-intake-us5-datadoghq.com/api/v2/replay")
48-
XCTAssertEqual(try url(for: .eu1), "https://session-replay.browser-intake-datadoghq.eu/api/v2/replay")
49-
XCTAssertEqual(try url(for: .ap1), "https://session-replay.browser-intake-datadoghq.eu/api/v2/replay")
50-
XCTAssertEqual(try url(for: .us1_fed), "https://session-replay.browser-intake-ddog-gov.com/api/v2/replay")
45+
XCTAssertEqual(try url(for: .us1), "https://browser-intake-datadoghq.com/api/v2/replay")
46+
XCTAssertEqual(try url(for: .us3), "https://browser-intake-us3-datadoghq.com/api/v2/replay")
47+
XCTAssertEqual(try url(for: .us5), "https://browser-intake-us5-datadoghq.com/api/v2/replay")
48+
XCTAssertEqual(try url(for: .eu1), "https://browser-intake-datadoghq.eu/api/v2/replay")
49+
XCTAssertEqual(try url(for: .ap1), "https://browser-intake-ap1-datadoghq.com/api/v2/replay")
50+
XCTAssertEqual(try url(for: .us1_fed), "https://browser-intake-ddog-gov.com/api/v2/replay")
5151
}
5252

5353
func testItSetsCustomIntakeURL() {

0 commit comments

Comments
 (0)