From 9f0e76f379db25a97d1cf67fa6ceac07be192989 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 27 Jan 2025 15:51:59 +0100 Subject: [PATCH 1/2] is_customer_registered property to ORDER_CREATION_CUSTOMER_ADDED event tracking --- .../creation/customerlist/CustomerListSelectionViewModel.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModel.kt index 95424417c12..953ca8f56b7 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModel.kt @@ -35,7 +35,10 @@ class CustomerListSelectionViewModel @Inject constructor( private var loadingMoreInfoAboutCustomerJob: Job? = null override fun onCustomerSelected(customerModel: WCCustomerModel) { - analyticsTracker.track(AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED) + analyticsTracker.track( + AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED, + mapOf("is_customer_registered" to (customerModel.remoteCustomerId > 0L)) + ) when { customerModel.remoteCustomerId > 0L -> { // this customer is registered, so we may have more info on them From 18bbc622712132956f9b667ebabd0d71bd27cf7a Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 27 Jan 2025 15:57:01 +0100 Subject: [PATCH 2/2] Fixed unit tests --- .../CustomerListSelectionViewModel.kt | 2 +- .../CustomerListSelectionViewModelTest.kt | 25 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModel.kt index 953ca8f56b7..5b55ae8caaa 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModel.kt @@ -37,7 +37,7 @@ class CustomerListSelectionViewModel @Inject constructor( override fun onCustomerSelected(customerModel: WCCustomerModel) { analyticsTracker.track( AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED, - mapOf("is_customer_registered" to (customerModel.remoteCustomerId > 0L)) + mapOf("is_customer_registered" to (customerModel.remoteCustomerId > 0L).toString()) ) when { customerModel.remoteCustomerId > 0L -> { diff --git a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModelTest.kt b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModelTest.kt index 861939d0981..a6269f28ba3 100644 --- a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModelTest.kt +++ b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/creation/customerlist/CustomerListSelectionViewModelTest.kt @@ -863,7 +863,10 @@ class CustomerListSelectionViewModelTest : BaseUnitTest() { ) ) ) - verify(analyticsTrackerWrapper).track(AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED) + verify(analyticsTrackerWrapper).track( + AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED, + mapOf("is_customer_registered" to "true") + ) } @Test @@ -913,7 +916,10 @@ class CustomerListSelectionViewModelTest : BaseUnitTest() { // THEN assertThat(states[0].partialLoading).isFalse assertThat(states[1].partialLoading).isTrue - verify(analyticsTrackerWrapper).track(AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED) + verify(analyticsTrackerWrapper).track( + AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED, + mapOf("is_customer_registered" to "true") + ) } @Test @@ -966,7 +972,10 @@ class CustomerListSelectionViewModelTest : BaseUnitTest() { ) ) ) - verify(analyticsTrackerWrapper).track(AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED) + verify(analyticsTrackerWrapper).track( + AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED, + mapOf("is_customer_registered" to "true") + ) } @Test @@ -1026,7 +1035,10 @@ class CustomerListSelectionViewModelTest : BaseUnitTest() { ) ) ) - verify(analyticsTrackerWrapper).track(AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED) + verify(analyticsTrackerWrapper).track( + AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED, + mapOf("is_customer_registered" to "true") + ) } @Test @@ -1076,7 +1088,10 @@ class CustomerListSelectionViewModelTest : BaseUnitTest() { ) ) ) - verify(analyticsTrackerWrapper).track(AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED) + verify(analyticsTrackerWrapper).track( + AnalyticsEvent.ORDER_CREATION_CUSTOMER_ADDED, + mapOf("is_customer_registered" to "false") + ) } @Test