Skip to content

Commit

Permalink
Merge branch 'develop' into ncreated/RUMM-3374/fix-manual-trace-injec…
Browse files Browse the repository at this point in the history
…tion-impossible
  • Loading branch information
ncreated authored Aug 18, 2023
2 parents 599f27a + e21b0f5 commit 99dbb48
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- [BUGFIX] Manual trace injection APIs are not available in DatadogTrace. See [#1415][].
- [BUGFIX] Fix session replay uploads to AP1 site. See [#1418][].
- [BUGFIX] Allow instantiating custom instance of the SDK after default one. See [#1413][].
- [BUGFIX] Do not propagate attributes from Errors and LongTasks to Views.
- [IMPROVEMENT] Upgrade to PLCrashReporter 1.11.1.
Expand Down Expand Up @@ -498,6 +499,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[#1410]: https://github.com/DataDog/dd-sdk-ios/pull/1410
[#1413]: https://github.com/DataDog/dd-sdk-ios/pull/1413
[#1415]: https://github.com/DataDog/dd-sdk-ios/pull/1415
[#1418]: https://github.com/DataDog/dd-sdk-ios/pull/1418
[#1419]: https://github.com/DataDog/dd-sdk-ios/pull/1419
[@00fa9a]: https://github.com/00FA9A
[@britton-earnin]: https://github.com/Britton-Earnin
Expand Down
2 changes: 1 addition & 1 deletion DatadogRUM/Sources/Feature/RequestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal struct RequestBuilder: FeatureRequestBuilder {
return builder.uploadRequest(with: data)
}

func url(with context: DatadogContext) -> URL {
private func url(with context: DatadogContext) -> URL {
customIntakeURL ?? context.site.endpoint.appendingPathComponent("api/v2/rum")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,15 @@ internal struct RequestBuilder: FeatureRequestBuilder {
// error to let the core delete the batch:
let records = try events.map { try EnrichedRecordJSON(jsonObjectData: $0.data) }
let segment = try segmentBuilder.createSegmentJSON(from: records)
let url = customUploadURL ?? intakeURL(for: context.site)

return try createRequest(url: url, segment: segment, context: context)
return try createRequest(segment: segment, context: context)
}

private func intakeURL(for site: DatadogSite) -> URL {
// swiftlint:disable force_unwrapping
switch site {
case .us1:
return URL(string: "https://session-replay.browser-intake-datadoghq.com/api/v2/replay")!
case .us3:
return URL(string: "https://session-replay.browser-intake-us3-datadoghq.com/api/v2/replay")!
case .us5:
return URL(string: "https://session-replay.browser-intake-us5-datadoghq.com/api/v2/replay")!
case .eu1:
return URL(string: "https://session-replay.browser-intake-datadoghq.eu/api/v2/replay")!
case .ap1:
return URL(string: "https://session-replay.browser-intake-datadoghq.eu/api/v2/replay")!
case .us1_fed:
return URL(string: "https://session-replay.browser-intake-ddog-gov.com/api/v2/replay")!
}
// swiftlint:enable force_unwrapping
}

private func createRequest(url: URL, segment: SegmentJSON, context: DatadogContext) throws -> URLRequest {
private func createRequest(segment: SegmentJSON, context: DatadogContext) throws -> URLRequest {
var multipart = multipartBuilder

let builder = URLRequestBuilder(
url: url,
url: url(with: context),
queryItems: [],
headers: [
.contentTypeHeader(contentType: .multipartFormData(boundary: multipart.boundary.uuidString)),
Expand Down Expand Up @@ -97,4 +77,8 @@ internal struct RequestBuilder: FeatureRequestBuilder {
// Data is already compressed, so request building request w/o compression:
return builder.uploadRequest(with: multipart.data, compress: false)
}

private func url(with context: DatadogContext) -> URL {
customUploadURL ?? context.site.endpoint.appendingPathComponent("api/v2/replay")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class RequestBuilderTests: XCTestCase {
}

// Then
XCTAssertEqual(try url(for: .us1), "https://session-replay.browser-intake-datadoghq.com/api/v2/replay")
XCTAssertEqual(try url(for: .us3), "https://session-replay.browser-intake-us3-datadoghq.com/api/v2/replay")
XCTAssertEqual(try url(for: .us5), "https://session-replay.browser-intake-us5-datadoghq.com/api/v2/replay")
XCTAssertEqual(try url(for: .eu1), "https://session-replay.browser-intake-datadoghq.eu/api/v2/replay")
XCTAssertEqual(try url(for: .ap1), "https://session-replay.browser-intake-datadoghq.eu/api/v2/replay")
XCTAssertEqual(try url(for: .us1_fed), "https://session-replay.browser-intake-ddog-gov.com/api/v2/replay")
XCTAssertEqual(try url(for: .us1), "https://browser-intake-datadoghq.com/api/v2/replay")
XCTAssertEqual(try url(for: .us3), "https://browser-intake-us3-datadoghq.com/api/v2/replay")
XCTAssertEqual(try url(for: .us5), "https://browser-intake-us5-datadoghq.com/api/v2/replay")
XCTAssertEqual(try url(for: .eu1), "https://browser-intake-datadoghq.eu/api/v2/replay")
XCTAssertEqual(try url(for: .ap1), "https://browser-intake-ap1-datadoghq.com/api/v2/replay")
XCTAssertEqual(try url(for: .us1_fed), "https://browser-intake-ddog-gov.com/api/v2/replay")
}

func testItSetsCustomIntakeURL() {
Expand Down

0 comments on commit 99dbb48

Please sign in to comment.