Skip to content

Commit

Permalink
Harmonize path on Android and iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
louiszawadzki committed Jan 29, 2024
1 parent 0afee88 commit 77ab36b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
12 changes: 9 additions & 3 deletions packages/core/ios/Sources/DdSdkImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ public class DdSdkImplementation: NSObject {

var customRUMEndpointURL: URL? = nil
if let customRUMEndpoint = configuration.customEndpoints?.rum as? NSString {
customRUMEndpointURL = URL(string: customRUMEndpoint as String)
if (customRUMEndpoint != "") {
customRUMEndpointURL = URL(string: "\(customRUMEndpoint)/api/v2/rum" as String)
}
}

return RUM.Configuration(
Expand Down Expand Up @@ -272,7 +274,9 @@ public class DdSdkImplementation: NSObject {
func buildLogsConfiguration(configuration: DdSdkConfiguration) -> Logs.Configuration {
var customLogsEndpointURL: URL? = nil
if let customLogsEndpoint = configuration.customEndpoints?.logs as? NSString {
customLogsEndpointURL = URL(string: customLogsEndpoint as String)
if (customLogsEndpoint != "") {
customLogsEndpointURL = URL(string: "\(customLogsEndpoint)/api/v2/logs" as String)
}
}

return Logs.Configuration(customEndpoint: customLogsEndpointURL)
Expand All @@ -282,7 +286,9 @@ public class DdSdkImplementation: NSObject {
func buildTraceConfiguration(configuration: DdSdkConfiguration) -> Trace.Configuration {
var customTraceEndpointURL: URL? = nil
if let customTraceEndpoint = configuration.customEndpoints?.trace as? NSString {
customTraceEndpointURL = URL(string: customTraceEndpoint as String)
if (customTraceEndpoint != "") {
customTraceEndpointURL = URL(string: "\(customTraceEndpoint)/api/v2/spans" as String)
}
}

return Trace.Configuration(customEndpoint: customTraceEndpointURL)
Expand Down
6 changes: 3 additions & 3 deletions packages/core/ios/Tests/DdSdkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -831,15 +831,15 @@ internal class DdSdkTests: XCTestCase {

let logsFeature = try XCTUnwrap(CoreRegistry.default as? DatadogCore).get(feature: LogsFeature.self)
let customLogsEndpoint = try XCTUnwrap(logsFeature?.requestBuilder as? DatadogLogs.RequestBuilder).customIntakeURL
XCTAssertEqual(customLogsEndpoint?.absoluteString, "https://logs.example.com")
XCTAssertEqual(customLogsEndpoint?.absoluteString, "https://logs.example.com/api/v2/logs")

let rumFeature = try XCTUnwrap(CoreRegistry.default as? DatadogCore).get(feature: RUMFeature.self)
let customRumEndpoint = try XCTUnwrap(rumFeature?.requestBuilder as? DatadogRUM.RequestBuilder).customIntakeURL
XCTAssertEqual(customRumEndpoint?.absoluteString, "https://rum.example.com")
XCTAssertEqual(customRumEndpoint?.absoluteString, "https://rum.example.com/api/v2/rum")

let traceFeature = try XCTUnwrap(CoreRegistry.default as? DatadogCore).get(feature: TraceFeature.self)
let customTraceEndpoint = try XCTUnwrap(traceFeature?.requestBuilder as? TracingRequestBuilder).customIntakeURL
XCTAssertEqual(customTraceEndpoint?.absoluteString, "https://trace.example.com")
XCTAssertEqual(customTraceEndpoint?.absoluteString, "https://trace.example.com/api/v2/spans")

Datadog.internalFlushAndDeinitialize()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ public class DdSessionReplayImplementation: NSObject {

@objc
public func enable(replaySampleRate: Double, defaultPrivacyLevel: String, customEndpoint: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
var customEndpointURL: URL? = nil
if (customEndpoint != "") {
customEndpointURL = URL(string: "\(customEndpoint)/api/v2/replay" as String)
}
var sessionReplayConfiguration = SessionReplay.Configuration(
replaySampleRate: Float(replaySampleRate),
defaultPrivacyLevel: buildPrivacyLevel(privacyLevel: defaultPrivacyLevel as NSString),
customEndpoint: URL(string: customEndpoint)
customEndpoint: customEndpointURL
)

sessionReplayConfiguration.setAdditionalNodeRecorders([RCTTextViewRecorder(uiManager: self.uiManager)])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal class DdSessionReplayTests: XCTestCase {
DdSessionReplayImplementation(sessionReplayProvider:{ sessionReplayMock }, uiManager: uiManagerMock)
.enable(replaySampleRate: 100, defaultPrivacyLevel: "MASK", customEndpoint: "https://session-replay.example.com", resolve: mockResolve, reject: mockReject)

XCTAssertEqual(sessionReplayMock.calledMethods.first, .enable(replaySampleRate: 100.0, privacyLevel: .mask, customEndpoint: URL(string: "https://session-replay.example.com")))
XCTAssertEqual(sessionReplayMock.calledMethods.first, .enable(replaySampleRate: 100.0, privacyLevel: .mask, customEndpoint: URL(string: "https://session-replay.example.com/api/v2/replay")))
}
}

Expand Down

0 comments on commit 77ab36b

Please sign in to comment.