From ecd7adcb4f754f5006fac0163fc16f16a4063610 Mon Sep 17 00:00:00 2001 From: Ajay Subramanya Date: Wed, 17 Apr 2024 12:31:26 -0500 Subject: [PATCH 1/2] fixed missing profile properties --- Sources/KlaviyoSwift/StateManagement.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/KlaviyoSwift/StateManagement.swift b/Sources/KlaviyoSwift/StateManagement.swift index d41b8260..048c6165 100644 --- a/Sources/KlaviyoSwift/StateManagement.swift +++ b/Sources/KlaviyoSwift/StateManagement.swift @@ -501,6 +501,9 @@ extension Profile { phoneNumber: state.phoneNumber, externalId: state.externalId, firstName: firstName, + lastName: lastName, + organization: organization, + title: title, image: image, location: location, properties: properties) From 7bb9fc1489dc201f940543e4a111ebc9803f5c72 Mon Sep 17 00:00:00 2001 From: Ajay Subramanya Date: Wed, 17 Apr 2024 16:59:49 -0500 Subject: [PATCH 2/2] added a test --- .../StateManagementTests.swift | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Tests/KlaviyoSwiftTests/StateManagementTests.swift b/Tests/KlaviyoSwiftTests/StateManagementTests.swift index dcdadb74..67b12e8d 100644 --- a/Tests/KlaviyoSwiftTests/StateManagementTests.swift +++ b/Tests/KlaviyoSwiftTests/StateManagementTests.swift @@ -458,6 +458,30 @@ class StateManagementTests: XCTestCase { } } + @MainActor + func testSetProfileWithAllProfileIdentifiersAndProperties() async throws { + let initialState = INITIALIZED_TEST_STATE() + let store = TestStore(initialState: initialState, reducer: KlaviyoReducer()) + + _ = await store.send(.enqueueProfile(Profile.test)) { + $0.email = Profile.test.email + $0.phoneNumber = Profile.test.phoneNumber + $0.externalId = Profile.test.externalId + $0.pushTokenData = nil + + let request = KlaviyoAPI.KlaviyoRequest( + apiKey: initialState.apiKey!, + endpoint: .registerPushToken(.init( + pushToken: initialState.pushTokenData!.pushToken, + enablement: initialState.pushTokenData!.pushEnablement.rawValue, + background: initialState.pushTokenData!.pushBackground.rawValue, + profile: Profile.test, + anonymousId: initialState.anonymousId!) + )) + $0.queue = [request] + } + } + // MARK: - Test enqueue event @MainActor