From 24d844be9a92597bccdfbdf233ca4c25491b2254 Mon Sep 17 00:00:00 2001 From: Peter Csajtai Date: Fri, 29 Jul 2022 16:39:15 +0200 Subject: [PATCH] Hotfix for user handling in new APIs --- ConfigCat.podspec | 2 +- ConfigCat.xcconfig | 2 +- README.md | 2 +- Sources/ConfigCat/Extensions.swift | 10 +++++----- Sources/ConfigCat/Utils.swift | 2 +- Tests/ConfigCatTests/AsyncAwaitTests.swift | 7 ++++++- Tests/ConfigCatTests/SyncTests.swift | 7 ++++++- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ConfigCat.podspec b/ConfigCat.podspec index 4f9318a..0a8440c 100755 --- a/ConfigCat.podspec +++ b/ConfigCat.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |spec| spec.name = "ConfigCat" - spec.version = "9.0.0" + spec.version = "9.0.1" spec.summary = "ConfigCat Swift SDK" spec.swift_version = "4.2" diff --git a/ConfigCat.xcconfig b/ConfigCat.xcconfig index 69ed16b..82307be 100644 --- a/ConfigCat.xcconfig +++ b/ConfigCat.xcconfig @@ -47,4 +47,4 @@ SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator watchos watchsimulator app SWIFT_VERSION = 4.2 // ConfigCat SDK version -MARKETING_VERSION = 9.0.0 +MARKETING_VERSION = 9.0.1 diff --git a/README.md b/README.md index b515571..db38a84 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ If you want to use ConfigCat in a [SwiftPM](https://swift.org/package-manager/) ``` swift dependencies: [ - .package(url: "https://github.com/configcat/swift-sdk", from: "9.0.0") + .package(url: "https://github.com/configcat/swift-sdk", from: "9.0.1") ] ``` diff --git a/Sources/ConfigCat/Extensions.swift b/Sources/ConfigCat/Extensions.swift index 8dcedf5..8c8aa13 100644 --- a/Sources/ConfigCat/Extensions.swift +++ b/Sources/ConfigCat/Extensions.swift @@ -25,7 +25,7 @@ extension ConfigCatClient { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func getValue(for key: String, defaultValue: Value, user: ConfigCatUser? = nil) async -> Value { await withCheckedContinuation { continuation in - getValue(for: key, defaultValue: defaultValue) { value in + getValue(for: key, defaultValue: defaultValue, user: user) { value in continuation.resume(returning: value) } } @@ -43,7 +43,7 @@ extension ConfigCatClient { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func getVariationId(for key: String, defaultVariationId: String?, user: ConfigCatUser? = nil) async -> String? { await withCheckedContinuation { continuation in - getVariationId(for: key, defaultVariationId: defaultVariationId) { variationId in + getVariationId(for: key, defaultVariationId: defaultVariationId, user: user) { variationId in continuation.resume(returning: variationId) } } @@ -52,7 +52,7 @@ extension ConfigCatClient { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func getAllVariationIds(user: ConfigCatUser? = nil) async -> [String] { await withCheckedContinuation { continuation in - getAllVariationIds { variationIds in + getAllVariationIds(user: user) { variationIds in continuation.resume(returning: variationIds) } } @@ -91,7 +91,7 @@ extension ConfigCatClient { public func getValueSync(for key: String, defaultValue: Value, user: ConfigCatUser? = nil) -> Value { let semaphore = DispatchSemaphore(value: 0) var result: Value? - getValue(for: key, defaultValue: defaultValue) { value in + getValue(for: key, defaultValue: defaultValue, user: user) { value in result = value semaphore.signal() } @@ -113,7 +113,7 @@ extension ConfigCatClient { @objc public func getVariationIdSync(for key: String, defaultVariationId: String?, user: ConfigCatUser? = nil) -> String? { let semaphore = DispatchSemaphore(value: 0) var result: String? - getVariationId(for: key, defaultVariationId: defaultVariationId) { variationId in + getVariationId(for: key, defaultVariationId: defaultVariationId, user: user) { variationId in result = variationId semaphore.signal() } diff --git a/Sources/ConfigCat/Utils.swift b/Sources/ConfigCat/Utils.swift index 59563cb..670a5a2 100644 --- a/Sources/ConfigCat/Utils.swift +++ b/Sources/ConfigCat/Utils.swift @@ -42,7 +42,7 @@ extension Date { } class Constants { - static let version: String = "9.0.0" + static let version: String = "9.0.1" static let configJsonName: String = "config_v5" static let globalBaseUrl: String = "https://cdn-global.configcat.com" static let euOnlyBaseUrl: String = "https://cdn-eu.configcat.com" diff --git a/Tests/ConfigCatTests/AsyncAwaitTests.swift b/Tests/ConfigCatTests/AsyncAwaitTests.swift index 525747b..1c6a307 100644 --- a/Tests/ConfigCatTests/AsyncAwaitTests.swift +++ b/Tests/ConfigCatTests/AsyncAwaitTests.swift @@ -3,7 +3,8 @@ import XCTest class AsyncAwaitTests: XCTestCase { #if compiler(>=5.5) && canImport(_Concurrency) - let testJsonMultiple = #"{ "f": { "key1": { "v": true, "i": "fakeId1", "p": [], "r": [] }, "key2": { "v": false, "i": "fakeId2", "p": [], "r": [] } } }"# + let testJsonMultiple = #"{ "f": { "key1": { "v": true, "i": "fakeId1", "p": [], "r": [] }, "key2": { "v": false, "i": "fakeId2", "p": [], "r": [{"o":1,"a":"Email","t":2,"c":"@example.com","v":true,"i":"9f21c24c"}] } } }"# + let user = ConfigCatUser(identifier: "id", email: "test@example.com") override func setUp() { super.setUp() @@ -16,6 +17,8 @@ class AsyncAwaitTests: XCTestCase { let client = ConfigCatClient(sdkKey: "test", refreshMode: PollingModes.autoPoll(), session: MockHTTP.session()) let value = await client.getValue(for: "key1", defaultValue: false) XCTAssertTrue(value) + let value2 = await client.getValue(for: "key2", defaultValue: false, user: user) + XCTAssertTrue(value2) } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @@ -23,6 +26,8 @@ class AsyncAwaitTests: XCTestCase { let client = ConfigCatClient(sdkKey: "test", refreshMode: PollingModes.autoPoll(), session: MockHTTP.session()) let id = await client.getVariationId(for: "key1", defaultVariationId: "") XCTAssertEqual("fakeId1", id) + let id2 = await client.getVariationId(for: "key2", defaultVariationId: "", user: user) + XCTAssertEqual("9f21c24c", id2) } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) diff --git a/Tests/ConfigCatTests/SyncTests.swift b/Tests/ConfigCatTests/SyncTests.swift index ec852aa..ab50a32 100644 --- a/Tests/ConfigCatTests/SyncTests.swift +++ b/Tests/ConfigCatTests/SyncTests.swift @@ -2,7 +2,8 @@ import XCTest @testable import ConfigCat class SyncTests: XCTestCase { - let testJsonMultiple = #"{ "f": { "key1": { "v": true, "i": "fakeId1", "p": [], "r": [] }, "key2": { "v": false, "i": "fakeId2", "p": [], "r": [] } } }"# + let testJsonMultiple = #"{ "f": { "key1": { "v": true, "i": "fakeId1", "p": [], "r": [] }, "key2": { "v": false, "i": "fakeId2", "p": [], "r": [{"o":1,"a":"Email","t":2,"c":"@example.com","v":true,"i":"9f21c24c"}] } } }"# + let user = ConfigCatUser(identifier: "id", email: "test@example.com") override func setUp() { super.setUp() @@ -14,12 +15,16 @@ class SyncTests: XCTestCase { let client = ConfigCatClient(sdkKey: "test", refreshMode: PollingModes.autoPoll(), session: MockHTTP.session()) let value = client.getValueSync(for: "key1", defaultValue: false) XCTAssertTrue(value) + let value2 = client.getValueSync(for: "key2", defaultValue: false, user: user) + XCTAssertTrue(value2) } func testGetVariationId() { let client = ConfigCatClient(sdkKey: "test", refreshMode: PollingModes.autoPoll(), session: MockHTTP.session()) let id = client.getVariationIdSync(for: "key1", defaultVariationId: "") XCTAssertEqual("fakeId1", id) + let id2 = client.getVariationIdSync(for: "key2", defaultVariationId: "", user: user) + XCTAssertEqual("9f21c24c", id2) } func testGetKeyValue() {