Skip to content

Commit

Permalink
Enable setting custom version on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
louiszawadzki committed Sep 12, 2023
1 parent 317dedb commit 698bb93
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 8 additions & 3 deletions packages/core/ios/Sources/DdSdkImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down
11 changes: 5 additions & 6 deletions packages/core/ios/Tests/DdSdkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 698bb93

Please sign in to comment.