From 3ca6892258a4d24257f2396c603071ffab0c3021 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Mon, 10 Jul 2023 15:04:30 -0400 Subject: [PATCH 01/11] feat: rename DVCClient to DevCycleClient --- Cartfile.resolved | 2 +- DevCycle.xcodeproj/project.pbxproj | 32 ++++++++--------- .../{DVCClient.swift => DevCycleClient.swift} | 19 ++++++----- ...CClient.swift => ObjCDevCycleClient.swift} | 34 +++++++++++-------- ...ntTest.swift => DevCycleClientTests.swift} | 30 ++++++++++------ DevCycleTests/Models/ThreadingTests.swift | 4 +-- ...lientTests.m => ObjCDevCycleClientTests.m} | 26 ++++++++------ DevCycleTests/ObjC/ObjcDVCUserTests.m | 8 ++--- DevCycleTests/ObjC/ObjcDVCVariableTests.m | 2 +- DevCycleTests/Utils/GetTestConfig.swift | 2 +- 10 files changed, 91 insertions(+), 68 deletions(-) rename DevCycle/{DVCClient.swift => DevCycleClient.swift} (97%) rename DevCycle/ObjC/{ObjCDVCClient.swift => ObjCDevCycleClient.swift} (90%) rename DevCycleTests/Models/{DVCClientTest.swift => DevCycleClientTests.swift} (96%) rename DevCycleTests/ObjC/{ObjCDVCClientTests.m => ObjCDevCycleClientTests.m} (69%) diff --git a/Cartfile.resolved b/Cartfile.resolved index 9165ff5..ece64e5 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "LaunchDarkly/swift-eventsource" "3.0.0" +github "LaunchDarkly/swift-eventsource" "3.1.1" diff --git a/DevCycle.xcodeproj/project.pbxproj b/DevCycle.xcodeproj/project.pbxproj index 87a41ae..5a3ae61 100644 --- a/DevCycle.xcodeproj/project.pbxproj +++ b/DevCycle.xcodeproj/project.pbxproj @@ -19,9 +19,9 @@ 524D58242770F78B00D7CC56 /* ObjCDVCVariable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 524D58232770F78B00D7CC56 /* ObjCDVCVariable.swift */; }; 524F4E60276BDDBD00CB9069 /* DVCVariable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 524F4E5F276BDDBD00CB9069 /* DVCVariable.swift */; }; 524F4E62276D20A600CB9069 /* DVCVariableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 524F4E61276D20A500CB9069 /* DVCVariableTests.swift */; }; - 5256A99A2798716400E749FF /* ObjCDVCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5256A9982798716400E749FF /* ObjCDVCClientTests.m */; }; + 5256A99A2798716400E749FF /* ObjCDevCycleClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5256A9982798716400E749FF /* ObjCDevCycleClientTests.m */; }; 5256A99B2798716400E749FF /* ObjcDVCUserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5256A9992798716400E749FF /* ObjcDVCUserTests.m */; }; - 5264A77B275E9A7E00FEDB43 /* ObjCDVCClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A77A275E9A7E00FEDB43 /* ObjCDVCClient.swift */; }; + 5264A77B275E9A7E00FEDB43 /* ObjCDevCycleClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A77A275E9A7E00FEDB43 /* ObjCDevCycleClient.swift */; }; 5264A781275EB7DC00FEDB43 /* ObjCDVCUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A780275EB7DC00FEDB43 /* ObjCDVCUser.swift */; }; 5264A78727626A2200FEDB43 /* ObjCErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A78627626A2200FEDB43 /* ObjCErrors.swift */; }; 5264A78B2763F6D800FEDB43 /* UserConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A78A2763F6D800FEDB43 /* UserConfig.swift */; }; @@ -30,10 +30,10 @@ 5264A7BD2769381600FEDB43 /* Cache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A7BC2769381500FEDB43 /* Cache.swift */; }; 5268DB5727501CFC00D17A40 /* DevCycle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5268DB4D27501CFC00D17A40 /* DevCycle.framework */; }; 5268DB5D27501CFC00D17A40 /* DevCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 5268DB4F27501CFC00D17A40 /* DevCycle.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 5268DB6627501D6000D17A40 /* DVCClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6427501D6000D17A40 /* DVCClient.swift */; }; + 5268DB6627501D6000D17A40 /* DevCycleClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6427501D6000D17A40 /* DevCycleClient.swift */; }; 5268DB6727501D6000D17A40 /* DVCUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6527501D6000D17A40 /* DVCUser.swift */; }; 5268DB69275020D900D17A40 /* DVCUserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB68275020D900D17A40 /* DVCUserTest.swift */; }; - 5268DB6B275020F800D17A40 /* DVCClientTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6A275020F800D17A40 /* DVCClientTest.swift */; }; + 5268DB6B275020F800D17A40 /* DevCycleClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */; }; 5276C9F0275E682B00B9A324 /* DVCOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5276C9EF275E682B00B9A324 /* DVCOptions.swift */; }; 5276C9F2275E6E0D00B9A324 /* DVCOptionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */; }; 529CE32328DCBEC2009AB137 /* RequestConsolidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529CE32228DCBEC2009AB137 /* RequestConsolidator.swift */; }; @@ -92,9 +92,9 @@ 524D58232770F78B00D7CC56 /* ObjCDVCVariable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ObjCDVCVariable.swift; sourceTree = ""; }; 524F4E5F276BDDBD00CB9069 /* DVCVariable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCVariable.swift; sourceTree = ""; }; 524F4E61276D20A500CB9069 /* DVCVariableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCVariableTests.swift; sourceTree = ""; }; - 5256A9982798716400E749FF /* ObjCDVCClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCDVCClientTests.m; sourceTree = ""; }; + 5256A9982798716400E749FF /* ObjCDevCycleClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCDevCycleClientTests.m; sourceTree = ""; }; 5256A9992798716400E749FF /* ObjcDVCUserTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjcDVCUserTests.m; sourceTree = ""; }; - 5264A77A275E9A7E00FEDB43 /* ObjCDVCClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDVCClient.swift; sourceTree = ""; }; + 5264A77A275E9A7E00FEDB43 /* ObjCDevCycleClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDevCycleClient.swift; sourceTree = ""; }; 5264A77D275EACA300FEDB43 /* DevCycleTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DevCycleTests-Bridging-Header.h"; sourceTree = ""; }; 5264A780275EB7DC00FEDB43 /* ObjCDVCUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDVCUser.swift; sourceTree = ""; }; 5264A78627626A2200FEDB43 /* ObjCErrors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCErrors.swift; sourceTree = ""; }; @@ -105,10 +105,10 @@ 5268DB4D27501CFC00D17A40 /* DevCycle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DevCycle.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5268DB4F27501CFC00D17A40 /* DevCycle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DevCycle.h; sourceTree = ""; }; 5268DB5627501CFC00D17A40 /* DevCycleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DevCycleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 5268DB6427501D6000D17A40 /* DVCClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DVCClient.swift; sourceTree = ""; }; + 5268DB6427501D6000D17A40 /* DevCycleClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DevCycleClient.swift; sourceTree = ""; }; 5268DB6527501D6000D17A40 /* DVCUser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DVCUser.swift; sourceTree = ""; }; 5268DB68275020D900D17A40 /* DVCUserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCUserTest.swift; sourceTree = ""; }; - 5268DB6A275020F800D17A40 /* DVCClientTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCClientTest.swift; sourceTree = ""; }; + 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleClientTests.swift; sourceTree = ""; }; 5276C9EF275E682B00B9A324 /* DVCOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCOptions.swift; sourceTree = ""; }; 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCOptionsTest.swift; sourceTree = ""; }; 529CE32228DCBEC2009AB137 /* RequestConsolidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestConsolidator.swift; sourceTree = ""; }; @@ -184,7 +184,7 @@ isa = PBXGroup; children = ( 524D58232770F78B00D7CC56 /* ObjCDVCVariable.swift */, - 5264A77A275E9A7E00FEDB43 /* ObjCDVCClient.swift */, + 5264A77A275E9A7E00FEDB43 /* ObjCDevCycleClient.swift */, 5264A780275EB7DC00FEDB43 /* ObjCDVCUser.swift */, 5264A78627626A2200FEDB43 /* ObjCErrors.swift */, D9341C13276A3C8A00BC753F /* ObjCDVCEvent.swift */, @@ -200,7 +200,7 @@ 5268DB68275020D900D17A40 /* DVCUserTest.swift */, 524F4E61276D20A500CB9069 /* DVCVariableTests.swift */, 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */, - 5268DB6A275020F800D17A40 /* DVCClientTest.swift */, + 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */, 52A1139E27AB235C000B8285 /* EventQueueTests.swift */, 5264A78F2768E9F400FEDB43 /* UserConfigTests.swift */, 5264A78D2768E94500FEDB43 /* test_config.json */, @@ -235,7 +235,7 @@ 5264A779275E994B00FEDB43 /* ObjC */, 52E693EB2756815C00B52375 /* Models */, 52E693E827557B5700B52375 /* Networking */, - 5268DB6427501D6000D17A40 /* DVCClient.swift */, + 5268DB6427501D6000D17A40 /* DevCycleClient.swift */, 5268DB6527501D6000D17A40 /* DVCUser.swift */, 524F4E5F276BDDBD00CB9069 /* DVCVariable.swift */, 5268DB4F27501CFC00D17A40 /* DevCycle.h */, @@ -260,7 +260,7 @@ 529F0C8E277373D10075AAB4 /* ObjC */ = { isa = PBXGroup; children = ( - 5256A9982798716400E749FF /* ObjCDVCClientTests.m */, + 5256A9982798716400E749FF /* ObjCDevCycleClientTests.m */, 5256A9992798716400E749FF /* ObjcDVCUserTests.m */, 529F0C8F277374150075AAB4 /* ObjcDVCVariableTests.m */, ); @@ -427,7 +427,7 @@ 52A48707278C9BE200DABA34 /* Log.swift in Sources */, D9341C14276A3C8A00BC753F /* ObjCDVCEvent.swift in Sources */, 5226DF06290C588900630745 /* NotificationNames.swift in Sources */, - 5264A77B275E9A7E00FEDB43 /* ObjCDVCClient.swift in Sources */, + 5264A77B275E9A7E00FEDB43 /* ObjCDevCycleClient.swift in Sources */, 52E693ED2756816A00B52375 /* DVCConfig.swift in Sources */, 5264A7BD2769381600FEDB43 /* Cache.swift in Sources */, 52404CEA27F3A9FB00290A31 /* isEqual.swift in Sources */, @@ -438,7 +438,7 @@ 5264A78727626A2200FEDB43 /* ObjCErrors.swift in Sources */, 52A487032788C0FF00DABA34 /* ObjCUserConfig.swift in Sources */, 529CE32328DCBEC2009AB137 /* RequestConsolidator.swift in Sources */, - 5268DB6627501D6000D17A40 /* DVCClient.swift in Sources */, + 5268DB6627501D6000D17A40 /* DevCycleClient.swift in Sources */, D9341C12276967DE00BC753F /* DVCEvent.swift in Sources */, 524F4E60276BDDBD00CB9069 /* DVCVariable.swift in Sources */, 5276C9F0275E682B00B9A324 /* DVCOptions.swift in Sources */, @@ -458,13 +458,13 @@ 0B721685290B21CD004D0AB7 /* SSEMessage.swift in Sources */, 52E693F62758032500B52375 /* DevCycleServiceTests.swift in Sources */, 52404CED27F4A92100290A31 /* IsEqualTests.swift in Sources */, - 5268DB6B275020F800D17A40 /* DVCClientTest.swift in Sources */, + 5268DB6B275020F800D17A40 /* DevCycleClientTests.swift in Sources */, 523A31D029CB411A008F3347 /* ThreadingTests.swift in Sources */, 529F0C90277374150075AAB4 /* ObjcDVCVariableTests.m in Sources */, 5268DB69275020D900D17A40 /* DVCUserTest.swift in Sources */, 52A1139F27AB235C000B8285 /* EventQueueTests.swift in Sources */, 52133B2428DE0FEB0007691D /* GetTestConfig.swift in Sources */, - 5256A99A2798716400E749FF /* ObjCDVCClientTests.m in Sources */, + 5256A99A2798716400E749FF /* ObjCDevCycleClientTests.m in Sources */, 5256A99B2798716400E749FF /* ObjcDVCUserTests.m in Sources */, 524F4E62276D20A600CB9069 /* DVCVariableTests.swift in Sources */, ); diff --git a/DevCycle/DVCClient.swift b/DevCycle/DevCycleClient.swift similarity index 97% rename from DevCycle/DVCClient.swift rename to DevCycle/DevCycleClient.swift index 26da36c..210cf19 100644 --- a/DevCycle/DVCClient.swift +++ b/DevCycle/DevCycleClient.swift @@ -1,5 +1,5 @@ // -// DVCClient.swift +// DevCycleClient.swift // DevCycle-iOS-SDK // // @@ -28,7 +28,7 @@ public typealias IdentifyCompletedHandler = (Error?, [String: Variable]?) -> Voi public typealias FlushCompletedHandler = (Error?) -> Void public typealias CloseCompletedHandler = () -> Void -public class DVCClient { +public class DevCycleClient { var sdkKey: String? var user: DVCUser? var lastIdentifiedUser: DVCUser? @@ -386,7 +386,7 @@ public class DVCClient { public func track(_ event: DVCEvent) { if (self.closed) { - Log.error("DVCClient is closed, cannot log new events.") + Log.error("DevCycleClient is closed, cannot log new events.") return } if(!self.disableCustomEventLogging){ @@ -432,14 +432,14 @@ public class DVCClient { } public class ClientBuilder { - private var client: DVCClient + private var client: DevCycleClient private var service: DevCycleServiceProtocol? init() { - self.client = DVCClient() + self.client = DevCycleClient() } - @available(*, deprecated) + @available(*, deprecated, message: "Use sdkKey()") public func environmentKey(_ key: String) -> ClientBuilder { self.client.setSDKKey(key) return self @@ -465,7 +465,7 @@ public class DVCClient { return self } - public func build(onInitialized: ClientInitializedHandler?) throws -> DVCClient { + public func build(onInitialized: ClientInitializedHandler?) throws -> DevCycleClient { guard self.client.sdkKey != nil else { Log.error("Missing SDK Key", tags: ["build"]) throw ClientError.MissingSDKKeyOrUser @@ -481,7 +481,7 @@ public class DVCClient { } else { result.initialize(callback: onInitialized) } - self.client = DVCClient() + self.client = DevCycleClient() return result } } @@ -507,3 +507,6 @@ public class DVCClient { DispatchQueue.main.asyncAfter(deadline: .now() + Double(delay), execute: work) } } + +@available(*, deprecated, message: "Use DevCycleClient") +public typealias DVCClient = DevCycleClient diff --git a/DevCycle/ObjC/ObjCDVCClient.swift b/DevCycle/ObjC/ObjCDevCycleClient.swift similarity index 90% rename from DevCycle/ObjC/ObjCDVCClient.swift rename to DevCycle/ObjC/ObjCDevCycleClient.swift index 89c9eae..f72ddc1 100644 --- a/DevCycle/ObjC/ObjCDVCClient.swift +++ b/DevCycle/ObjC/ObjCDevCycleClient.swift @@ -1,21 +1,21 @@ // -// ObjCDVCClient.swift +// ObjCDevCycleClient.swift // DevCycle // // import Foundation -@objc(DVCClient) -public class ObjCDVCClient: NSObject { - var client: DVCClient? +@objc(DevCycleClient) +public class ObjCDevCycleClient: NSObject { + var client: DevCycleClient? @objc(initialize:user:) public static func initialize( sdkKey: String, user: ObjCUser - ) -> ObjCDVCClient { - return ObjCDVCClient( + ) -> ObjCDevCycleClient { + return ObjCDevCycleClient( sdkKey: sdkKey, user: user, options: nil, @@ -28,8 +28,8 @@ public class ObjCDVCClient: NSObject { sdkKey: String, user: ObjCUser, options: ObjCOptions? - ) -> ObjCDVCClient { - return ObjCDVCClient( + ) -> ObjCDevCycleClient { + return ObjCDevCycleClient( sdkKey: sdkKey, user: user, options: options, @@ -43,8 +43,8 @@ public class ObjCDVCClient: NSObject { user: ObjCUser, options: ObjCOptions?, onInitialized: ((Error?) -> Void)? - ) -> ObjCDVCClient { - return ObjCDVCClient( + ) -> ObjCDevCycleClient { + return ObjCDevCycleClient( sdkKey: sdkKey, user: user, options: options, @@ -71,7 +71,7 @@ public class ObjCDVCClient: NSObject { let dvcUser = try user.buildDVCUser() - var clientBuilder = DVCClient.builder() + var clientBuilder = DevCycleClient.builder() .sdkKey(sdkKey) .user(dvcUser) @@ -81,7 +81,7 @@ public class ObjCDVCClient: NSObject { guard let client = try? clientBuilder.build(onInitialized: onInitialized) else { - Log.error("Error creating client", tags: ["build", "objc"]) + Log.error("Error creating DevCycleClient", tags: ["build", "objc"]) throw ObjCClientErrors.InvalidClient } self.client = client @@ -89,7 +89,7 @@ public class ObjCDVCClient: NSObject { if let onInitializedCallback = onInitialized { onInitializedCallback(error) } else { - Log.error("Error initializing DVCClient: \(error)") + Log.error("Error initializing DevCycleClient: \(error)") } } } @@ -118,7 +118,7 @@ public class ObjCDVCClient: NSObject { if let idCallback = callback { idCallback(error, nil) } else { - Log.error("Error calling DVCClient identifyUser:callback: \(error)") + Log.error("Error calling DevCycleClient identifyUser:callback: \(error)") } } } @@ -209,7 +209,7 @@ public class ObjCDVCClient: NSObject { } } -extension ObjCDVCClient { +extension ObjCDevCycleClient { func featureToObjCFeature(_ features: [String: Feature]?) -> [String: ObjCFeature] { var objcFeatures: [String: ObjCFeature] = [:] if let features = features { @@ -230,3 +230,7 @@ extension ObjCDVCClient { return objcVariables } } + +@available(*, deprecated, message: "Use DevCycleClient") +@objc(DVCClient) +public class ObjCDVCClient: ObjCDevCycleClient {} diff --git a/DevCycleTests/Models/DVCClientTest.swift b/DevCycleTests/Models/DevCycleClientTests.swift similarity index 96% rename from DevCycleTests/Models/DVCClientTest.swift rename to DevCycleTests/Models/DevCycleClientTests.swift index e884a1a..40469ce 100644 --- a/DevCycleTests/Models/DVCClientTest.swift +++ b/DevCycleTests/Models/DevCycleClientTests.swift @@ -1,5 +1,5 @@ // -// DVCClient.swift +// DevCycleClient.swift // DevCycleTests // // @@ -14,10 +14,10 @@ import WatchKit @testable import DevCycle -class DVCClientTest: XCTestCase { +class DevCycleClientTest: XCTestCase { private var service: MockService! private var user: DVCUser! - private var builder: DVCClient.ClientBuilder! + private var builder: DevCycleClient.ClientBuilder! private var userConfig: UserConfig! override func setUp() { @@ -25,7 +25,7 @@ class DVCClientTest: XCTestCase { self.user = try! DVCUser.builder() .userId("my_user") .build() - self.builder = DVCClient.builder().service(service) + self.builder = DevCycleClient.builder().service(service) let data = getConfigData(name: "test_config") let dictionary = try! JSONSerialization.jsonObject(with: data, options: .fragmentsAllowed) as! [String:Any] @@ -58,8 +58,18 @@ class DVCClientTest: XCTestCase { client.close(callback: nil) } + func testDepracatedDVCClientWorks() { + let builder = DevCycleClient.builder().service(service) + let client = try! builder.user(self.user).environmentKey("my_sdk_key").build(onInitialized: nil) + XCTAssertNotNil(client) + XCTAssertNotNil(client.user) + XCTAssertNotNil(client.sdkKey) + XCTAssertNil(client.options) + client.close(callback: nil) + } + func testSetupCallsGetConfig() { - let client = DVCClient() + let client = DevCycleClient() let service = MockService() // will assert if getConfig was called client.setSDKKey("") client.setUser(self.user) @@ -79,7 +89,7 @@ class DVCClientTest: XCTestCase { func testTrackWithValidDVCEventNoOptionals() { let expectation = XCTestExpectation(description: "EventQueue has one event") - let client = DVCClient() + let client = DevCycleClient() let event: DVCEvent = try! DVCEvent.builder().type("test").build() client.track(event) @@ -94,7 +104,7 @@ class DVCClientTest: XCTestCase { func testTrackWithValidDVCEventWithAllParamsDefined() { let expectation = XCTestExpectation(description: "EventQueue has one fully defined event") - let client = DVCClient() + let client = DevCycleClient() let metaData: [String:Any] = ["test1": "key", "test2": 2, "test3": false] let event: DVCEvent = try! DVCEvent.builder().type("test").target("test").clientDate(Date()).value(1).metaData(metaData).build() @@ -110,7 +120,7 @@ class DVCClientTest: XCTestCase { func testTrackWithValidDVCEventWithAllParamsDefinedAndDoubleValue() { let expectation = XCTestExpectation(description: "EventQueue has one fully defined event") - let client = DVCClient() + let client = DevCycleClient() let metaData: [String:Any] = ["test1": "key", "test2": 2, "test3": false] let event: DVCEvent = try! DVCEvent.builder().type("test").target("test").clientDate(Date()).value(364.25).metaData(metaData).build() @@ -300,7 +310,7 @@ class DVCClientTest: XCTestCase { func testRefetchConfigUsesTheCorrectUser() { let service = MockService() let user1 = try! DVCUser.builder().userId("user1").build() - let client = try! DVCClient.builder().user(user1).sdkKey("my_sdk_key").build(onInitialized: nil) + let client = try! DevCycleClient.builder().user(user1).sdkKey("my_sdk_key").build(onInitialized: nil) client.setup(service: service) client.initialized = true @@ -481,7 +491,7 @@ class DVCClientTest: XCTestCase { } -extension DVCClientTest { +extension DevCycleClientTest { private class MockService: DevCycleServiceProtocol { public var publishCallCount: Int = 0 public var userForGetConfig: DVCUser? diff --git a/DevCycleTests/Models/ThreadingTests.swift b/DevCycleTests/Models/ThreadingTests.swift index 991deef..641d1c8 100644 --- a/DevCycleTests/Models/ThreadingTests.swift +++ b/DevCycleTests/Models/ThreadingTests.swift @@ -11,7 +11,7 @@ import XCTest final class ThreadingTests: XCTestCase { private var service: MockService! private var user: DVCUser! - private var builder: DVCClient.ClientBuilder! + private var builder: DevCycleClient.ClientBuilder! private var userConfig: UserConfig! override func setUpWithError() throws { @@ -19,7 +19,7 @@ final class ThreadingTests: XCTestCase { self.user = try! DVCUser.builder() .userId("my_user") .build() - self.builder = DVCClient.builder().service(service) + self.builder = DevCycleClient.builder().service(service) let data = getConfigData(name: "test_config") let dictionary = try! JSONSerialization.jsonObject(with: data, options: .fragmentsAllowed) as! [String:Any] diff --git a/DevCycleTests/ObjC/ObjCDVCClientTests.m b/DevCycleTests/ObjC/ObjCDevCycleClientTests.m similarity index 69% rename from DevCycleTests/ObjC/ObjCDVCClientTests.m rename to DevCycleTests/ObjC/ObjCDevCycleClientTests.m index a5e7f37..03556a7 100644 --- a/DevCycleTests/ObjC/ObjCDVCClientTests.m +++ b/DevCycleTests/ObjC/ObjCDevCycleClientTests.m @@ -1,5 +1,5 @@ // -// ObjcDVCClientTests.m +// ObjcDevCycleClientTests.m // DevCycleTests // // @@ -7,16 +7,16 @@ #import @import DevCycle; -@interface ObjcDVCClientTests : XCTestCase +@interface ObjcDevCycleClientTests : XCTestCase @end -@implementation ObjcDVCClientTests +@implementation ObjcDevCycleClientTests - (void)testBuilderReturnsErrorIfNoSDKKey { XCTestExpectation *expectation = [self expectationWithDescription:@"Builder returns error if no sdk key"]; DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCClient *client = [DVCClient initialize:nil user:user options:nil onInitialized:^(NSError * _Nullable err) { + DevCycleClient *client = [DevCycleClient initialize:nil user:user options:nil onInitialized:^(NSError * _Nullable err) { XCTAssertNil(client); XCTAssertNotNil(err); [expectation fulfill]; @@ -26,7 +26,7 @@ - (void)testBuilderReturnsErrorIfNoSDKKey { - (void)testBuilderReturnsErrorIfNoUser { XCTestExpectation *expectation = [self expectationWithDescription:@"Builder returns error if no user"]; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:nil options:nil onInitialized:^(NSError * _Nullable err) { + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:nil options:nil onInitialized:^(NSError * _Nullable err) { XCTAssertNil(client); XCTAssertNotNil(err); [expectation fulfill]; @@ -36,7 +36,7 @@ - (void)testBuilderReturnsErrorIfNoUser { - (void)testBuilderCreatesClientWithUserAndSDKKey { DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); } @@ -47,7 +47,13 @@ - (void)testBuilderCreatesClientWithUserAndSDKKeyAndOptions { options.disableRealtimeUpdates = @true; options.configCacheTTL = @86400000; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:options onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:options onInitialized:nil]; + XCTAssertNotNil(client); +} + +- (void)testDepracatedDVCClientWorks { + DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); } @@ -55,7 +61,7 @@ - (void)testBuilderCreatesClientWithUserAndSDKKeyAndOptions { - (void)testVariableIsCreated { DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); DVCVariable *variable = [client stringVariableWithKey:@"my-key" defaultValue:@"default-value"]; XCTAssertNotNil(variable); @@ -67,7 +73,7 @@ - (void)testVariableIsCreated { - (void)testVariableValueIsCreated { DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); NSString *variableValue = [client stringVariableValueWithKey:@"my-key" defaultValue:@"default-value"]; XCTAssertNotNil(variableValue); @@ -76,7 +82,7 @@ - (void)testVariableValueIsCreated { - (void)testVariableValueBool { DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); BOOL boolValue = [client boolVariableValueWithKey:@"my-key" defaultValue:true]; XCTAssertTrue(boolValue); diff --git a/DevCycleTests/ObjC/ObjcDVCUserTests.m b/DevCycleTests/ObjC/ObjcDVCUserTests.m index 2b8da2a..41c7e71 100644 --- a/DevCycleTests/ObjC/ObjcDVCUserTests.m +++ b/DevCycleTests/ObjC/ObjcDVCUserTests.m @@ -15,21 +15,21 @@ @implementation ObjcDVCUserTests - (void)testCreateUser { DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(user); XCTAssertNotNil(client); } - (void)testAnonUser { DVCUser *user = [[DVCUser alloc] init]; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(user); XCTAssertTrue(user.isAnonymous); } - (void)testNonUserIdPropertiesAreNil { DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(user); XCTAssert([user.userId isEqual:@"my_user"]); XCTAssertFalse([user.isAnonymous boolValue]); @@ -46,7 +46,7 @@ - (void)testNonUserIdPropertiesAreNotNil { user.email = @"email.com"; user.name = @"Jason Smith"; user.country = @"CAN"; - DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(user); XCTAssert([user.userId isEqual:@"my_user"]); XCTAssertFalse([user.isAnonymous boolValue]); diff --git a/DevCycleTests/ObjC/ObjcDVCVariableTests.m b/DevCycleTests/ObjC/ObjcDVCVariableTests.m index cb2133f..c241158 100644 --- a/DevCycleTests/ObjC/ObjcDVCVariableTests.m +++ b/DevCycleTests/ObjC/ObjcDVCVariableTests.m @@ -16,7 +16,7 @@ @implementation ObjcDVCVariableTests - (void)testVariableGetsCreatedWithDefault { DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCClient *client = [DVCClient initialize:@"key" user:user]; + DevCycleClient *client = [DevCycleClient initialize:@"key" user:user]; DVCVariable *variable = [client stringVariableWithKey:@"my-key" defaultValue:@"my-default"]; XCTAssertNotNil(variable); XCTAssertEqual(variable.value, @"my-default"); diff --git a/DevCycleTests/Utils/GetTestConfig.swift b/DevCycleTests/Utils/GetTestConfig.swift index 6192e7e..2fb771b 100644 --- a/DevCycleTests/Utils/GetTestConfig.swift +++ b/DevCycleTests/Utils/GetTestConfig.swift @@ -8,7 +8,7 @@ import Foundation func getConfigData(name: String, withExtension: String = "json") -> Data { - let bundle = Bundle(for: DVCClientTest.self) + let bundle = Bundle(for: DevCycleClientTest.self) let fileUrl = bundle.url(forResource: name, withExtension: withExtension) let data = try! Data(contentsOf: fileUrl!) return data From cb43a3a111a9fc2aba46af0f1e9f8a044c9445bb Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Mon, 10 Jul 2023 15:14:53 -0400 Subject: [PATCH 02/11] feat: rename DVCUser to DevCycleUser --- DevCycle.xcodeproj/project.pbxproj | 32 ++++++++--------- DevCycle/DevCycleClient.swift | 16 ++++----- .../{DVCUser.swift => DevCycleUser.swift} | 22 ++++++------ DevCycle/Models/Cache.swift | 20 +++++------ DevCycle/Models/DVCConfig.swift | 4 +-- DevCycle/Models/EventQueue.swift | 2 +- DevCycle/Networking/DevCycleService.swift | 16 ++++----- DevCycle/ObjC/ObjCDevCycleClient.swift | 16 ++++----- ...jCDVCUser.swift => ObjCDevCycleUser.swift} | 26 ++++++++++---- DevCycle/Utils/RequestConsolidator.swift | 4 +-- .../Models/DevCycleClientTests.swift | 26 +++++++------- ...CUserTest.swift => DevCycleUserTest.swift} | 34 ++++++++++++------- DevCycleTests/Models/EventQueueTests.swift | 18 +++++----- DevCycleTests/Models/ThreadingTests.swift | 10 +++--- .../Networking/DevCycleServiceTests.swift | 10 +++--- ...DVCUserTests.m => ObjcDevCycleUserTests.m} | 21 ++++++++---- .../Utils/RequestConsolidatorTests.swift | 10 +++--- 17 files changed, 159 insertions(+), 128 deletions(-) rename DevCycle/{DVCUser.swift => DevCycleUser.swift} (94%) rename DevCycle/ObjC/{ObjCDVCUser.swift => ObjCDevCycleUser.swift} (77%) rename DevCycleTests/Models/{DVCUserTest.swift => DevCycleUserTest.swift} (81%) rename DevCycleTests/ObjC/{ObjcDVCUserTests.m => ObjcDevCycleUserTests.m} (72%) diff --git a/DevCycle.xcodeproj/project.pbxproj b/DevCycle.xcodeproj/project.pbxproj index 5a3ae61..012bb20 100644 --- a/DevCycle.xcodeproj/project.pbxproj +++ b/DevCycle.xcodeproj/project.pbxproj @@ -20,9 +20,9 @@ 524F4E60276BDDBD00CB9069 /* DVCVariable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 524F4E5F276BDDBD00CB9069 /* DVCVariable.swift */; }; 524F4E62276D20A600CB9069 /* DVCVariableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 524F4E61276D20A500CB9069 /* DVCVariableTests.swift */; }; 5256A99A2798716400E749FF /* ObjCDevCycleClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5256A9982798716400E749FF /* ObjCDevCycleClientTests.m */; }; - 5256A99B2798716400E749FF /* ObjcDVCUserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5256A9992798716400E749FF /* ObjcDVCUserTests.m */; }; + 5256A99B2798716400E749FF /* ObjcDevCycleUserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5256A9992798716400E749FF /* ObjcDevCycleUserTests.m */; }; 5264A77B275E9A7E00FEDB43 /* ObjCDevCycleClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A77A275E9A7E00FEDB43 /* ObjCDevCycleClient.swift */; }; - 5264A781275EB7DC00FEDB43 /* ObjCDVCUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A780275EB7DC00FEDB43 /* ObjCDVCUser.swift */; }; + 5264A781275EB7DC00FEDB43 /* ObjCDevCycleUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A780275EB7DC00FEDB43 /* ObjCDevCycleUser.swift */; }; 5264A78727626A2200FEDB43 /* ObjCErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A78627626A2200FEDB43 /* ObjCErrors.swift */; }; 5264A78B2763F6D800FEDB43 /* UserConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5264A78A2763F6D800FEDB43 /* UserConfig.swift */; }; 5264A78E2768E94600FEDB43 /* test_config.json in Resources */ = {isa = PBXBuildFile; fileRef = 5264A78D2768E94500FEDB43 /* test_config.json */; }; @@ -31,8 +31,8 @@ 5268DB5727501CFC00D17A40 /* DevCycle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5268DB4D27501CFC00D17A40 /* DevCycle.framework */; }; 5268DB5D27501CFC00D17A40 /* DevCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 5268DB4F27501CFC00D17A40 /* DevCycle.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5268DB6627501D6000D17A40 /* DevCycleClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6427501D6000D17A40 /* DevCycleClient.swift */; }; - 5268DB6727501D6000D17A40 /* DVCUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6527501D6000D17A40 /* DVCUser.swift */; }; - 5268DB69275020D900D17A40 /* DVCUserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB68275020D900D17A40 /* DVCUserTest.swift */; }; + 5268DB6727501D6000D17A40 /* DevCycleUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6527501D6000D17A40 /* DevCycleUser.swift */; }; + 5268DB69275020D900D17A40 /* DevCycleUserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB68275020D900D17A40 /* DevCycleUserTest.swift */; }; 5268DB6B275020F800D17A40 /* DevCycleClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */; }; 5276C9F0275E682B00B9A324 /* DVCOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5276C9EF275E682B00B9A324 /* DVCOptions.swift */; }; 5276C9F2275E6E0D00B9A324 /* DVCOptionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */; }; @@ -93,10 +93,10 @@ 524F4E5F276BDDBD00CB9069 /* DVCVariable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCVariable.swift; sourceTree = ""; }; 524F4E61276D20A500CB9069 /* DVCVariableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCVariableTests.swift; sourceTree = ""; }; 5256A9982798716400E749FF /* ObjCDevCycleClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCDevCycleClientTests.m; sourceTree = ""; }; - 5256A9992798716400E749FF /* ObjcDVCUserTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjcDVCUserTests.m; sourceTree = ""; }; + 5256A9992798716400E749FF /* ObjcDevCycleUserTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjcDevCycleUserTests.m; sourceTree = ""; }; 5264A77A275E9A7E00FEDB43 /* ObjCDevCycleClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDevCycleClient.swift; sourceTree = ""; }; 5264A77D275EACA300FEDB43 /* DevCycleTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DevCycleTests-Bridging-Header.h"; sourceTree = ""; }; - 5264A780275EB7DC00FEDB43 /* ObjCDVCUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDVCUser.swift; sourceTree = ""; }; + 5264A780275EB7DC00FEDB43 /* ObjCDevCycleUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDevCycleUser.swift; sourceTree = ""; }; 5264A78627626A2200FEDB43 /* ObjCErrors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCErrors.swift; sourceTree = ""; }; 5264A78A2763F6D800FEDB43 /* UserConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserConfig.swift; sourceTree = ""; }; 5264A78D2768E94500FEDB43 /* test_config.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = test_config.json; sourceTree = ""; }; @@ -106,8 +106,8 @@ 5268DB4F27501CFC00D17A40 /* DevCycle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DevCycle.h; sourceTree = ""; }; 5268DB5627501CFC00D17A40 /* DevCycleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DevCycleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5268DB6427501D6000D17A40 /* DevCycleClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DevCycleClient.swift; sourceTree = ""; }; - 5268DB6527501D6000D17A40 /* DVCUser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DVCUser.swift; sourceTree = ""; }; - 5268DB68275020D900D17A40 /* DVCUserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCUserTest.swift; sourceTree = ""; }; + 5268DB6527501D6000D17A40 /* DevCycleUser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DevCycleUser.swift; sourceTree = ""; }; + 5268DB68275020D900D17A40 /* DevCycleUserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleUserTest.swift; sourceTree = ""; }; 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleClientTests.swift; sourceTree = ""; }; 5276C9EF275E682B00B9A324 /* DVCOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCOptions.swift; sourceTree = ""; }; 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCOptionsTest.swift; sourceTree = ""; }; @@ -185,7 +185,7 @@ children = ( 524D58232770F78B00D7CC56 /* ObjCDVCVariable.swift */, 5264A77A275E9A7E00FEDB43 /* ObjCDevCycleClient.swift */, - 5264A780275EB7DC00FEDB43 /* ObjCDVCUser.swift */, + 5264A780275EB7DC00FEDB43 /* ObjCDevCycleUser.swift */, 5264A78627626A2200FEDB43 /* ObjCErrors.swift */, D9341C13276A3C8A00BC753F /* ObjCDVCEvent.swift */, 52A486752784A3E600DABA34 /* ObjCDVCOptions.swift */, @@ -197,7 +197,7 @@ 5264A78C2768E87C00FEDB43 /* Models */ = { isa = PBXGroup; children = ( - 5268DB68275020D900D17A40 /* DVCUserTest.swift */, + 5268DB68275020D900D17A40 /* DevCycleUserTest.swift */, 524F4E61276D20A500CB9069 /* DVCVariableTests.swift */, 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */, 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */, @@ -236,7 +236,7 @@ 52E693EB2756815C00B52375 /* Models */, 52E693E827557B5700B52375 /* Networking */, 5268DB6427501D6000D17A40 /* DevCycleClient.swift */, - 5268DB6527501D6000D17A40 /* DVCUser.swift */, + 5268DB6527501D6000D17A40 /* DevCycleUser.swift */, 524F4E5F276BDDBD00CB9069 /* DVCVariable.swift */, 5268DB4F27501CFC00D17A40 /* DevCycle.h */, E673EFC6290093C400C2C4BE /* SSEConnection.swift */, @@ -261,7 +261,7 @@ isa = PBXGroup; children = ( 5256A9982798716400E749FF /* ObjCDevCycleClientTests.m */, - 5256A9992798716400E749FF /* ObjcDVCUserTests.m */, + 5256A9992798716400E749FF /* ObjcDevCycleUserTests.m */, 529F0C8F277374150075AAB4 /* ObjcDVCVariableTests.m */, ); path = ObjC; @@ -422,7 +422,7 @@ 5264A78B2763F6D800FEDB43 /* UserConfig.swift in Sources */, E673EFC7290093C400C2C4BE /* SSEConnection.swift in Sources */, 0F2DD75A279EFA6B00540C9D /* CustomData.swift in Sources */, - 5264A781275EB7DC00FEDB43 /* ObjCDVCUser.swift in Sources */, + 5264A781275EB7DC00FEDB43 /* ObjCDevCycleUser.swift in Sources */, 52A96990279F3AAA00D3A602 /* PlatformDetails.swift in Sources */, 52A48707278C9BE200DABA34 /* Log.swift in Sources */, D9341C14276A3C8A00BC753F /* ObjCDVCEvent.swift in Sources */, @@ -434,7 +434,7 @@ 52A486762784A3E600DABA34 /* ObjCDVCOptions.swift in Sources */, 52A96A0F27A0A7CF00D3A602 /* EventQueue.swift in Sources */, 52E693EA27567E2600B52375 /* DevCycleService.swift in Sources */, - 5268DB6727501D6000D17A40 /* DVCUser.swift in Sources */, + 5268DB6727501D6000D17A40 /* DevCycleUser.swift in Sources */, 5264A78727626A2200FEDB43 /* ObjCErrors.swift in Sources */, 52A487032788C0FF00DABA34 /* ObjCUserConfig.swift in Sources */, 529CE32328DCBEC2009AB137 /* RequestConsolidator.swift in Sources */, @@ -461,11 +461,11 @@ 5268DB6B275020F800D17A40 /* DevCycleClientTests.swift in Sources */, 523A31D029CB411A008F3347 /* ThreadingTests.swift in Sources */, 529F0C90277374150075AAB4 /* ObjcDVCVariableTests.m in Sources */, - 5268DB69275020D900D17A40 /* DVCUserTest.swift in Sources */, + 5268DB69275020D900D17A40 /* DevCycleUserTest.swift in Sources */, 52A1139F27AB235C000B8285 /* EventQueueTests.swift in Sources */, 52133B2428DE0FEB0007691D /* GetTestConfig.swift in Sources */, 5256A99A2798716400E749FF /* ObjCDevCycleClientTests.m in Sources */, - 5256A99B2798716400E749FF /* ObjcDVCUserTests.m in Sources */, + 5256A99B2798716400E749FF /* ObjcDevCycleUserTests.m in Sources */, 524F4E62276D20A600CB9069 /* DVCVariableTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/DevCycle/DevCycleClient.swift b/DevCycle/DevCycleClient.swift index 210cf19..67b14f0 100644 --- a/DevCycle/DevCycleClient.swift +++ b/DevCycle/DevCycleClient.swift @@ -30,8 +30,8 @@ public typealias CloseCompletedHandler = () -> Void public class DevCycleClient { var sdkKey: String? - var user: DVCUser? - var lastIdentifiedUser: DVCUser? + var user: DevCycleUser? + var lastIdentifiedUser: DevCycleUser? var config: DVCConfig? var options: DVCOptions? var configCompletionHandlers: [ClientInitializedHandler] = [] @@ -196,7 +196,7 @@ public class DevCycleClient { self.sdkKey = sdkKey } - func setUser(_ user: DVCUser) { + func setUser(_ user: DevCycleUser) { self.user = user } @@ -219,7 +219,7 @@ public class DevCycleClient { } } - private func cacheUser(user: DVCUser) { + private func cacheUser(user: DevCycleUser) { self.cacheService.save(user: user) if user.isAnonymous == true, let userId = user.userId { self.cacheService.setAnonUserId(anonUserId: userId) @@ -313,12 +313,12 @@ public class DevCycleClient { } } - public func identifyUser(user: DVCUser, callback: IdentifyCompletedHandler? = nil) throws { + public func identifyUser(user: DevCycleUser, callback: IdentifyCompletedHandler? = nil) throws { guard let currentUser = self.user, let userId = currentUser.userId, let incomingUserId = user.userId else { throw ClientError.InvalidUser } self.flushEvents() - var updateUser: DVCUser = currentUser + var updateUser: DevCycleUser = currentUser if (userId == incomingUserId) { updateUser.update(with: user) } else { @@ -351,7 +351,7 @@ public class DevCycleClient { let cachedAnonUserId = self.cacheService.getAnonUserId() self.cacheService.clearAnonUserId() - let anonUser = try DVCUser.builder().isAnonymous(true).build() + let anonUser = try DevCycleUser.builder().isAnonymous(true).build() self.lastIdentifiedUser = anonUser @@ -450,7 +450,7 @@ public class DevCycleClient { return self } - public func user(_ user: DVCUser) -> ClientBuilder { + public func user(_ user: DevCycleUser) -> ClientBuilder { self.client.setUser(user) return self } diff --git a/DevCycle/DVCUser.swift b/DevCycle/DevCycleUser.swift similarity index 94% rename from DevCycle/DVCUser.swift rename to DevCycle/DevCycleUser.swift index b7242d9..6f3d525 100644 --- a/DevCycle/DVCUser.swift +++ b/DevCycle/DevCycleUser.swift @@ -1,8 +1,7 @@ // -// DVCUser.swift +// DevCycleUser.swift // DevCycle-iOS-SDK // -// import Foundation @@ -21,12 +20,12 @@ enum UserError: Error { public class UserBuilder { private let cacheService: CacheServiceProtocol = CacheService() - var user: DVCUser + var user: DevCycleUser var customData: [String: Any]? var privateCustomData: [String: Any]? init() { - self.user = DVCUser() + self.user = DevCycleUser() } public func userId(_ userId: String) -> UserBuilder { @@ -79,7 +78,7 @@ public class UserBuilder { return self } - public func build() throws -> DVCUser { + public func build() throws -> DevCycleUser { guard self.user.userId?.trimmingCharacters(in: .whitespacesAndNewlines) != "" else { throw UserError.InvalidUser @@ -105,7 +104,7 @@ public class UserBuilder { } let result = self.user - self.user = DVCUser() + self.user = DevCycleUser() self.customData = nil self.privateCustomData = nil return result @@ -113,7 +112,7 @@ public class UserBuilder { } -public class DVCUser: Codable { +public class DevCycleUser: Codable { public var userId: String? public var isAnonymous: Bool? public var email: String? @@ -152,7 +151,7 @@ public class DVCUser: Codable { case isAnonymous, email, name, language, country, appVersion, appBuild, customData, privateCustomData, lastSeenDate, createdDate, platform, platformVersion, deviceModel, sdkType, sdkVersion } - public func update(with user: DVCUser) { + public func update(with user: DevCycleUser) { self.lastSeenDate = Date() self.email = user.email self.name = user.name @@ -199,11 +198,14 @@ public class DVCUser: Codable { } } +@available(*, deprecated, message: "Use DevCycleUser") +public typealias DVCUser = DevCycleUser + class QueryItemBuilder { var items: [URLQueryItem] - let user: DVCUser + let user: DevCycleUser - init(user: DVCUser) { + init(user: DevCycleUser) { self.items = [] self.user = user } diff --git a/DevCycle/Models/Cache.swift b/DevCycle/Models/Cache.swift index a15ac66..14a7c54 100644 --- a/DevCycle/Models/Cache.swift +++ b/DevCycle/Models/Cache.swift @@ -8,17 +8,17 @@ import Foundation protocol CacheServiceProtocol { func load() -> Cache - func save(user: DVCUser) + func save(user: DevCycleUser) func setAnonUserId(anonUserId: String) func getAnonUserId() -> String? func clearAnonUserId() - func saveConfig(user: DVCUser, fetchDate: Int, configToSave: Data?) - func getConfig(user: DVCUser, ttlMs: Int) -> UserConfig? + func saveConfig(user: DevCycleUser, fetchDate: Int, configToSave: Data?) + func getConfig(user: DevCycleUser, ttlMs: Int) -> UserConfig? } struct Cache { var config: UserConfig? - var user: DVCUser? + var user: DevCycleUser? var anonUserId: String? } @@ -35,7 +35,7 @@ class CacheService: CacheServiceProtocol { func load() -> Cache { var userConfig: UserConfig? - var dvcUser: DVCUser? + var dvcUser: DevCycleUser? if let data = defaults.object(forKey: CacheKeys.config) as? Data, let dictionary = try? JSONSerialization.jsonObject(with: data, options: .fragmentsAllowed) as? [String:Any], let config = try? UserConfig(from: dictionary) @@ -43,14 +43,14 @@ class CacheService: CacheServiceProtocol { userConfig = config } if let data = defaults.object(forKey: CacheKeys.user) as? Data { - dvcUser = try? JSONDecoder().decode(DVCUser.self, from: data) + dvcUser = try? JSONDecoder().decode(DevCycleUser.self, from: data) } let anonUserId = self.getAnonUserId() return Cache(config: userConfig, user: dvcUser, anonUserId: anonUserId) } - func save(user: DVCUser) { + func save(user: DevCycleUser) { if let data = try? JSONEncoder().encode(user) { defaults.set(data, forKey: CacheKeys.user) } @@ -68,7 +68,7 @@ class CacheService: CacheServiceProtocol { self.remove(key: CacheKeys.anonUserId) } - func saveConfig(user: DVCUser, fetchDate: Int, configToSave: Data?) { + func saveConfig(user: DevCycleUser, fetchDate: Int, configToSave: Data?) { let key = getConfigKeyPrefix(user: user) defaults.set(configToSave, forKey: key) if let data = user.userId { @@ -77,7 +77,7 @@ class CacheService: CacheServiceProtocol { self.setInt(key: "\(key).FETCH_DATE", value: fetchDate) } - func getConfig(user: DVCUser, ttlMs: Int) -> UserConfig? { + func getConfig(user: DevCycleUser, ttlMs: Int) -> UserConfig? { let key = getConfigKeyPrefix(user: user) var config: UserConfig? @@ -125,7 +125,7 @@ class CacheService: CacheServiceProtocol { defaults.removeObject(forKey: key) } - private func getConfigKeyPrefix(user: DVCUser) -> String { + private func getConfigKeyPrefix(user: DevCycleUser) -> String { return (user.isAnonymous ?? false) ? CacheKeys.anonymousConfigKey : CacheKeys.identifiedConfigKey } } diff --git a/DevCycle/Models/DVCConfig.swift b/DevCycle/Models/DVCConfig.swift index 7bdf5b6..0993b1b 100644 --- a/DevCycle/Models/DVCConfig.swift +++ b/DevCycle/Models/DVCConfig.swift @@ -8,7 +8,7 @@ import Foundation public class DVCConfig { var sdkKey: String - var user: DVCUser + var user: DevCycleUser var userConfig: UserConfig? { didSet { if let userConfig = self.userConfig { @@ -21,7 +21,7 @@ public class DVCConfig { } } - init(sdkKey: String, user: DVCUser) { + init(sdkKey: String, user: DevCycleUser) { self.sdkKey = sdkKey self.user = user } diff --git a/DevCycle/Models/EventQueue.swift b/DevCycle/Models/EventQueue.swift index 7dee1af..6adaa5c 100644 --- a/DevCycle/Models/EventQueue.swift +++ b/DevCycle/Models/EventQueue.swift @@ -29,7 +29,7 @@ class EventQueue { } } - func flush(service: DevCycleServiceProtocol, user: DVCUser, callback: FlushCompletedHandler? = nil) { + func flush(service: DevCycleServiceProtocol, user: DevCycleUser, callback: FlushCompletedHandler? = nil) { if (self.flushing) { Log.warn("Flushing already in progress, cancelling flush") callback?(EventQueueErrors.FlushingInProgress) diff --git a/DevCycle/Networking/DevCycleService.swift b/DevCycle/Networking/DevCycleService.swift index 3fa0b83..4b9a15f 100644 --- a/DevCycle/Networking/DevCycleService.swift +++ b/DevCycle/Networking/DevCycleService.swift @@ -62,9 +62,9 @@ struct RequestParams { } protocol DevCycleServiceProtocol { - func getConfig(user:DVCUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) - func publishEvents(events: [DVCEvent], user: DVCUser, completion: @escaping PublishEventsCompletionHandler) - func saveEntity(user:DVCUser, completion: @escaping SaveEntityCompletionHandler) + func getConfig(user:DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) + func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) + func saveEntity(user:DevCycleUser, completion: @escaping SaveEntityCompletionHandler) func makeRequest(request: URLRequest, completion: @escaping CompletionHandler) } @@ -75,7 +75,7 @@ class DevCycleService: DevCycleServiceProtocol { var cacheService: CacheServiceProtocol var requestConsolidator: RequestConsolidator! - private var newUser: DVCUser? + private var newUser: DevCycleUser? init(config: DVCConfig, cacheService: CacheServiceProtocol) { let sessionConfig = URLSessionConfiguration.default @@ -85,12 +85,12 @@ class DevCycleService: DevCycleServiceProtocol { self.requestConsolidator = RequestConsolidator(service: self, cacheService: cacheService) } - func getConfig(user: DVCUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) { + func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) { let configRequest = createConfigRequest(user: user, enableEdgeDB: enableEdgeDB, extraParams: extraParams) requestConsolidator.queue(request: configRequest, user: user, callback: completion) } - func publishEvents(events: [DVCEvent], user: DVCUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { var eventsRequest = createEventsRequest() let userEncoder = JSONEncoder() userEncoder.dateEncodingStrategy = .iso8601 @@ -124,7 +124,7 @@ class DevCycleService: DevCycleServiceProtocol { } } - func saveEntity(user: DVCUser, completion: @escaping SaveEntityCompletionHandler) { + func saveEntity(user: DevCycleUser, completion: @escaping SaveEntityCompletionHandler) { var saveEntityRequest = createSaveEntityRequest() guard let userIsAnonymous = user.isAnonymous, !userIsAnonymous else { @@ -203,7 +203,7 @@ class DevCycleService: DevCycleServiceProtocol { }.resume() } - func createConfigRequest(user: DVCUser, enableEdgeDB: Bool, extraParams: RequestParams? = nil) -> URLRequest { + func createConfigRequest(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams? = nil) -> URLRequest { var userQueryItems: [URLQueryItem] = user.toQueryItems() let queryItem = URLQueryItem(name: "enableEdgeDB", value: String(enableEdgeDB)) userQueryItems.append(queryItem) diff --git a/DevCycle/ObjC/ObjCDevCycleClient.swift b/DevCycle/ObjC/ObjCDevCycleClient.swift index f72ddc1..f6e51c3 100644 --- a/DevCycle/ObjC/ObjCDevCycleClient.swift +++ b/DevCycle/ObjC/ObjCDevCycleClient.swift @@ -13,7 +13,7 @@ public class ObjCDevCycleClient: NSObject { @objc(initialize:user:) public static func initialize( sdkKey: String, - user: ObjCUser + user: ObjCDevCycleUser ) -> ObjCDevCycleClient { return ObjCDevCycleClient( sdkKey: sdkKey, @@ -26,7 +26,7 @@ public class ObjCDevCycleClient: NSObject { @objc(initialize:user:options:) public static func initialize( sdkKey: String, - user: ObjCUser, + user: ObjCDevCycleUser, options: ObjCOptions? ) -> ObjCDevCycleClient { return ObjCDevCycleClient( @@ -40,7 +40,7 @@ public class ObjCDevCycleClient: NSObject { @objc(initialize:user:options:onInitialized:) public static func initialize( sdkKey: String, - user: ObjCUser, + user: ObjCDevCycleUser, options: ObjCOptions?, onInitialized: ((Error?) -> Void)? ) -> ObjCDevCycleClient { @@ -54,7 +54,7 @@ public class ObjCDevCycleClient: NSObject { init( sdkKey: String, - user: ObjCUser, + user: ObjCDevCycleUser, options: ObjCOptions?, onInitialized: ((Error?) -> Void)? ) { @@ -69,7 +69,7 @@ public class ObjCDevCycleClient: NSObject { throw ObjCClientErrors.InvalidUser } - let dvcUser = try user.buildDVCUser() + let dvcUser = try user.buildDevCycleUser() var clientBuilder = DevCycleClient.builder() .sdkKey(sdkKey) @@ -96,16 +96,16 @@ public class ObjCDevCycleClient: NSObject { @objc(identifyUser:callback:) - public func identify(user: ObjCUser, callback: ((Error?, [String: ObjCVariable]?) -> Void)?) { + public func identify(user: ObjCDevCycleUser, callback: ((Error?, [String: ObjCVariable]?) -> Void)?) { do { guard let client = self.client else { return } guard user.userId != nil else { callback?(NSError(), nil) return } - let dvcUser = try user.buildDVCUser() + let dvcUser = try user.buildDevCycleUser() - let createdUser = DVCUser() + let createdUser = DevCycleUser() createdUser.userId = user.userId! createdUser.isAnonymous = false createdUser.update(with: dvcUser) diff --git a/DevCycle/ObjC/ObjCDVCUser.swift b/DevCycle/ObjC/ObjCDevCycleUser.swift similarity index 77% rename from DevCycle/ObjC/ObjCDVCUser.swift rename to DevCycle/ObjC/ObjCDevCycleUser.swift index 0617cf4..59d886b 100644 --- a/DevCycle/ObjC/ObjCDVCUser.swift +++ b/DevCycle/ObjC/ObjCDevCycleUser.swift @@ -6,8 +6,8 @@ import Foundation -@objc(DVCUser) -public class ObjCUser: NSObject { +@objc(DevCycleUser) +public class ObjCDevCycleUser: NSObject { @objc public var userId: String? @objc public var isAnonymous: NSNumber? @objc public var email: String? @@ -22,8 +22,8 @@ public class ObjCUser: NSObject { } @objc(initializeWithUserId:) - public static func initialize(userId: String?) -> ObjCUser { - let builder = ObjCUser() + public static func initialize(userId: String?) -> ObjCDevCycleUser { + let builder = ObjCDevCycleUser() if (userId == nil) { builder.isAnonymous = true } else { @@ -33,8 +33,8 @@ public class ObjCUser: NSObject { return builder } - func buildDVCUser() throws -> DVCUser { - var userBuilder = DVCUser.builder() + func buildDevCycleUser() throws -> DevCycleUser { + var userBuilder = DevCycleUser.builder() if let userId = self.userId { userBuilder = userBuilder.userId(userId) } else { @@ -69,4 +69,18 @@ public class ObjCUser: NSObject { throw error } } + + @available(*, deprecated, message: "Use buildDevCycleUser") + func buildDVCUser() throws -> DVCUser { + do { + return try buildDevCycleUser() + } catch { + throw error + } + } } + +@available(*, deprecated, message: "Use DevCycleUser") +@objc(DVCUser) +public class ObjCDVCUser: ObjCDevCycleUser {} + diff --git a/DevCycle/Utils/RequestConsolidator.swift b/DevCycle/Utils/RequestConsolidator.swift index 0b7e3c4..5868657 100644 --- a/DevCycle/Utils/RequestConsolidator.swift +++ b/DevCycle/Utils/RequestConsolidator.swift @@ -20,7 +20,7 @@ class RequestConsolidator { self.cacheService = cacheService } - func queue(request: URLRequest, user: DVCUser, callback: @escaping ConfigCompletionHandler) { + func queue(request: URLRequest, user: DevCycleUser, callback: @escaping ConfigCompletionHandler) { if (self.requestInFlight) { self.requestCallbacks.append( RequestWithCallback( @@ -57,7 +57,7 @@ class RequestConsolidator { } } - func makeLastRequestInQueue(user: DVCUser, complete: (() -> Void)?) { + func makeLastRequestInQueue(user: DevCycleUser, complete: (() -> Void)?) { guard let lastRequest = self.requestCallbacks.last?.request else { print("No last request to make in queue") return diff --git a/DevCycleTests/Models/DevCycleClientTests.swift b/DevCycleTests/Models/DevCycleClientTests.swift index 40469ce..59ca39b 100644 --- a/DevCycleTests/Models/DevCycleClientTests.swift +++ b/DevCycleTests/Models/DevCycleClientTests.swift @@ -16,13 +16,13 @@ import WatchKit class DevCycleClientTest: XCTestCase { private var service: MockService! - private var user: DVCUser! + private var user: DevCycleUser! private var builder: DevCycleClient.ClientBuilder! private var userConfig: UserConfig! override func setUp() { self.service = MockService() - self.user = try! DVCUser.builder() + self.user = try! DevCycleUser.builder() .userId("my_user") .build() self.builder = DevCycleClient.builder().service(service) @@ -309,7 +309,7 @@ class DevCycleClientTest: XCTestCase { func testRefetchConfigUsesTheCorrectUser() { let service = MockService() - let user1 = try! DVCUser.builder().userId("user1").build() + let user1 = try! DevCycleUser.builder().userId("user1").build() let client = try! DevCycleClient.builder().user(user1).sdkKey("my_sdk_key").build(onInitialized: nil) client.setup(service: service) client.initialized = true @@ -318,13 +318,13 @@ class DevCycleClientTest: XCTestCase { client.refetchConfig(sse: true, lastModified: 123, etag: "etag") XCTAssertEqual(service.numberOfConfigCalls, 2) - let user2 = try! DVCUser.builder().userId("user2").build() + let user2 = try! DevCycleUser.builder().userId("user2").build() try! client.identifyUser(user: user2) XCTAssertEqual(client.lastIdentifiedUser?.userId, user2.userId) client.refetchConfig(sse: true, lastModified: 456, etag: "etag") XCTAssertEqual(service.numberOfConfigCalls, 4) - let user3 = try! DVCUser.builder().userId("user3").build() + let user3 = try! DevCycleUser.builder().userId("user3").build() try! client.identifyUser(user: user3) XCTAssertEqual(client.lastIdentifiedUser?.userId, user3.userId) client.refetchConfig(sse: true, lastModified: 789, etag: "etag") @@ -411,14 +411,14 @@ class DevCycleClientTest: XCTestCase { func testIdentifyUserClearsCachedAnonymousUserId() { // Build Anon User, generates a new UUID - let anonUser1 = try! DVCUser.builder().isAnonymous(true).build() + let anonUser1 = try! DevCycleUser.builder().isAnonymous(true).build() XCTAssertNotNil(anonUser1) // Call Identify with a NOT anonymous User, this should erase the Cached UUID of anonUser1 let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").build(onInitialized: { [weak self] error in // Since the cached Anonymous User Id is only cleared on successful identify call, // the anonUser3.userId should be the same as anonUser1.userId - let anonUser3 = try! DVCUser.builder().isAnonymous(true).build() + let anonUser3 = try! DevCycleUser.builder().isAnonymous(true).build() XCTAssertNotNil(anonUser3) XCTAssertEqual(anonUser3.userId, anonUser1.userId) }) @@ -427,7 +427,7 @@ class DevCycleClientTest: XCTestCase { try! client.identifyUser(user: self.user, callback: { [weak self] error, variables in // Wait for successful identifyUser callback, then build a new anonymous User, which SHOULD generate a new UUID - let anonUser2 = try! DVCUser.builder().isAnonymous(true).build() + let anonUser2 = try! DevCycleUser.builder().isAnonymous(true).build() XCTAssertNotNil(anonUser2) XCTAssertNotEqual(anonUser2.userId, anonUser1.userId) }) @@ -435,7 +435,7 @@ class DevCycleClientTest: XCTestCase { } func testResetUserGeneratesANewAnonymousUserId() { - let anonUser1 = try! DVCUser.builder().isAnonymous(true).build() + let anonUser1 = try! DevCycleUser.builder().isAnonymous(true).build() XCTAssertNotNil(anonUser1) let client = try! self.builder.user(anonUser1).sdkKey("my_sdk_key").build(onInitialized: nil) @@ -494,18 +494,18 @@ class DevCycleClientTest: XCTestCase { extension DevCycleClientTest { private class MockService: DevCycleServiceProtocol { public var publishCallCount: Int = 0 - public var userForGetConfig: DVCUser? + public var userForGetConfig: DevCycleUser? public var numberOfConfigCalls: Int = 0 public var eventPublishCount: Int = 0 - func getConfig(user: DVCUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) { + func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) { self.userForGetConfig = user self.numberOfConfigCalls += 1 XCTAssert(true) } - func publishEvents(events: [DVCEvent], user: DVCUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { self.publishCallCount += 1 self.eventPublishCount += events.count XCTAssert(true) @@ -514,7 +514,7 @@ extension DevCycleClientTest { }) } - func saveEntity(user: DVCUser, completion: @escaping SaveEntityCompletionHandler) { + func saveEntity(user: DevCycleUser, completion: @escaping SaveEntityCompletionHandler) { XCTAssert(true) } diff --git a/DevCycleTests/Models/DVCUserTest.swift b/DevCycleTests/Models/DevCycleUserTest.swift similarity index 81% rename from DevCycleTests/Models/DVCUserTest.swift rename to DevCycleTests/Models/DevCycleUserTest.swift index 7de1b2f..bea15e3 100644 --- a/DevCycleTests/Models/DVCUserTest.swift +++ b/DevCycleTests/Models/DevCycleUserTest.swift @@ -7,9 +7,9 @@ import XCTest @testable import DevCycle -class DVCUserTest: XCTestCase { +class DevCycleUserTest: XCTestCase { func testCreateUser() { - let user = DVCUser() + let user = DevCycleUser() #if os(tvOS) XCTAssert(user.platform == "tvOS") XCTAssertNotNil(user.platformVersion) @@ -33,9 +33,17 @@ class DVCUserTest: XCTestCase { XCTAssert(user.sdkType == "mobile") XCTAssertNotNil(user.sdkVersion) } + + func testDeprecatedDVCUser() { + let user = try! DVCUser.builder() + .build() + XCTAssertNotNil(user) + XCTAssert(UUID(uuidString: user.userId!) != nil) + XCTAssertTrue(user.isAnonymous!) + } func testBuilderReturnsAnonUserIfNoUserIdOrIsAnonymous() { - let user = try! DVCUser.builder() + let user = try! DevCycleUser.builder() .build() XCTAssertNotNil(user) XCTAssert(UUID(uuidString: user.userId!) != nil) @@ -43,7 +51,7 @@ class DVCUserTest: XCTestCase { } func testBuilderReturnsAnonUserIfNoUserIdAndIsAnonymousIsFalse() { - let user = try! DVCUser.builder() + let user = try! DevCycleUser.builder() .isAnonymous(false) .build() XCTAssertNotNil(user) @@ -52,26 +60,26 @@ class DVCUserTest: XCTestCase { } func testBuilderReturnsUserIfUserIdSet() { - let user = try! DVCUser.builder().userId("my_user").build() + let user = try! DevCycleUser.builder().userId("my_user").build() XCTAssertNotNil(user) XCTAssert(user.userId == "my_user") XCTAssert(!user.isAnonymous!) } func testBuilderReturnsUserIfIsAnonymousSet() { - let user = try! DVCUser.builder().isAnonymous(true).build() + let user = try! DevCycleUser.builder().isAnonymous(true).build() XCTAssertNotNil(user) XCTAssert(user.isAnonymous!) XCTAssert(UUID(uuidString: user.userId!) != nil) } func testBuilderReturnsNilIfUserIdIsEmptyString() { - let user = try? DVCUser.builder().userId("").build() + let user = try? DevCycleUser.builder().userId("").build() XCTAssertNil(user) } func testBuilderReturnsNilIfUserIdOnlyContainsWhitespaces() { - let user = try? DVCUser.builder().userId(" ").build() + let user = try? DevCycleUser.builder().userId(" ").build() XCTAssertNil(user) } @@ -104,12 +112,12 @@ class DVCUserTest: XCTestCase { let cacheService = CacheService() cacheService.setAnonUserId(anonUserId: "123") - let anonUser = try! DVCUser.builder().isAnonymous(true).build() + let anonUser = try! DevCycleUser.builder().isAnonymous(true).build() XCTAssertNotNil(anonUser) XCTAssert(anonUser.isAnonymous!) XCTAssertEqual(anonUser.userId, "123") - let anonUser2 = try! DVCUser.builder().isAnonymous(true).build() + let anonUser2 = try! DevCycleUser.builder().isAnonymous(true).build() XCTAssertNotNil(anonUser2) XCTAssert(anonUser2.isAnonymous!) XCTAssertEqual(anonUser2.userId, "123") @@ -118,9 +126,9 @@ class DVCUserTest: XCTestCase { } } -extension DVCUserTest { - func getTestUser() -> DVCUser { - return try! DVCUser.builder() +extension DevCycleUserTest { + func getTestUser() -> DevCycleUser { + return try! DevCycleUser.builder() .userId("my_user") .isAnonymous(false) .customData(["custom": "key"]) diff --git a/DevCycleTests/Models/EventQueueTests.swift b/DevCycleTests/Models/EventQueueTests.swift index b7c6358..f7a4cf6 100644 --- a/DevCycleTests/Models/EventQueueTests.swift +++ b/DevCycleTests/Models/EventQueueTests.swift @@ -29,7 +29,7 @@ class EventQueueTests: XCTestCase { let eventQueue = EventQueue() let expectation = XCTestExpectation(description: "Subsequent flushes are cancelled") let event = try! DVCEvent.builder().type("event1").build() - let user = try! DVCUser.builder().userId("user1").build() + let user = try! DevCycleUser.builder().userId("user1").build() eventQueue.queue(event) eventQueue.flush(service: MockService(), user: user, callback: nil) eventQueue.flush(service: MockService(), user: user) { error in @@ -43,7 +43,7 @@ class EventQueueTests: XCTestCase { let eventQueue = EventQueue() let expectation = XCTestExpectation(description: "Flush Requeues Retryable Event") let event = try! DVCEvent.builder().type("event1").build() - let user = try! DVCUser.builder().userId("user1").build() + let user = try! DevCycleUser.builder().userId("user1").build() eventQueue.queue(event) eventQueue.flush(service: MockWithErrorCodeService(errorCode: 500), user: user, callback: nil) let result = XCTWaiter.wait(for: [expectation], timeout: 2.0) @@ -56,7 +56,7 @@ class EventQueueTests: XCTestCase { let eventQueue = EventQueue() let expectation = XCTestExpectation(description: "Subsequent flushes are cancelled") let event = try! DVCEvent.builder().type("event1").build() - let user = try! DVCUser.builder().userId("user1").build() + let user = try! DevCycleUser.builder().userId("user1").build() eventQueue.queue(event) eventQueue.flush(service: MockWithErrorCodeService(errorCode: 403), user: user, callback: nil) let result = XCTWaiter.wait(for: [expectation], timeout: 2.0) @@ -67,16 +67,16 @@ class EventQueueTests: XCTestCase { } private class MockService: DevCycleServiceProtocol { - func getConfig(user: DVCUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} + func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} - func publishEvents(events: [DVCEvent], user: DVCUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { completion((nil, nil, nil)) } } - func saveEntity(user: DVCUser, completion: @escaping SaveEntityCompletionHandler) {} + func saveEntity(user: DevCycleUser, completion: @escaping SaveEntityCompletionHandler) {} func makeRequest(request: URLRequest, completion: @escaping DevCycle.CompletionHandler) {} } @@ -87,13 +87,13 @@ class MockWithErrorCodeService: DevCycleServiceProtocol { self.errorCode = errorCode } - func getConfig(user: DVCUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} - func publishEvents(events: [DVCEvent], user: DVCUser, completion: @escaping PublishEventsCompletionHandler) { + func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} + func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { let error = NSError(domain: "api.devcycle.com", code: self.errorCode) DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { completion((nil, nil, error)) } } - func saveEntity(user: DVCUser, completion: @escaping SaveEntityCompletionHandler) {} + func saveEntity(user: DevCycleUser, completion: @escaping SaveEntityCompletionHandler) {} func makeRequest(request: URLRequest, completion: @escaping DevCycle.CompletionHandler) {} } diff --git a/DevCycleTests/Models/ThreadingTests.swift b/DevCycleTests/Models/ThreadingTests.swift index 641d1c8..28bcfbb 100644 --- a/DevCycleTests/Models/ThreadingTests.swift +++ b/DevCycleTests/Models/ThreadingTests.swift @@ -10,13 +10,13 @@ import XCTest final class ThreadingTests: XCTestCase { private var service: MockService! - private var user: DVCUser! + private var user: DevCycleUser! private var builder: DevCycleClient.ClientBuilder! private var userConfig: UserConfig! override func setUpWithError() throws { self.service = MockService() - self.user = try! DVCUser.builder() + self.user = try! DevCycleUser.builder() .userId("my_user") .build() self.builder = DevCycleClient.builder().service(service) @@ -41,11 +41,11 @@ final class ThreadingTests: XCTestCase { } private class MockService: DevCycleServiceProtocol { - func getConfig(user: DVCUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} + func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} - func publishEvents(events: [DVCEvent], user: DVCUser, completion: @escaping PublishEventsCompletionHandler) {} + func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) {} - func saveEntity(user: DVCUser, completion: @escaping SaveEntityCompletionHandler) {} + func saveEntity(user: DevCycleUser, completion: @escaping SaveEntityCompletionHandler) {} func makeRequest(request: URLRequest, completion: @escaping DevCycle.CompletionHandler) {} } diff --git a/DevCycleTests/Networking/DevCycleServiceTests.swift b/DevCycleTests/Networking/DevCycleServiceTests.swift index b6cae54..0e646ee 100644 --- a/DevCycleTests/Networking/DevCycleServiceTests.swift +++ b/DevCycleTests/Networking/DevCycleServiceTests.swift @@ -59,7 +59,7 @@ extension DevCycleServiceTests { return Cache(config: nil, user: nil) } - func save(user: DVCUser) { + func save(user: DevCycleUser) { self.saveUserCalled = true } func setAnonUserId(anonUserId: String) { @@ -72,11 +72,11 @@ extension DevCycleServiceTests { // TODO: update implementation for tests } - func saveConfig(user: DVCUser, fetchDate: Int, configToSave: Data?) { + func saveConfig(user: DevCycleUser, fetchDate: Int, configToSave: Data?) { self.saveConfigCalled = true } - func getConfig(user: DVCUser, ttlMs: Int) -> UserConfig? { + func getConfig(user: DevCycleUser, ttlMs: Int) -> UserConfig? { return nil } } @@ -87,8 +87,8 @@ extension DevCycleServiceTests { return DevCycleService(config: config, cacheService: MockCacheService()) } - func getTestUser() -> DVCUser { - return try! DVCUser.builder() + func getTestUser() -> DevCycleUser { + return try! DevCycleUser.builder() .userId("my_user") .build() } diff --git a/DevCycleTests/ObjC/ObjcDVCUserTests.m b/DevCycleTests/ObjC/ObjcDevCycleUserTests.m similarity index 72% rename from DevCycleTests/ObjC/ObjcDVCUserTests.m rename to DevCycleTests/ObjC/ObjcDevCycleUserTests.m index 41c7e71..28a082f 100644 --- a/DevCycleTests/ObjC/ObjcDVCUserTests.m +++ b/DevCycleTests/ObjC/ObjcDevCycleUserTests.m @@ -1,5 +1,5 @@ // -// ObjcDVCUserTests.m +// ObjcDevCycleUserTests.m // DevCycleTests // // @@ -7,28 +7,35 @@ #import @import DevCycle; -@interface ObjcDVCUserTests : XCTestCase +@interface ObjcDevCycleUserTests : XCTestCase @end -@implementation ObjcDVCUserTests +@implementation ObjcDevCycleUserTests - (void)testCreateUser { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(user); XCTAssertNotNil(client); } +- (void)testDeprecatedDVCUser { + DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; + XCTAssertNotNil(user); + XCTAssertNotNil(client); +} + - (void)testAnonUser { - DVCUser *user = [[DVCUser alloc] init]; + DevCycleUser *user = [[DevCycleUser alloc] init]; DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(user); XCTAssertTrue(user.isAnonymous); } - (void)testNonUserIdPropertiesAreNil { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(user); XCTAssert([user.userId isEqual:@"my_user"]); @@ -41,7 +48,7 @@ - (void)testNonUserIdPropertiesAreNil { } - (void)testNonUserIdPropertiesAreNotNil { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; user.isAnonymous = @NO; user.email = @"email.com"; user.name = @"Jason Smith"; diff --git a/DevCycleTests/Utils/RequestConsolidatorTests.swift b/DevCycleTests/Utils/RequestConsolidatorTests.swift index ff5f1c7..6e2e3d6 100644 --- a/DevCycleTests/Utils/RequestConsolidatorTests.swift +++ b/DevCycleTests/Utils/RequestConsolidatorTests.swift @@ -16,7 +16,7 @@ class RequestConsolidatorTests: XCTestCase { let requestConsolidator = RequestConsolidator(service: mockService, cacheService: mockCacheService) let request = URLRequest(url: URL(string: "https://dummy.com")!) let expectation = expectation(description: "One request completes") - let user = try! DVCUser.builder().userId("test_user").build() + let user = try! DevCycleUser.builder().userId("test_user").build() requestConsolidator.queue(request: request, user: user) { response in XCTAssertEqual(response.config?.variables["testVar"]?.value as! String, "any_value") expectation.fulfill() @@ -32,7 +32,7 @@ class RequestConsolidatorTests: XCTestCase { let request1 = URLRequest(url: URL(string: "https://dummy.com/firstPage")!) let request2 = URLRequest(url: URL(string: "https://dummy.com/secondPage")!) let request3 = URLRequest(url: URL(string: "https://dummy.com/thirdPage")!) - let user = try! DVCUser.builder().userId("test_user").build() + let user = try! DevCycleUser.builder().userId("test_user").build() let expectation = expectation(description: "Multiple request completes") expectation.expectedFulfillmentCount = 3 requestConsolidator.queue(request: request1, user: user) { response in @@ -61,15 +61,15 @@ class RequestConsolidatorTests: XCTestCase { extension RequestConsolidatorTests { class MockService: DevCycleServiceProtocol { - func getConfig(user: DVCUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) { + func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) { XCTAssert(true) } - func publishEvents(events: [DVCEvent], user: DVCUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { XCTAssert(true) } - func saveEntity(user: DVCUser, completion: @escaping SaveEntityCompletionHandler) { + func saveEntity(user: DevCycleUser, completion: @escaping SaveEntityCompletionHandler) { XCTAssert(true) } From 755735a884b21a6593d785814ffedd5295b0a716 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Mon, 10 Jul 2023 15:21:48 -0400 Subject: [PATCH 03/11] rename DVCOptions to DevCycleOptions --- DevCycle.xcodeproj/project.pbxproj | 24 +++++++++---------- DevCycle/DevCycleClient.swift | 6 ++--- ...DVCOptions.swift => DevCycleOptions.swift} | 13 ++++++---- DevCycle/ObjC/ObjCDevCycleClient.swift | 6 ++--- ...ptions.swift => ObjCDevCycleOptions.swift} | 15 ++++++------ .../Models/DevCycleClientTests.swift | 12 +++++----- ...nsTest.swift => DevCycleOptionsTest.swift} | 20 ++++++++++++---- 7 files changed, 55 insertions(+), 41 deletions(-) rename DevCycle/Models/{DVCOptions.swift => DevCycleOptions.swift} (88%) rename DevCycle/ObjC/{ObjCDVCOptions.swift => ObjCDevCycleOptions.swift} (88%) rename DevCycleTests/Models/{DVCOptionsTest.swift => DevCycleOptionsTest.swift} (69%) diff --git a/DevCycle.xcodeproj/project.pbxproj b/DevCycle.xcodeproj/project.pbxproj index 012bb20..fe087fc 100644 --- a/DevCycle.xcodeproj/project.pbxproj +++ b/DevCycle.xcodeproj/project.pbxproj @@ -34,13 +34,13 @@ 5268DB6727501D6000D17A40 /* DevCycleUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6527501D6000D17A40 /* DevCycleUser.swift */; }; 5268DB69275020D900D17A40 /* DevCycleUserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB68275020D900D17A40 /* DevCycleUserTest.swift */; }; 5268DB6B275020F800D17A40 /* DevCycleClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */; }; - 5276C9F0275E682B00B9A324 /* DVCOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5276C9EF275E682B00B9A324 /* DVCOptions.swift */; }; - 5276C9F2275E6E0D00B9A324 /* DVCOptionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */; }; + 5276C9F0275E682B00B9A324 /* DevCycleOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5276C9EF275E682B00B9A324 /* DevCycleOptions.swift */; }; + 5276C9F2275E6E0D00B9A324 /* DevCycleOptionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5276C9F1275E6E0D00B9A324 /* DevCycleOptionsTest.swift */; }; 529CE32328DCBEC2009AB137 /* RequestConsolidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529CE32228DCBEC2009AB137 /* RequestConsolidator.swift */; }; 529F0C90277374150075AAB4 /* ObjcDVCVariableTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 529F0C8F277374150075AAB4 /* ObjcDVCVariableTests.m */; }; 529F0CA52774D6BE0075AAB4 /* URLSessionMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529F0CA42774D6BE0075AAB4 /* URLSessionMock.swift */; }; 52A1139F27AB235C000B8285 /* EventQueueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A1139E27AB235C000B8285 /* EventQueueTests.swift */; }; - 52A486762784A3E600DABA34 /* ObjCDVCOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A486752784A3E600DABA34 /* ObjCDVCOptions.swift */; }; + 52A486762784A3E600DABA34 /* ObjCDevCycleOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A486752784A3E600DABA34 /* ObjCDevCycleOptions.swift */; }; 52A487032788C0FF00DABA34 /* ObjCUserConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A487022788C0FF00DABA34 /* ObjCUserConfig.swift */; }; 52A48707278C9BE200DABA34 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A48706278C9BE200DABA34 /* Log.swift */; }; 52A96990279F3AAA00D3A602 /* PlatformDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A9698F279F3AAA00D3A602 /* PlatformDetails.swift */; }; @@ -109,13 +109,13 @@ 5268DB6527501D6000D17A40 /* DevCycleUser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DevCycleUser.swift; sourceTree = ""; }; 5268DB68275020D900D17A40 /* DevCycleUserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleUserTest.swift; sourceTree = ""; }; 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleClientTests.swift; sourceTree = ""; }; - 5276C9EF275E682B00B9A324 /* DVCOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCOptions.swift; sourceTree = ""; }; - 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCOptionsTest.swift; sourceTree = ""; }; + 5276C9EF275E682B00B9A324 /* DevCycleOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleOptions.swift; sourceTree = ""; }; + 5276C9F1275E6E0D00B9A324 /* DevCycleOptionsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleOptionsTest.swift; sourceTree = ""; }; 529CE32228DCBEC2009AB137 /* RequestConsolidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestConsolidator.swift; sourceTree = ""; }; 529F0C8F277374150075AAB4 /* ObjcDVCVariableTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ObjcDVCVariableTests.m; sourceTree = ""; }; 529F0CA42774D6BE0075AAB4 /* URLSessionMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionMock.swift; sourceTree = ""; }; 52A1139E27AB235C000B8285 /* EventQueueTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventQueueTests.swift; sourceTree = ""; }; - 52A486752784A3E600DABA34 /* ObjCDVCOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDVCOptions.swift; sourceTree = ""; }; + 52A486752784A3E600DABA34 /* ObjCDevCycleOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDevCycleOptions.swift; sourceTree = ""; }; 52A487022788C0FF00DABA34 /* ObjCUserConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCUserConfig.swift; sourceTree = ""; }; 52A48706278C9BE200DABA34 /* Log.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = ""; }; 52A9698F279F3AAA00D3A602 /* PlatformDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformDetails.swift; sourceTree = ""; }; @@ -188,7 +188,7 @@ 5264A780275EB7DC00FEDB43 /* ObjCDevCycleUser.swift */, 5264A78627626A2200FEDB43 /* ObjCErrors.swift */, D9341C13276A3C8A00BC753F /* ObjCDVCEvent.swift */, - 52A486752784A3E600DABA34 /* ObjCDVCOptions.swift */, + 52A486752784A3E600DABA34 /* ObjCDevCycleOptions.swift */, 52A487022788C0FF00DABA34 /* ObjCUserConfig.swift */, ); path = ObjC; @@ -199,7 +199,7 @@ children = ( 5268DB68275020D900D17A40 /* DevCycleUserTest.swift */, 524F4E61276D20A500CB9069 /* DVCVariableTests.swift */, - 5276C9F1275E6E0D00B9A324 /* DVCOptionsTest.swift */, + 5276C9F1275E6E0D00B9A324 /* DevCycleOptionsTest.swift */, 5268DB6A275020F800D17A40 /* DevCycleClientTests.swift */, 52A1139E27AB235C000B8285 /* EventQueueTests.swift */, 5264A78F2768E9F400FEDB43 /* UserConfigTests.swift */, @@ -287,7 +287,7 @@ isa = PBXGroup; children = ( 52E693EC2756816A00B52375 /* DVCConfig.swift */, - 5276C9EF275E682B00B9A324 /* DVCOptions.swift */, + 5276C9EF275E682B00B9A324 /* DevCycleOptions.swift */, 5264A78A2763F6D800FEDB43 /* UserConfig.swift */, D9341C11276967DE00BC753F /* DVCEvent.swift */, 5264A7BC2769381500FEDB43 /* Cache.swift */, @@ -431,7 +431,7 @@ 52E693ED2756816A00B52375 /* DVCConfig.swift in Sources */, 5264A7BD2769381600FEDB43 /* Cache.swift in Sources */, 52404CEA27F3A9FB00290A31 /* isEqual.swift in Sources */, - 52A486762784A3E600DABA34 /* ObjCDVCOptions.swift in Sources */, + 52A486762784A3E600DABA34 /* ObjCDevCycleOptions.swift in Sources */, 52A96A0F27A0A7CF00D3A602 /* EventQueue.swift in Sources */, 52E693EA27567E2600B52375 /* DevCycleService.swift in Sources */, 5268DB6727501D6000D17A40 /* DevCycleUser.swift in Sources */, @@ -441,7 +441,7 @@ 5268DB6627501D6000D17A40 /* DevCycleClient.swift in Sources */, D9341C12276967DE00BC753F /* DVCEvent.swift in Sources */, 524F4E60276BDDBD00CB9069 /* DVCVariable.swift in Sources */, - 5276C9F0275E682B00B9A324 /* DVCOptions.swift in Sources */, + 5276C9F0275E682B00B9A324 /* DevCycleOptions.swift in Sources */, 524D58242770F78B00D7CC56 /* ObjCDVCVariable.swift in Sources */, 52133B2228DE00BC0007691D /* ProcessConfig.swift in Sources */, ); @@ -453,7 +453,7 @@ files = ( 529F0CA52774D6BE0075AAB4 /* URLSessionMock.swift in Sources */, 52133B2028DDFB260007691D /* RequestConsolidatorTests.swift in Sources */, - 5276C9F2275E6E0D00B9A324 /* DVCOptionsTest.swift in Sources */, + 5276C9F2275E6E0D00B9A324 /* DevCycleOptionsTest.swift in Sources */, 5264A7902768E9F400FEDB43 /* UserConfigTests.swift in Sources */, 0B721685290B21CD004D0AB7 /* SSEMessage.swift in Sources */, 52E693F62758032500B52375 /* DevCycleServiceTests.swift in Sources */, diff --git a/DevCycle/DevCycleClient.swift b/DevCycle/DevCycleClient.swift index 67b14f0..d8d2503 100644 --- a/DevCycle/DevCycleClient.swift +++ b/DevCycle/DevCycleClient.swift @@ -33,7 +33,7 @@ public class DevCycleClient { var user: DevCycleUser? var lastIdentifiedUser: DevCycleUser? var config: DVCConfig? - var options: DVCOptions? + var options: DevCycleOptions? var configCompletionHandlers: [ClientInitializedHandler] = [] var initialized: Bool = false var eventQueue: EventQueue = EventQueue() @@ -200,7 +200,7 @@ public class DevCycleClient { self.user = user } - func setOptions(_ options: DVCOptions) { + func setOptions(_ options: DevCycleOptions) { self.options = options } @@ -455,7 +455,7 @@ public class DevCycleClient { return self } - public func options(_ options: DVCOptions) -> ClientBuilder { + public func options(_ options: DevCycleOptions) -> ClientBuilder { self.client.setOptions(options) return self } diff --git a/DevCycle/Models/DVCOptions.swift b/DevCycle/Models/DevCycleOptions.swift similarity index 88% rename from DevCycle/Models/DVCOptions.swift rename to DevCycle/Models/DevCycleOptions.swift index c946396..577259e 100644 --- a/DevCycle/Models/DVCOptions.swift +++ b/DevCycle/Models/DevCycleOptions.swift @@ -6,7 +6,7 @@ import Foundation -public class DVCOptions { +public class DevCycleOptions { var flushEventsIntervalMs: Int? var disableEventLogging: Bool? var logLevel: LogLevel = .error @@ -18,10 +18,10 @@ public class DVCOptions { var disableCustomEventLogging: Bool = false public class OptionsBuilder { - var options: DVCOptions + var options: DevCycleOptions init () { - self.options = DVCOptions() + self.options = DevCycleOptions() } public func flushEventsIntervalMs(_ interval: Int? = 10000) -> OptionsBuilder { @@ -70,9 +70,9 @@ public class DVCOptions { return self } - public func build() -> DVCOptions { + public func build() -> DevCycleOptions { let result = self.options - self.options = DVCOptions() + self.options = DevCycleOptions() return result } } @@ -81,3 +81,6 @@ public class DVCOptions { return OptionsBuilder() } } + +@available(*, deprecated, message: "Use DevCycleOptions") +public typealias DVCOptions = DevCycleOptions diff --git a/DevCycle/ObjC/ObjCDevCycleClient.swift b/DevCycle/ObjC/ObjCDevCycleClient.swift index f6e51c3..2cdec58 100644 --- a/DevCycle/ObjC/ObjCDevCycleClient.swift +++ b/DevCycle/ObjC/ObjCDevCycleClient.swift @@ -27,7 +27,7 @@ public class ObjCDevCycleClient: NSObject { public static func initialize( sdkKey: String, user: ObjCDevCycleUser, - options: ObjCOptions? + options: ObjCDevCycleOptions? ) -> ObjCDevCycleClient { return ObjCDevCycleClient( sdkKey: sdkKey, @@ -41,7 +41,7 @@ public class ObjCDevCycleClient: NSObject { public static func initialize( sdkKey: String, user: ObjCDevCycleUser, - options: ObjCOptions?, + options: ObjCDevCycleOptions?, onInitialized: ((Error?) -> Void)? ) -> ObjCDevCycleClient { return ObjCDevCycleClient( @@ -55,7 +55,7 @@ public class ObjCDevCycleClient: NSObject { init( sdkKey: String, user: ObjCDevCycleUser, - options: ObjCOptions?, + options: ObjCDevCycleOptions?, onInitialized: ((Error?) -> Void)? ) { do { diff --git a/DevCycle/ObjC/ObjCDVCOptions.swift b/DevCycle/ObjC/ObjCDevCycleOptions.swift similarity index 88% rename from DevCycle/ObjC/ObjCDVCOptions.swift rename to DevCycle/ObjC/ObjCDevCycleOptions.swift index bbcb747..ba1dc98 100644 --- a/DevCycle/ObjC/ObjCDVCOptions.swift +++ b/DevCycle/ObjC/ObjCDevCycleOptions.swift @@ -1,9 +1,7 @@ // -// ObjCDVCOptions.swift +// ObjCDevCycleOptions.swift // DevCycle // -// Copyright © 2022 Taplytics. All rights reserved. -// import Foundation @@ -14,8 +12,8 @@ public class ObjCLogLevel: NSObject { @objc public static let error = NSNumber(2) } -@objc(DVCOptions) -public class ObjCOptions: NSObject { +@objc(DevCycleOptions) +public class ObjCDevCycleOptions: NSObject { @objc public var flushEventsIntervalMs: NSNumber? @objc public var disableEventLogging: NSNumber? @objc public var logLevel: NSNumber? @@ -24,8 +22,8 @@ public class ObjCOptions: NSObject { @objc public var configCacheTTL: NSNumber? @objc public var disableRealtimeUpdates: NSNumber? - func buildDVCOptions() -> DVCOptions { - var optionsBuilder = DVCOptions.builder() + func buildDVCOptions() -> DevCycleOptions { + var optionsBuilder = DevCycleOptions.builder() if let flushEventsIntervalMs = self.flushEventsIntervalMs, let interval = flushEventsIntervalMs as? Int { optionsBuilder = optionsBuilder.flushEventsIntervalMs(interval) @@ -76,3 +74,6 @@ public class ObjCOptions: NSObject { } } +@available(*, deprecated, message: "Use DevCycleOptions") +@objc(DVCOptions) +public class ObjCDVCOptions: ObjCDevCycleOptions {} diff --git a/DevCycleTests/Models/DevCycleClientTests.swift b/DevCycleTests/Models/DevCycleClientTests.swift index 59ca39b..07a9ab6 100644 --- a/DevCycleTests/Models/DevCycleClientTests.swift +++ b/DevCycleTests/Models/DevCycleClientTests.swift @@ -78,7 +78,7 @@ class DevCycleClientTest: XCTestCase { } func testBuilderReturnsClientWithOptions() { - let options = DVCOptions.builder().disableEventLogging(false).flushEventsIntervalMs(100).build() + let options = DevCycleOptions.builder().disableEventLogging(false).flushEventsIntervalMs(100).build() let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).build(onInitialized: nil) XCTAssertNotNil(client) XCTAssertNotNil(client.options) @@ -136,7 +136,7 @@ class DevCycleClientTest: XCTestCase { func testFlushEventsWithOneEventInQueue() { let expectation = XCTestExpectation(description: "EventQueue publishes an event") - let options = DVCOptions.builder().flushEventsIntervalMs(100).build() + let options = DevCycleOptions.builder().flushEventsIntervalMs(100).build() let service = MockService() // will assert if publishEvents was called let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).service(service).build(onInitialized: nil) @@ -156,7 +156,7 @@ class DevCycleClientTest: XCTestCase { func testFlushEventsWithOneEventInQueueAndCallback() { let expectation = XCTestExpectation(description: "EventQueue publishes an event") - let options = DVCOptions.builder().flushEventsIntervalMs(100).build() + let options = DevCycleOptions.builder().flushEventsIntervalMs(100).build() let service = MockService() // will assert if publishEvents was called let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).service(service).build(onInitialized: nil) @@ -181,7 +181,7 @@ class DevCycleClientTest: XCTestCase { func testCloseFlushesRemainingEvents() { let expectation = XCTestExpectation(description: "Close flushes remaining events") - let options = DVCOptions.builder().flushEventsIntervalMs(10000).build() + let options = DevCycleOptions.builder().flushEventsIntervalMs(10000).build() let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).build(onInitialized: nil) let service = MockService() // will assert if publishEvents was called client.setup(service: service) @@ -451,7 +451,7 @@ class DevCycleClientTest: XCTestCase { func testDisableCustomEventLogging() { let expectation = XCTestExpectation(description: "test disableCustomEventLogging") - let options = DVCOptions.builder().disableCustomEventLogging(true).flushEventsIntervalMs(100).build() + let options = DevCycleOptions.builder().disableCustomEventLogging(true).flushEventsIntervalMs(100).build() let service = MockService() // will assert if publishEvents was called let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).service(service).build(onInitialized: nil) @@ -471,7 +471,7 @@ class DevCycleClientTest: XCTestCase { func testDisableAutomaticEventLogging() { let expectation = XCTestExpectation(description: "test disableAutomaticEventLogging") - let options = DVCOptions.builder().disableAutomaticEventLogging(true).flushEventsIntervalMs(10000).build() + let options = DevCycleOptions.builder().disableAutomaticEventLogging(true).flushEventsIntervalMs(10000).build() let service = MockService() // will assert if publishEvents was called let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).service(service).build(onInitialized: nil) diff --git a/DevCycleTests/Models/DVCOptionsTest.swift b/DevCycleTests/Models/DevCycleOptionsTest.swift similarity index 69% rename from DevCycleTests/Models/DVCOptionsTest.swift rename to DevCycleTests/Models/DevCycleOptionsTest.swift index 12a3062..8908980 100644 --- a/DevCycleTests/Models/DVCOptionsTest.swift +++ b/DevCycleTests/Models/DevCycleOptionsTest.swift @@ -1,21 +1,20 @@ // -// DVCUser.swift +// DevCycleOptionsTest.swift // DevCycleTests // -// import XCTest @testable import DevCycle -class DVCOptionsTest: XCTestCase { +class DevCycleOptionsTest: XCTestCase { func testOptionsAreNil() { - let options = DVCOptions() + let options = DevCycleOptions() XCTAssertNil(options.disableEventLogging) XCTAssertNil(options.flushEventsIntervalMs) } func testBuilderReturnsOptions() { - let options = DVCOptions.builder() + let options = DevCycleOptions.builder() .disableEventLogging(false) .flushEventsIntervalMs(1000) .enableEdgeDB(true) @@ -33,6 +32,17 @@ class DVCOptionsTest: XCTestCase { } func testBuilderReturnsOptionsAndSomeAreNil() { + let options = DevCycleOptions.builder() + .disableEventLogging(false) + .build() + XCTAssertNotNil(options) + XCTAssertNil(options.flushEventsIntervalMs) + XCTAssertFalse(options.disableEventLogging!) + XCTAssertFalse(options.enableEdgeDB) + XCTAssertFalse(options.disableRealtimeUpdates) + } + + func testDeprecatedDVCOptions { let options = DVCOptions.builder() .disableEventLogging(false) .build() From 59c0a58746c1573efe6d573dc1be2a8038cbd309 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Mon, 10 Jul 2023 15:26:15 -0400 Subject: [PATCH 04/11] rename DVCEvent to DevCycleEvent --- DevCycle.xcodeproj/project.pbxproj | 16 +++++----- DevCycle/DevCycleClient.swift | 2 +- .../{DVCEvent.swift => DevCycleEvent.swift} | 29 ++++++++++--------- DevCycle/Models/EventQueue.swift | 8 ++--- DevCycle/Networking/DevCycleService.swift | 6 ++-- DevCycle/ObjC/ObjCDevCycleClient.swift | 2 +- ...DVCEvent.swift => ObjCDevCycleEvent.swift} | 20 ++++++++----- DevCycleTests/Models/EventQueueTests.swift | 26 ++++++++++++----- DevCycleTests/Models/ThreadingTests.swift | 2 +- .../Utils/RequestConsolidatorTests.swift | 2 +- 10 files changed, 66 insertions(+), 47 deletions(-) rename DevCycle/Models/{DVCEvent.swift => DevCycleEvent.swift} (70%) rename DevCycle/ObjC/{ObjCDVCEvent.swift => ObjCDevCycleEvent.swift} (79%) diff --git a/DevCycle.xcodeproj/project.pbxproj b/DevCycle.xcodeproj/project.pbxproj index fe087fc..220051d 100644 --- a/DevCycle.xcodeproj/project.pbxproj +++ b/DevCycle.xcodeproj/project.pbxproj @@ -48,8 +48,8 @@ 52E693EA27567E2600B52375 /* DevCycleService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52E693E927567E2600B52375 /* DevCycleService.swift */; }; 52E693ED2756816A00B52375 /* DVCConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52E693EC2756816A00B52375 /* DVCConfig.swift */; }; 52E693F62758032500B52375 /* DevCycleServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52E693F52758032500B52375 /* DevCycleServiceTests.swift */; }; - D9341C12276967DE00BC753F /* DVCEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9341C11276967DE00BC753F /* DVCEvent.swift */; }; - D9341C14276A3C8A00BC753F /* ObjCDVCEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9341C13276A3C8A00BC753F /* ObjCDVCEvent.swift */; }; + D9341C12276967DE00BC753F /* DevCycleEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9341C11276967DE00BC753F /* DevCycleEvent.swift */; }; + D9341C14276A3C8A00BC753F /* ObjCDevCycleEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9341C13276A3C8A00BC753F /* ObjCDevCycleEvent.swift */; }; E66CF1C82901E9C7008734FD /* LDSwiftEventSource.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E66CF1C72901E9C7008734FD /* LDSwiftEventSource.xcframework */; }; E66CF1C92901E9C7008734FD /* LDSwiftEventSource.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E66CF1C72901E9C7008734FD /* LDSwiftEventSource.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; E673EFC7290093C400C2C4BE /* SSEConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = E673EFC6290093C400C2C4BE /* SSEConnection.swift */; }; @@ -123,8 +123,8 @@ 52E693E927567E2600B52375 /* DevCycleService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleService.swift; sourceTree = ""; }; 52E693EC2756816A00B52375 /* DVCConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCConfig.swift; sourceTree = ""; }; 52E693F52758032500B52375 /* DevCycleServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleServiceTests.swift; sourceTree = ""; }; - D9341C11276967DE00BC753F /* DVCEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DVCEvent.swift; sourceTree = ""; }; - D9341C13276A3C8A00BC753F /* ObjCDVCEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDVCEvent.swift; sourceTree = ""; }; + D9341C11276967DE00BC753F /* DevCycleEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DevCycleEvent.swift; sourceTree = ""; }; + D9341C13276A3C8A00BC753F /* ObjCDevCycleEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjCDevCycleEvent.swift; sourceTree = ""; }; E66CF1C72901E9C7008734FD /* LDSwiftEventSource.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = LDSwiftEventSource.xcframework; path = Carthage/Build/LDSwiftEventSource.xcframework; sourceTree = ""; }; E673EFC6290093C400C2C4BE /* SSEConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSEConnection.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -187,7 +187,7 @@ 5264A77A275E9A7E00FEDB43 /* ObjCDevCycleClient.swift */, 5264A780275EB7DC00FEDB43 /* ObjCDevCycleUser.swift */, 5264A78627626A2200FEDB43 /* ObjCErrors.swift */, - D9341C13276A3C8A00BC753F /* ObjCDVCEvent.swift */, + D9341C13276A3C8A00BC753F /* ObjCDevCycleEvent.swift */, 52A486752784A3E600DABA34 /* ObjCDevCycleOptions.swift */, 52A487022788C0FF00DABA34 /* ObjCUserConfig.swift */, ); @@ -289,7 +289,7 @@ 52E693EC2756816A00B52375 /* DVCConfig.swift */, 5276C9EF275E682B00B9A324 /* DevCycleOptions.swift */, 5264A78A2763F6D800FEDB43 /* UserConfig.swift */, - D9341C11276967DE00BC753F /* DVCEvent.swift */, + D9341C11276967DE00BC753F /* DevCycleEvent.swift */, 5264A7BC2769381500FEDB43 /* Cache.swift */, 52A9698F279F3AAA00D3A602 /* PlatformDetails.swift */, 0F2DD759279EFA6B00540C9D /* CustomData.swift */, @@ -425,7 +425,7 @@ 5264A781275EB7DC00FEDB43 /* ObjCDevCycleUser.swift in Sources */, 52A96990279F3AAA00D3A602 /* PlatformDetails.swift in Sources */, 52A48707278C9BE200DABA34 /* Log.swift in Sources */, - D9341C14276A3C8A00BC753F /* ObjCDVCEvent.swift in Sources */, + D9341C14276A3C8A00BC753F /* ObjCDevCycleEvent.swift in Sources */, 5226DF06290C588900630745 /* NotificationNames.swift in Sources */, 5264A77B275E9A7E00FEDB43 /* ObjCDevCycleClient.swift in Sources */, 52E693ED2756816A00B52375 /* DVCConfig.swift in Sources */, @@ -439,7 +439,7 @@ 52A487032788C0FF00DABA34 /* ObjCUserConfig.swift in Sources */, 529CE32328DCBEC2009AB137 /* RequestConsolidator.swift in Sources */, 5268DB6627501D6000D17A40 /* DevCycleClient.swift in Sources */, - D9341C12276967DE00BC753F /* DVCEvent.swift in Sources */, + D9341C12276967DE00BC753F /* DevCycleEvent.swift in Sources */, 524F4E60276BDDBD00CB9069 /* DVCVariable.swift in Sources */, 5276C9F0275E682B00B9A324 /* DevCycleOptions.swift in Sources */, 524D58242770F78B00D7CC56 /* ObjCDVCVariable.swift in Sources */, diff --git a/DevCycle/DevCycleClient.swift b/DevCycle/DevCycleClient.swift index d8d2503..0fc3d20 100644 --- a/DevCycle/DevCycleClient.swift +++ b/DevCycle/DevCycleClient.swift @@ -384,7 +384,7 @@ public class DevCycleClient { return self.config?.userConfig?.variables ?? [:] } - public func track(_ event: DVCEvent) { + public func track(_ event: DevCycleEvent) { if (self.closed) { Log.error("DevCycleClient is closed, cannot log new events.") return diff --git a/DevCycle/Models/DVCEvent.swift b/DevCycle/Models/DevCycleEvent.swift similarity index 70% rename from DevCycle/Models/DVCEvent.swift rename to DevCycle/Models/DevCycleEvent.swift index 52b1842..ab18fe6 100644 --- a/DevCycle/Models/DVCEvent.swift +++ b/DevCycle/Models/DevCycleEvent.swift @@ -10,7 +10,7 @@ enum EventError: Error { case MissingEventType } -public class DVCEvent { +public class DevCycleEvent { var type: String? var target: String? var clientDate: Date? @@ -26,10 +26,10 @@ public class DVCEvent { } public class EventBuilder { - var event: DVCEvent + var event: DevCycleEvent init () { - self.event = DVCEvent(type: nil, target: nil, clientDate: nil, value: nil, metaData: nil) + self.event = DevCycleEvent(type: nil, target: nil, clientDate: nil, value: nil, metaData: nil) } public func type(_ type: String) -> EventBuilder { @@ -57,12 +57,12 @@ public class DVCEvent { return self } - public func build() throws -> DVCEvent { + public func build() throws -> DevCycleEvent { guard let _ = self.event.type else { throw EventError.MissingEventType } let result = self.event - self.event = DVCEvent(type: nil, target: nil, clientDate: nil, value: nil, metaData: nil) + self.event = DevCycleEvent(type: nil, target: nil, clientDate: nil, value: nil, metaData: nil) return result } } @@ -72,13 +72,16 @@ public class DVCEvent { } } +@available(*, deprecated, message: "Use DevCycleEvent") +public typealias DVCEvent = DevCycleEvent + enum DVCEventTypes: String { case VariableDefaulted, VariableEvaluated } struct DVCAggregateEvents { - var variableDefaulted: [String:DVCEvent] - var variableEvaluated: [String:DVCEvent] + var variableDefaulted: [String:DevCycleEvent] + var variableEvaluated: [String:DevCycleEvent] init () { self.variableDefaulted = [:] @@ -90,23 +93,23 @@ struct DVCAggregateEvents { if let variableEvaluatedEvent = self.variableEvaluated[variableKey] { variableEvaluatedEvent.value = variableEvaluatedEvent.value! + 1 } else { - self.variableEvaluated[variableKey] = DVCEvent(type: "variableEvaluated", target: variableKey, clientDate: nil, value: 1, metaData: nil) + self.variableEvaluated[variableKey] = DevCycleEvent(type: "variableEvaluated", target: variableKey, clientDate: nil, value: 1, metaData: nil) } } else { if let variableDefaultedEvent = self.variableDefaulted[variableKey] { variableDefaultedEvent.value = variableDefaultedEvent.value! + 1 } else { - self.variableDefaulted[variableKey] = DVCEvent(type: "variableDefaulted", target: variableKey, clientDate: nil, value: 1, metaData: nil) + self.variableDefaulted[variableKey] = DevCycleEvent(type: "variableDefaulted", target: variableKey, clientDate: nil, value: 1, metaData: nil) } } } - func getAllAggregateEvents() -> [DVCEvent] { - var allAggregateEvents: [DVCEvent] = [] - allAggregateEvents.append(contentsOf: self.variableDefaulted.map { (_: String, defaultedEvent: DVCEvent) -> DVCEvent in + func getAllAggregateEvents() -> [DevCycleEvent] { + var allAggregateEvents: [DevCycleEvent] = [] + allAggregateEvents.append(contentsOf: self.variableDefaulted.map { (_: String, defaultedEvent: DevCycleEvent) -> DevCycleEvent in defaultedEvent }) - allAggregateEvents.append(contentsOf: self.variableEvaluated.map { (_: String, evaluatedEvent: DVCEvent) -> DVCEvent in + allAggregateEvents.append(contentsOf: self.variableEvaluated.map { (_: String, evaluatedEvent: DevCycleEvent) -> DevCycleEvent in evaluatedEvent }) return allAggregateEvents diff --git a/DevCycle/Models/EventQueue.swift b/DevCycle/Models/EventQueue.swift index 6adaa5c..accdf89 100644 --- a/DevCycle/Models/EventQueue.swift +++ b/DevCycle/Models/EventQueue.swift @@ -13,17 +13,17 @@ enum EventQueueErrors: Error { class EventQueue { var eventDispatchQueue = DispatchQueue(label: "com.devcycle.EventQueue") - var events: [DVCEvent] = [] + var events: [DevCycleEvent] = [] var aggregateEventQueue: DVCAggregateEvents = DVCAggregateEvents() var flushing: Bool = false - func queue(_ event: DVCEvent) { + func queue(_ event: DevCycleEvent) { eventDispatchQueue.async { self.events.append(event) } } - func queue(_ events: [DVCEvent]) { + func queue(_ events: [DevCycleEvent]) { eventDispatchQueue.async { self.events.append(contentsOf: events) } @@ -36,7 +36,7 @@ class EventQueue { return } - var eventsToFlush: [DVCEvent] = [] + var eventsToFlush: [DevCycleEvent] = [] eventDispatchQueue.sync { self.flushing = true eventsToFlush = self.events diff --git a/DevCycle/Networking/DevCycleService.swift b/DevCycle/Networking/DevCycleService.swift index 4b9a15f..9444973 100644 --- a/DevCycle/Networking/DevCycleService.swift +++ b/DevCycle/Networking/DevCycleService.swift @@ -63,7 +63,7 @@ struct RequestParams { protocol DevCycleServiceProtocol { func getConfig(user:DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) - func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) + func publishEvents(events: [DevCycleEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) func saveEntity(user:DevCycleUser, completion: @escaping SaveEntityCompletionHandler) func makeRequest(request: URLRequest, completion: @escaping CompletionHandler) } @@ -90,7 +90,7 @@ class DevCycleService: DevCycleServiceProtocol { requestConsolidator.queue(request: configRequest, user: user, callback: completion) } - func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DevCycleEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { var eventsRequest = createEventsRequest() let userEncoder = JSONEncoder() userEncoder.dateEncodingStrategy = .iso8601 @@ -266,7 +266,7 @@ class DevCycleService: DevCycleServiceProtocol { return urlComponents } - private func generateEventPayload(_ events: [DVCEvent], _ userId: String, _ featureVariables: [String:String]?) -> [[String:Any]] { + private func generateEventPayload(_ events: [DevCycleEvent], _ userId: String, _ featureVariables: [String:String]?) -> [[String:Any]] { var eventsJSON: [[String:Any]] = [] let formatter = ISO8601DateFormatter() diff --git a/DevCycle/ObjC/ObjCDevCycleClient.swift b/DevCycle/ObjC/ObjCDevCycleClient.swift index 2cdec58..b327bfa 100644 --- a/DevCycle/ObjC/ObjCDevCycleClient.swift +++ b/DevCycle/ObjC/ObjCDevCycleClient.swift @@ -198,7 +198,7 @@ public class ObjCDevCycleClient: NSObject { } @objc(track:err:) - public func track(_ event: ObjCDVCEvent) throws { + public func track(_ event: ObjCDevCycleEvent) throws { guard let client = self.client else { return } let dvcEvent = try event.buildDVCEvent() client.track(dvcEvent) diff --git a/DevCycle/ObjC/ObjCDVCEvent.swift b/DevCycle/ObjC/ObjCDevCycleEvent.swift similarity index 79% rename from DevCycle/ObjC/ObjCDVCEvent.swift rename to DevCycle/ObjC/ObjCDevCycleEvent.swift index e5418cb..85fd3d2 100644 --- a/DevCycle/ObjC/ObjCDVCEvent.swift +++ b/DevCycle/ObjC/ObjCDevCycleEvent.swift @@ -6,8 +6,8 @@ import Foundation -@objc(DVCEvent) -public class ObjCDVCEvent: NSObject { +@objc(DevCycleEvent) +public class ObjCDevCycleEvent: NSObject { @objc var type: String? @objc var target: String? @objc var clientDate: NSDate? @@ -15,30 +15,30 @@ public class ObjCDVCEvent: NSObject { @objc var metaData: NSDictionary? @objc(initializeWithType:) - public static func initialize(type: String) -> ObjCDVCEvent { + public static func initialize(type: String) -> ObjCDevCycleEvent { return self.initialize(type: type, target: nil, value: nil) } @objc(initializeWithType:target:) - public static func initialize(type: String, target: String?) -> ObjCDVCEvent { + public static func initialize(type: String, target: String?) -> ObjCDevCycleEvent { return self.initialize(type: type, target: target, value: nil) } @objc(initializeWithType:target:value:) - public static func initialize(type: String, target: String?, value: NSNumber?) -> ObjCDVCEvent { - let builder = ObjCDVCEvent() + public static func initialize(type: String, target: String?, value: NSNumber?) -> ObjCDevCycleEvent { + let builder = ObjCDevCycleEvent() builder.type = type builder.target = target builder.value = value return builder } - func buildDVCEvent() throws -> DVCEvent { + func buildDVCEvent() throws -> DevCycleEvent { if self.type == nil { throw ObjCEventErrors.MissingEventType } - var eventBuilder = DVCEvent.builder() + var eventBuilder = DevCycleEvent.builder() if let eventType = self.type { eventBuilder = eventBuilder.type(eventType) } @@ -63,3 +63,7 @@ public class ObjCDVCEvent: NSObject { } } } + +@available(*, deprecated, message: "Use DVCEvent") +@objc(DVCEvent) +public class ObjCDVCEvent: ObjCDevCycleEvent {} diff --git a/DevCycleTests/Models/EventQueueTests.swift b/DevCycleTests/Models/EventQueueTests.swift index f7a4cf6..5aeaabe 100644 --- a/DevCycleTests/Models/EventQueueTests.swift +++ b/DevCycleTests/Models/EventQueueTests.swift @@ -10,11 +10,23 @@ import XCTest class EventQueueTests: XCTestCase { + func testDeprecatedDVCEvent() { + let eventQueue = EventQueue() + let expectation = XCTestExpectation(description: "Events are serially queued") + let event1 = try! DVCEvent.builder().type("dvcEvent").build() + eventQueue.queue(event1) + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { + XCTAssert(eventQueue.events.first?.type == "dvcEvent") + expectation.fulfill() + } + wait(for: [expectation], timeout: 3.0) + } + func testSerialOrderOfEvents() { let eventQueue = EventQueue() let expectation = XCTestExpectation(description: "Events are serially queued") - let event1 = try! DVCEvent.builder().type("event1").build() - let event2 = try! DVCEvent.builder().type("event2").build() + let event1 = try! DevCycleEvent.builder().type("event1").build() + let event2 = try! DevCycleEvent.builder().type("event2").build() eventQueue.queue(event1) eventQueue.queue(event2) DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { @@ -28,7 +40,7 @@ class EventQueueTests: XCTestCase { func testFlushCancelsIfFlushInProgress() { let eventQueue = EventQueue() let expectation = XCTestExpectation(description: "Subsequent flushes are cancelled") - let event = try! DVCEvent.builder().type("event1").build() + let event = try! DevCycleEvent.builder().type("event1").build() let user = try! DevCycleUser.builder().userId("user1").build() eventQueue.queue(event) eventQueue.flush(service: MockService(), user: user, callback: nil) @@ -42,7 +54,7 @@ class EventQueueTests: XCTestCase { func testFlushRequeuesIfErrorRetryable() { let eventQueue = EventQueue() let expectation = XCTestExpectation(description: "Flush Requeues Retryable Event") - let event = try! DVCEvent.builder().type("event1").build() + let event = try! DevCycleEvent.builder().type("event1").build() let user = try! DevCycleUser.builder().userId("user1").build() eventQueue.queue(event) eventQueue.flush(service: MockWithErrorCodeService(errorCode: 500), user: user, callback: nil) @@ -55,7 +67,7 @@ class EventQueueTests: XCTestCase { func testFlushDoesntRequeueIfErrorNotRetryable() { let eventQueue = EventQueue() let expectation = XCTestExpectation(description: "Subsequent flushes are cancelled") - let event = try! DVCEvent.builder().type("event1").build() + let event = try! DevCycleEvent.builder().type("event1").build() let user = try! DevCycleUser.builder().userId("user1").build() eventQueue.queue(event) eventQueue.flush(service: MockWithErrorCodeService(errorCode: 403), user: user, callback: nil) @@ -69,7 +81,7 @@ class EventQueueTests: XCTestCase { private class MockService: DevCycleServiceProtocol { func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} - func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DevCycleEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { completion((nil, nil, nil)) @@ -88,7 +100,7 @@ class MockWithErrorCodeService: DevCycleServiceProtocol { } func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} - func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DevCycleEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { let error = NSError(domain: "api.devcycle.com", code: self.errorCode) DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { completion((nil, nil, error)) diff --git a/DevCycleTests/Models/ThreadingTests.swift b/DevCycleTests/Models/ThreadingTests.swift index 28bcfbb..59cdce8 100644 --- a/DevCycleTests/Models/ThreadingTests.swift +++ b/DevCycleTests/Models/ThreadingTests.swift @@ -43,7 +43,7 @@ final class ThreadingTests: XCTestCase { private class MockService: DevCycleServiceProtocol { func getConfig(user: DevCycleUser, enableEdgeDB: Bool, extraParams: RequestParams?, completion: @escaping ConfigCompletionHandler) {} - func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) {} + func publishEvents(events: [DevCycleEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) {} func saveEntity(user: DevCycleUser, completion: @escaping SaveEntityCompletionHandler) {} diff --git a/DevCycleTests/Utils/RequestConsolidatorTests.swift b/DevCycleTests/Utils/RequestConsolidatorTests.swift index 6e2e3d6..499b306 100644 --- a/DevCycleTests/Utils/RequestConsolidatorTests.swift +++ b/DevCycleTests/Utils/RequestConsolidatorTests.swift @@ -65,7 +65,7 @@ extension RequestConsolidatorTests { XCTAssert(true) } - func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DevCycleEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { XCTAssert(true) } From 2e95fa1c7e25030e22366254db4b9baec0e641a5 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Mon, 10 Jul 2023 15:38:33 -0400 Subject: [PATCH 05/11] fix: update DevCycle iOS ObjC example app --- .../DevCycle-iOS-Example-App-ObjC/AppDelegate.m | 12 ++++++------ .../DevCycleManager.h | 5 +++-- .../DevCycleManager.m | 10 +++++----- .../DevCycle-iOS-Example-App-ObjC/ViewController.m | 14 +++++++------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/AppDelegate.m b/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/AppDelegate.m index ded99c4..6840816 100644 --- a/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/AppDelegate.m +++ b/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/AppDelegate.m @@ -19,7 +19,7 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // TODO: Set SDK Key in DevCycleManager.m - DVCUser *user = [DVCUser initializeWithUserId:@"test_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"test_user"]; user.customData = @{ @"key": @"value", @"num": @610.610, @@ -27,25 +27,25 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( }; [[DevCycleManager sharedManager] initialize:user onInitialized:^(NSError * _Nonnull err) { - DVCClient *client = [[DevCycleManager sharedManager] client]; + DevCycleClient *client = [[DevCycleManager sharedManager] client]; if (err || client == nil) { return NSLog(@"Error starting DevCycle: %@", err.description); } NSString *stringValue = [client stringVariableValueWithKey:@"string_key" defaultValue:@"default"]; NSNumber *numValue = [client numberVariableValueWithKey:@"num_key" defaultValue:@610]; - Bool boolValue = [client boolVariableValueWithKey:@"bool_key" defaultValue:NO]; + BOOL boolValue = [client boolVariableValueWithKey:@"bool_key" defaultValue:NO]; DVCVariable *jsonVar = [[client jsonVariableWithKey:@"json_key" defaultValue:@{@"key": @"value"}] onUpdateWithHandler:^(id _Nonnull value) { NSLog(@"json_key value updated: %@", value); }]; - NSLog(@"DVC Var Values\n string: %@\n num: %@\n bool: %@\n json: %@", stringValue, numValue, boolValue, jsonVar.value); + NSLog(@"DevCycle Variable Values\n string: %@\n num: %@\n bool: %@\n json: %@", stringValue, numValue, boolValue, jsonVar.value); NSDictionary *allFeatures = [client allFeatures]; - NSLog(@"DVC All Features: %@", allFeatures); + NSLog(@"DevCycle All Features: %@", allFeatures); NSDictionary *allVariables = [client allVariables]; - NSLog(@"DVC All Variables: %@", allVariables); + NSLog(@"DevCycle All Variables: %@", allVariables); }]; return YES; diff --git a/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/DevCycleManager.h b/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/DevCycleManager.h index bf46278..1dba3f1 100644 --- a/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/DevCycleManager.h +++ b/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/DevCycleManager.h @@ -11,10 +11,11 @@ NS_ASSUME_NONNULL_BEGIN @interface DevCycleManager : NSObject -@property (atomic, readonly) DVCClient * _Nullable client; +@property (atomic, readonly) DevCycleClient * _Nullable client; + (id)sharedManager; -- (DVCClient*)initialize:(DVCUser *)user onInitialized:(void (^_Nullable)(NSError*))onInitialized; + +- (DevCycleClient*)initialize:(DevCycleUser *)user onInitialized:(void (^_Nullable)(NSError*))onInitialized; @end diff --git a/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/DevCycleManager.m b/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/DevCycleManager.m index dc7d90e..8da4399 100644 --- a/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/DevCycleManager.m +++ b/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/DevCycleManager.m @@ -9,13 +9,13 @@ @interface DevCycleManager() -@property (atomic) DVCClient * _Nullable client; +@property (atomic) DevCycleClient* _Nullable client; @end @implementation DevCycleManager -static NSString *const DEVELOPMENT_KEY = @""; +static NSString *const DEVCYCLE_KEY = @""; + (id)sharedManager { static DevCycleManager *sharedMyManager = nil; @@ -33,13 +33,13 @@ - (id)init { return self; } -- (DVCClient*)initialize:(DVCUser *)user onInitialized:(void (^_Nullable)(NSError*))onInitialized { +- (DevCycleClient*)initialize:(DevCycleUser *)user onInitialized:(void (^_Nullable)(NSError*))onInitialized { NSError *err = nil; - DVCOptions *options = [[DVCOptions alloc] init]; + DevCycleOptions *options = [[DevCycleOptions alloc] init]; // options.logLevel = LogLevel.debug; - self.client = [DVCClient initialize:DEVELOPMENT_KEY + self.client = [DevCycleClient initialize:DEVCYCLE_KEY user:user options:options onInitialized:^(NSError * _Nullable error) { diff --git a/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/ViewController.m b/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/ViewController.m index aed9cf0..ace080c 100644 --- a/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/ViewController.m +++ b/Examples/DevCycle-iOS-Example-App-ObjC/DevCycle-iOS-Example-App-ObjC/ViewController.m @@ -11,7 +11,7 @@ @interface ViewController () @property (weak, nonatomic) IBOutlet UIButton *loginButton; -@property (strong) DVCClient *client; +@property (atomic) DevCycleClient *client; @property BOOL loggedIn; @end @@ -22,13 +22,13 @@ - (IBAction)loginButtonPressed:(id)sender { __weak typeof(self) weakSelf = self; if (self.loggedIn) { [self.client resetUser:^(NSError *error, NSDictionary *variables) { - NSLog(@"Reset User!"); + NSLog(@"DevCycle: Reset User!"); NSLog(@"%@", variables); weakSelf.loggedIn = NO; [weakSelf.loginButton setTitle:@"Log In" forState:UIControlStateNormal]; }]; } else { - DVCUser *user = [DVCUser initializeWithUserId:@"my-user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my-user"]; user.userId = @"my-user"; user.name = @"My Name"; user.language = @"en"; @@ -37,7 +37,7 @@ - (IBAction)loginButtonPressed:(id)sender { [self.client identifyUser:user callback:^(NSError *error, NSDictionary *variables) { if (error) { - return NSLog(@"Error calling DVCClient identifyUser:callback: %@", error); + return NSLog(@"Error calling DevCycleClient identifyUser:callback: %@", error); } NSLog(@"Identified User!"); NSLog(@"%@", variables); @@ -49,12 +49,12 @@ - (IBAction)loginButtonPressed:(id)sender { - (IBAction)track:(id)sender { NSError *err = nil; - DVCEvent *event = [DVCEvent initializeWithType:@"my-event"]; + DevCycleEvent *event = [DevCycleEvent initializeWithType:@"my-event"]; [self.client track:event err:&err]; if (err) { - NSLog(@"Error calling DVCClient track:err: %@", err); + NSLog(@"Error calling DevCycleClient track:err: %@", err); } else { - NSLog(@"Tracked event to DVC"); + NSLog(@"Tracked event to DevCycle"); } } From 44e01d3e6308ce9899a0a6c400b7e7505ae47185 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Mon, 10 Jul 2023 15:41:57 -0400 Subject: [PATCH 06/11] fix: updated iOS Swift example app --- .../DevCycle-iOS-Example-App-Swift/AppDelegate.swift | 2 +- .../DevCycleManager.swift | 10 +++++----- .../ViewController.swift | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/AppDelegate.swift b/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/AppDelegate.swift index ca987d0..cdf35ce 100644 --- a/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/AppDelegate.swift +++ b/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // TODO: Set SDK KEY in DevCycleManager.swift // create anonymous user - let user = try? DVCUser.builder() + let user = try? DevCycleUser.builder() .isAnonymous(true) .build() diff --git a/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/DevCycleManager.swift b/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/DevCycleManager.swift index 0f00b40..13027a3 100644 --- a/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/DevCycleManager.swift +++ b/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/DevCycleManager.swift @@ -8,20 +8,20 @@ import Foundation import DevCycle struct DevCycleKeys { - static var DEVELOPMENT = "" + static var DEVELOPMENT = "" } class DevCycleManager { - var client: DVCClient? + var client: DevCycleClient? static let shared = DevCycleManager() - func initialize(user: DVCUser) { - let options = DVCOptions.builder() + func initialize(user: DevCycleUser) { + let options = DevCycleOptions.builder() // .logLevel(.debug) .build() - guard let client = try? DVCClient.builder() + guard let client = try? DevCycleClient.builder() .sdkKey(DevCycleKeys.DEVELOPMENT) .user(user) .options(options) diff --git a/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/ViewController.swift b/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/ViewController.swift index 0b81a96..d852994 100644 --- a/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/ViewController.swift +++ b/Examples/DevCycle-iOS-Example-App-Swift/DevCycle-iOS-Example-App-Swift/ViewController.swift @@ -13,7 +13,7 @@ class ViewController: UIViewController { @IBOutlet weak var loginButton: UIButton! var loggedIn: Bool = false - var client: DVCClient? + var client: DevCycleClient? var titleHeaderVar: DVCVariable? var loginCtaVar: DVCVariable? @@ -56,7 +56,7 @@ class ViewController: UIViewController { print("Variables: \(String(describing: variables))") } } else { - let user = try? DVCUser.builder() + let user = try? DevCycleUser.builder() .userId("my-user1") .email("my-email@email.com") .country("CA") @@ -93,7 +93,7 @@ class ViewController: UIViewController { @IBAction func track(_ sender: Any) { guard let client = self.client else { return } - let event = try! DVCEvent.builder() + let event = try! DevCycleEvent.builder() .type("my_event") .target("my_target") .value(3) @@ -101,7 +101,7 @@ class ViewController: UIViewController { .clientDate(Date()) .build() client.track(event) - print("Tracked event to DVC") + print("Tracked event to DevCycle") } @IBAction func logAllFeatures(_ sender: Any) { From 62173bc20e911feea7fe00c2294d041995833460 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Mon, 10 Jul 2023 15:59:56 -0400 Subject: [PATCH 07/11] fix: update macOS example app --- .../DevCycle-macOS-Example-App/AppDelegate.swift | 2 +- .../DevCycle-macOS-Example-App/DevCycleManager.swift | 10 +++++----- .../DevCycle-macOS-Example-App/ViewController.swift | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/AppDelegate.swift b/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/AppDelegate.swift index 53fefef..2f4a1bf 100644 --- a/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/AppDelegate.swift +++ b/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { // Insert code here to initialize your application // create anonymous user - let user = try? DVCUser.builder() + let user = try? DevCycleUser.builder() .isAnonymous(true) .build() diff --git a/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/DevCycleManager.swift b/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/DevCycleManager.swift index 57c5c01..03ed4e7 100644 --- a/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/DevCycleManager.swift +++ b/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/DevCycleManager.swift @@ -7,20 +7,20 @@ import Foundation import DevCycle struct DevCycleKeys { - static var DEVELOPMENT = "" + static var DEVELOPMENT = "" } class DevCycleManager { - var client: DVCClient? + var client: DevCycleClient? static let shared = DevCycleManager() - func initialize(user: DVCUser) { - let options = DVCOptions.builder() + func initialize(user: DevCycleUser) { + let options = DevCycleOptions.builder() .logLevel(.debug) .build() - guard let client = try? DVCClient.builder() + guard let client = try? DevCycleClient.builder() .sdkKey(DevCycleKeys.DEVELOPMENT) .user(user) .options(options) diff --git a/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/ViewController.swift b/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/ViewController.swift index 69d5e5c..41302e8 100644 --- a/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/ViewController.swift +++ b/Examples/DevCycle-MacOS-Example-App/DevCycle-macOS-Example-App/ViewController.swift @@ -12,7 +12,7 @@ class ViewController: NSViewController { @IBOutlet weak var loginButton: NSButton! var loggedIn: Bool = false - var client: DVCClient? + var client: DevCycleClient? var titleHeaderVar: DVCVariable? var loginCtaVar: DVCVariable? @@ -66,7 +66,7 @@ class ViewController: NSViewController { print("Variables: \(String(describing: variables))") } } else { - let user = try? DVCUser.builder() + let user = try? DevCycleUser.builder() .userId("my-user1") .email("my-email@email.com") .country("CA") @@ -103,7 +103,7 @@ class ViewController: NSViewController { @IBAction func track(_ sender: Any) { guard let client = self.client else { return } - let event = try! DVCEvent.builder() + let event = try! DevCycleEvent.builder() .type("my_event") .target("my_target") .value(3) @@ -111,7 +111,7 @@ class ViewController: NSViewController { .clientDate(Date()) .build() client.track(event) - print("Tracked event to DVC") + print("Tracked event to DevCycle") } @IBAction func logAllFeatures(_ sender: Any) { From eb10b978d5f1f8f3c6f934835fe1fdd05e491046 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Mon, 10 Jul 2023 16:06:23 -0400 Subject: [PATCH 08/11] fix: update tvOS example app --- .../DevCycle-tvOS-Example-App/AppDelegate.swift | 2 +- .../DevCycle-tvOS-Example-App/DevCycleManager.swift | 10 +++++----- .../DevCycle-tvOS-Example-App/ViewController.swift | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/AppDelegate.swift b/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/AppDelegate.swift index 4a03983..b3d4a48 100644 --- a/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/AppDelegate.swift +++ b/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // create anonymous user - let user = try? DVCUser.builder() + let user = try? DevCycleUser.builder() .isAnonymous(true) .build() diff --git a/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/DevCycleManager.swift b/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/DevCycleManager.swift index 57c5c01..03ed4e7 100644 --- a/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/DevCycleManager.swift +++ b/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/DevCycleManager.swift @@ -7,20 +7,20 @@ import Foundation import DevCycle struct DevCycleKeys { - static var DEVELOPMENT = "" + static var DEVELOPMENT = "" } class DevCycleManager { - var client: DVCClient? + var client: DevCycleClient? static let shared = DevCycleManager() - func initialize(user: DVCUser) { - let options = DVCOptions.builder() + func initialize(user: DevCycleUser) { + let options = DevCycleOptions.builder() .logLevel(.debug) .build() - guard let client = try? DVCClient.builder() + guard let client = try? DevCycleClient.builder() .sdkKey(DevCycleKeys.DEVELOPMENT) .user(user) .options(options) diff --git a/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/ViewController.swift b/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/ViewController.swift index 145b134..5891841 100644 --- a/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/ViewController.swift +++ b/Examples/DevCycle-tvOS-Example-App/DevCycle-tvOS-Example-App/ViewController.swift @@ -12,7 +12,7 @@ class ViewController: UIViewController { @IBOutlet weak var loginButton: UIButton! var loggedIn: Bool = false - var client: DVCClient? + var client: DevCycleClient? var titleHeaderVar: DVCVariable? var loginCtaVar: DVCVariable? @@ -55,7 +55,7 @@ class ViewController: UIViewController { print("Variables: \(String(describing: variables))") } } else { - let user = try? DVCUser.builder() + let user = try? DevCycleUser.builder() .userId("my-user1") .email("my-email@email.com") .country("CA") @@ -92,7 +92,7 @@ class ViewController: UIViewController { @IBAction func track(_ sender: Any) { guard let client = self.client else { return } - let event = try! DVCEvent.builder() + let event = try! DevCycleEvent.builder() .type("my_event") .target("my_target") .value(3) @@ -100,7 +100,7 @@ class ViewController: UIViewController { .clientDate(Date()) .build() client.track(event) - print("Tracked event to DVC") + print("Tracked event to DevCycle") } @IBAction func logAllFeatures(_ sender: Any) { From 4bbffbdd3c9d7eff4af92960def4d17a9f5fc313 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Tue, 11 Jul 2023 10:21:29 -0400 Subject: [PATCH 09/11] fix: DVCEvent cleanup --- DevCycle/Models/DevCycleEvent.swift | 2 +- DevCycle/ObjC/ObjCDevCycleClient.swift | 2 +- DevCycle/ObjC/ObjCDevCycleEvent.swift | 8 +++---- .../Models/DevCycleClientTests.swift | 24 +++++++++---------- .../Models/DevCycleOptionsTest.swift | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/DevCycle/Models/DevCycleEvent.swift b/DevCycle/Models/DevCycleEvent.swift index ab18fe6..7a1a25d 100644 --- a/DevCycle/Models/DevCycleEvent.swift +++ b/DevCycle/Models/DevCycleEvent.swift @@ -1,5 +1,5 @@ // -// DVCEvent.swift +// DevCycleEvent.swift // DevCycle // // diff --git a/DevCycle/ObjC/ObjCDevCycleClient.swift b/DevCycle/ObjC/ObjCDevCycleClient.swift index b327bfa..4b79268 100644 --- a/DevCycle/ObjC/ObjCDevCycleClient.swift +++ b/DevCycle/ObjC/ObjCDevCycleClient.swift @@ -200,7 +200,7 @@ public class ObjCDevCycleClient: NSObject { @objc(track:err:) public func track(_ event: ObjCDevCycleEvent) throws { guard let client = self.client else { return } - let dvcEvent = try event.buildDVCEvent() + let dvcEvent = try event.buildDevCycleEvent() client.track(dvcEvent) } diff --git a/DevCycle/ObjC/ObjCDevCycleEvent.swift b/DevCycle/ObjC/ObjCDevCycleEvent.swift index 85fd3d2..42a6ab3 100644 --- a/DevCycle/ObjC/ObjCDevCycleEvent.swift +++ b/DevCycle/ObjC/ObjCDevCycleEvent.swift @@ -1,5 +1,5 @@ // -// ObjCDVCEvent.swift +// ObjCDevCycleEvent.swift // DevCycle // // @@ -33,7 +33,7 @@ public class ObjCDevCycleEvent: NSObject { return builder } - func buildDVCEvent() throws -> DevCycleEvent { + func buildDevCycleEvent() throws -> DevCycleEvent { if self.type == nil { throw ObjCEventErrors.MissingEventType } @@ -58,12 +58,12 @@ public class ObjCDevCycleEvent: NSObject { do { return try eventBuilder.build() } catch { - Log.error("Error building DVCEvent: \(error)", tags: ["event", "build"]) + Log.error("Error building DevCycleEvent: \(error)", tags: ["event", "build"]) throw error } } } -@available(*, deprecated, message: "Use DVCEvent") +@available(*, deprecated, message: "Use DevCycleEvent") @objc(DVCEvent) public class ObjCDVCEvent: ObjCDevCycleEvent {} diff --git a/DevCycleTests/Models/DevCycleClientTests.swift b/DevCycleTests/Models/DevCycleClientTests.swift index 07a9ab6..9362087 100644 --- a/DevCycleTests/Models/DevCycleClientTests.swift +++ b/DevCycleTests/Models/DevCycleClientTests.swift @@ -87,10 +87,10 @@ class DevCycleClientTest: XCTestCase { client.close(callback: nil) } - func testTrackWithValidDVCEventNoOptionals() { + func testTrackWithValidDevCycleEventNoOptionals() { let expectation = XCTestExpectation(description: "EventQueue has one event") let client = DevCycleClient() - let event: DVCEvent = try! DVCEvent.builder().type("test").build() + let event: DevCycleEvent = try! DevCycleEvent.builder().type("test").build() client.track(event) @@ -102,11 +102,11 @@ class DevCycleClientTest: XCTestCase { wait(for: [expectation], timeout: 1.0) } - func testTrackWithValidDVCEventWithAllParamsDefined() { + func testTrackWithValidDevCycleEventWithAllParamsDefined() { let expectation = XCTestExpectation(description: "EventQueue has one fully defined event") let client = DevCycleClient() let metaData: [String:Any] = ["test1": "key", "test2": 2, "test3": false] - let event: DVCEvent = try! DVCEvent.builder().type("test").target("test").clientDate(Date()).value(1).metaData(metaData).build() + let event: DevCycleEvent = try! DevCycleEvent.builder().type("test").target("test").clientDate(Date()).value(1).metaData(metaData).build() client.track(event) @@ -118,11 +118,11 @@ class DevCycleClientTest: XCTestCase { wait(for: [expectation], timeout: 1.0) } - func testTrackWithValidDVCEventWithAllParamsDefinedAndDoubleValue() { + func testTrackWithValidDevCycleEventWithAllParamsDefinedAndDoubleValue() { let expectation = XCTestExpectation(description: "EventQueue has one fully defined event") let client = DevCycleClient() let metaData: [String:Any] = ["test1": "key", "test2": 2, "test3": false] - let event: DVCEvent = try! DVCEvent.builder().type("test").target("test").clientDate(Date()).value(364.25).metaData(metaData).build() + let event: DevCycleEvent = try! DevCycleEvent.builder().type("test").target("test").clientDate(Date()).value(364.25).metaData(metaData).build() client.track(event) @@ -141,7 +141,7 @@ class DevCycleClientTest: XCTestCase { let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).service(service).build(onInitialized: nil) - let event: DVCEvent = try! DVCEvent.builder().type("test").clientDate(Date()).build() + let event: DevCycleEvent = try! DevCycleEvent.builder().type("test").clientDate(Date()).build() client.track(event) client.flushEvents() @@ -161,7 +161,7 @@ class DevCycleClientTest: XCTestCase { let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).service(service).build(onInitialized: nil) - let event: DVCEvent = try! DVCEvent.builder().type("test").clientDate(Date()).build() + let event: DevCycleEvent = try! DevCycleEvent.builder().type("test").clientDate(Date()).build() client.track(event) client.flushEvents(callback: { error in @@ -185,7 +185,7 @@ class DevCycleClientTest: XCTestCase { let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).build(onInitialized: nil) let service = MockService() // will assert if publishEvents was called client.setup(service: service) - let event: DVCEvent = try! DVCEvent.builder().type("test").clientDate(Date()).build() + let event: DevCycleEvent = try! DevCycleEvent.builder().type("test").clientDate(Date()).build() client.track(event) client.close(callback: { @@ -456,7 +456,7 @@ class DevCycleClientTest: XCTestCase { let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).service(service).build(onInitialized: nil) - let event: DVCEvent = try! DVCEvent.builder().type("test").clientDate(Date()).build() + let event: DevCycleEvent = try! DevCycleEvent.builder().type("test").clientDate(Date()).build() client.track(event) client.flushEvents() @@ -476,7 +476,7 @@ class DevCycleClientTest: XCTestCase { let client = try! self.builder.user(self.user).sdkKey("my_sdk_key").options(options).service(service).build(onInitialized: nil) - let event: DVCEvent = try! DVCEvent.builder().type("test").clientDate(Date()).build() + let event: DevCycleEvent = try! DevCycleEvent.builder().type("test").clientDate(Date()).build() client.variable(key: "test-key", defaultValue: false) client.flushEvents() @@ -505,7 +505,7 @@ extension DevCycleClientTest { XCTAssert(true) } - func publishEvents(events: [DVCEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { + func publishEvents(events: [DevCycleEvent], user: DevCycleUser, completion: @escaping PublishEventsCompletionHandler) { self.publishCallCount += 1 self.eventPublishCount += events.count XCTAssert(true) diff --git a/DevCycleTests/Models/DevCycleOptionsTest.swift b/DevCycleTests/Models/DevCycleOptionsTest.swift index 8908980..5d4422b 100644 --- a/DevCycleTests/Models/DevCycleOptionsTest.swift +++ b/DevCycleTests/Models/DevCycleOptionsTest.swift @@ -42,7 +42,7 @@ class DevCycleOptionsTest: XCTestCase { XCTAssertFalse(options.disableRealtimeUpdates) } - func testDeprecatedDVCOptions { + func testDeprecatedDVCOptions() { let options = DVCOptions.builder() .disableEventLogging(false) .build() From 90dcd6e3dd991e5d8ad916c874c6a7722960a5ff Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Thu, 20 Jul 2023 15:55:43 -0400 Subject: [PATCH 10/11] fix: test name --- DevCycleTests/Models/DevCycleClientTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DevCycleTests/Models/DevCycleClientTests.swift b/DevCycleTests/Models/DevCycleClientTests.swift index 9362087..9f83646 100644 --- a/DevCycleTests/Models/DevCycleClientTests.swift +++ b/DevCycleTests/Models/DevCycleClientTests.swift @@ -58,7 +58,7 @@ class DevCycleClientTest: XCTestCase { client.close(callback: nil) } - func testDepracatedDVCClientWorks() { + func testDeprecatedDVCClientWorks() { let builder = DevCycleClient.builder().service(service) let client = try! builder.user(self.user).environmentKey("my_sdk_key").build(onInitialized: nil) XCTAssertNotNil(client) From bd9eae3864b23d887a81a1b0b099767f2ae34f4f Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Fri, 21 Jul 2023 11:10:15 -0400 Subject: [PATCH 11/11] fix: more DVC cleanup --- DevCycle/DevCycleClient.swift | 4 ++-- DevCycle/ObjC/ObjCDevCycleClient.swift | 2 +- DevCycle/ObjC/ObjCDevCycleOptions.swift | 2 +- DevCycle/ObjC/ObjCDevCycleUser.swift | 11 +---------- DevCycleTests/Models/DevCycleClientTests.swift | 2 +- DevCycleTests/ObjC/ObjCDevCycleClientTests.m | 16 ++++++++-------- DevCycleTests/ObjC/ObjcDVCVariableTests.m | 2 +- 7 files changed, 15 insertions(+), 24 deletions(-) diff --git a/DevCycle/DevCycleClient.swift b/DevCycle/DevCycleClient.swift index 0fc3d20..35ef0e1 100644 --- a/DevCycle/DevCycleClient.swift +++ b/DevCycle/DevCycleClient.swift @@ -419,10 +419,10 @@ public class DevCycleClient { public func close(callback: CloseCompletedHandler?) { if (self.closed) { - Log.error("DVC Client is already closed.") + Log.error("DevCycleClient is already closed.") return } - Log.info("Closing DVC client and flushing remaining events.") + Log.info("Closing DevCycleClient and flushing remaining events.") self.closed = true self.flushTimer?.invalidate() self.flushEvents(callback: { error in diff --git a/DevCycle/ObjC/ObjCDevCycleClient.swift b/DevCycle/ObjC/ObjCDevCycleClient.swift index 4b79268..55c258d 100644 --- a/DevCycle/ObjC/ObjCDevCycleClient.swift +++ b/DevCycle/ObjC/ObjCDevCycleClient.swift @@ -76,7 +76,7 @@ public class ObjCDevCycleClient: NSObject { .user(dvcUser) if let dvcOptions = options { - clientBuilder = clientBuilder.options(dvcOptions.buildDVCOptions()) + clientBuilder = clientBuilder.options(dvcOptions.buildDevCycleOptions()) } guard let client = try? clientBuilder.build(onInitialized: onInitialized) diff --git a/DevCycle/ObjC/ObjCDevCycleOptions.swift b/DevCycle/ObjC/ObjCDevCycleOptions.swift index ba1dc98..1b71c56 100644 --- a/DevCycle/ObjC/ObjCDevCycleOptions.swift +++ b/DevCycle/ObjC/ObjCDevCycleOptions.swift @@ -22,7 +22,7 @@ public class ObjCDevCycleOptions: NSObject { @objc public var configCacheTTL: NSNumber? @objc public var disableRealtimeUpdates: NSNumber? - func buildDVCOptions() -> DevCycleOptions { + func buildDevCycleOptions() -> DevCycleOptions { var optionsBuilder = DevCycleOptions.builder() if let flushEventsIntervalMs = self.flushEventsIntervalMs, let interval = flushEventsIntervalMs as? Int { diff --git a/DevCycle/ObjC/ObjCDevCycleUser.swift b/DevCycle/ObjC/ObjCDevCycleUser.swift index 59d886b..46145eb 100644 --- a/DevCycle/ObjC/ObjCDevCycleUser.swift +++ b/DevCycle/ObjC/ObjCDevCycleUser.swift @@ -65,16 +65,7 @@ public class ObjCDevCycleUser: NSObject { do { return try userBuilder.build() } catch { - Log.error("Error building DVCUser: \(error)", tags: ["user", "build"]) - throw error - } - } - - @available(*, deprecated, message: "Use buildDevCycleUser") - func buildDVCUser() throws -> DVCUser { - do { - return try buildDevCycleUser() - } catch { + Log.error("Error building DevCycleUser: \(error)", tags: ["user", "build"]) throw error } } diff --git a/DevCycleTests/Models/DevCycleClientTests.swift b/DevCycleTests/Models/DevCycleClientTests.swift index 9f83646..3972a51 100644 --- a/DevCycleTests/Models/DevCycleClientTests.swift +++ b/DevCycleTests/Models/DevCycleClientTests.swift @@ -59,7 +59,7 @@ class DevCycleClientTest: XCTestCase { } func testDeprecatedDVCClientWorks() { - let builder = DevCycleClient.builder().service(service) + let builder = DVCClient.builder().service(service) let client = try! builder.user(self.user).environmentKey("my_sdk_key").build(onInitialized: nil) XCTAssertNotNil(client) XCTAssertNotNil(client.user) diff --git a/DevCycleTests/ObjC/ObjCDevCycleClientTests.m b/DevCycleTests/ObjC/ObjCDevCycleClientTests.m index 03556a7..be8199f 100644 --- a/DevCycleTests/ObjC/ObjCDevCycleClientTests.m +++ b/DevCycleTests/ObjC/ObjCDevCycleClientTests.m @@ -15,7 +15,7 @@ @implementation ObjcDevCycleClientTests - (void)testBuilderReturnsErrorIfNoSDKKey { XCTestExpectation *expectation = [self expectationWithDescription:@"Builder returns error if no sdk key"]; - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DevCycleClient *client = [DevCycleClient initialize:nil user:user options:nil onInitialized:^(NSError * _Nullable err) { XCTAssertNil(client); XCTAssertNotNil(err); @@ -35,14 +35,14 @@ - (void)testBuilderReturnsErrorIfNoUser { } - (void)testBuilderCreatesClientWithUserAndSDKKey { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); } - (void)testBuilderCreatesClientWithUserAndSDKKeyAndOptions { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; - DVCOptions *options = [[DVCOptions alloc] init]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; + DevCycleOptions *options = [[DevCycleOptions alloc] init]; options.logLevel = LogLevel.info; options.disableRealtimeUpdates = @true; options.configCacheTTL = @86400000; @@ -52,7 +52,7 @@ - (void)testBuilderCreatesClientWithUserAndSDKKeyAndOptions { } - (void)testDepracatedDVCClientWorks { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DVCClient *client = [DVCClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); } @@ -60,7 +60,7 @@ - (void)testDepracatedDVCClientWorks { #pragma mark - Variable Tests - (void)testVariableIsCreated { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); DVCVariable *variable = [client stringVariableWithKey:@"my-key" defaultValue:@"default-value"]; @@ -72,7 +72,7 @@ - (void)testVariableIsCreated { } - (void)testVariableValueIsCreated { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); NSString *variableValue = [client stringVariableValueWithKey:@"my-key" defaultValue:@"default-value"]; @@ -81,7 +81,7 @@ - (void)testVariableValueIsCreated { } - (void)testVariableValueBool { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DevCycleClient *client = [DevCycleClient initialize:@"my_sdk_key" user:user options:nil onInitialized:nil]; XCTAssertNotNil(client); BOOL boolValue = [client boolVariableValueWithKey:@"my-key" defaultValue:true]; diff --git a/DevCycleTests/ObjC/ObjcDVCVariableTests.m b/DevCycleTests/ObjC/ObjcDVCVariableTests.m index c241158..1125416 100644 --- a/DevCycleTests/ObjC/ObjcDVCVariableTests.m +++ b/DevCycleTests/ObjC/ObjcDVCVariableTests.m @@ -15,7 +15,7 @@ @interface ObjcDVCVariableTests : XCTestCase @implementation ObjcDVCVariableTests - (void)testVariableGetsCreatedWithDefault { - DVCUser *user = [DVCUser initializeWithUserId:@"my_user"]; + DevCycleUser *user = [DevCycleUser initializeWithUserId:@"my_user"]; DevCycleClient *client = [DevCycleClient initialize:@"key" user:user]; DVCVariable *variable = [client stringVariableWithKey:@"my-key" defaultValue:@"my-default"]; XCTAssertNotNil(variable);