diff --git a/packages/core/ios/Sources/DdSdkImplementation.swift b/packages/core/ios/Sources/DdSdkImplementation.swift index 92fbaa50c..cf313168b 100644 --- a/packages/core/ios/Sources/DdSdkImplementation.swift +++ b/packages/core/ios/Sources/DdSdkImplementation.swift @@ -171,8 +171,7 @@ public class DdSdkImplementation: NSObject { ) } - func buildSDKConfiguration(configuration: DdSdkConfiguration) -> Datadog.Configuration { - // TODO: Add version to config once this is released on iOS + func buildSDKConfiguration(configuration: DdSdkConfiguration, defaultAppVersion: String = getDefaultAppVersion()) -> Datadog.Configuration { var config = Datadog.Configuration( clientToken: configuration.clientToken, env: configuration.env, @@ -182,7 +181,13 @@ public class DdSdkImplementation: NSObject { uploadFrequency: configuration.uploadFrequency, proxyConfiguration: buildProxyConfiguration(config: configuration.additionalConfig) ) - if let additionalConfiguration = configuration.additionalConfig as? [String: Any] { + + if var additionalConfiguration = configuration.additionalConfig as? [String: Any] { + if let versionSuffix = additionalConfiguration[InternalConfigurationAttributes.versionSuffix] as? String { + let datadogVersion = defaultAppVersion + versionSuffix + additionalConfiguration[CrossPlatformAttributes.version] = datadogVersion + } + config._internal_mutation { $0.additionalConfiguration = additionalConfiguration } diff --git a/packages/core/ios/Tests/DdSdkTests.swift b/packages/core/ios/Tests/DdSdkTests.swift index 0dc757a60..1144eff8b 100644 --- a/packages/core/ios/Tests/DdSdkTests.swift +++ b/packages/core/ios/Tests/DdSdkTests.swift @@ -296,12 +296,11 @@ internal class DdSdkTests: XCTestCase { } func testBuildConfigurationWithVersionSuffix() { - // TODO: Re-enable this test when function is supported -// let configuration: DdSdkConfiguration = .mockAny(additionalConfig: ["_dd.version_suffix": ":codepush-3"]) -// -// let ddConfig = DdSdkImplementation().buildRUMConfiguration(configuration: configuration, defaultAppVersion: "1.2.3") -// -// XCTAssertEqual(ddConfig.additionalConfiguration["_dd.version"] as! String, "1.2.3:codepush-3") + let configuration: DdSdkConfiguration = .mockAny(additionalConfig: ["_dd.version_suffix": ":codepush-3"]) + + let ddConfig = DdSdkImplementation().buildSDKConfiguration(configuration: configuration, defaultAppVersion: "1.2.3") + + XCTAssertEqual(ddConfig.additionalConfiguration["_dd.version"] as! String, "1.2.3:codepush-3") } func testBuildConfigurationFrustrationTrackingEnabledByDefault() {