Skip to content

Commit 0475c38

Browse files
committed
Tracks when customer details are added
1 parent e945055 commit 0475c38

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ extension WooAnalyticsEvent {
354354
WooAnalyticsEvent(statName: .orderProductAdd, properties: [Keys.flow: flow.rawValue])
355355
}
356356

357-
static func orderCustomerDetailsAdd(flow: Flow, hasDifferentShippingDetails: Bool) -> WooAnalyticsEvent {
357+
static func orderCustomerAdd(flow: Flow, hasDifferentShippingDetails: Bool) -> WooAnalyticsEvent {
358358
WooAnalyticsEvent(statName: .orderCustomerAdd, properties: [
359359
Keys.flow: flow.rawValue,
360360
Keys.hasDifferentShippingDetails: hasDifferentShippingDetails

WooCommerce/Classes/ViewRelated/Orders/Order Creation/NewOrderViewModel.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ final class NewOrderViewModel: ObservableObject {
201201
onAddressUpdate: { [weak self] updatedAddressData in
202202
self?.orderDetails.billingAddress = updatedAddressData.billingAddress
203203
self?.orderDetails.shippingAddress = updatedAddressData.shippingAddress
204+
self?.trackCustomerDetailsAdded()
204205
})
205206
}
206207

@@ -481,6 +482,18 @@ private extension NewOrderViewModel {
481482
}
482483
.assign(to: &$paymentDataViewModel)
483484
}
485+
486+
/// Tracks when customer details have been added
487+
///
488+
func trackCustomerDetailsAdded() {
489+
let areAddressesDifferent: Bool = {
490+
guard let billingAddress = orderDetails.billingAddress, let shippingAddress = orderDetails.shippingAddress else {
491+
return false
492+
}
493+
return billingAddress != shippingAddress
494+
}()
495+
analytics.track(event: WooAnalyticsEvent.Orders.orderCustomerAdd(flow: .creation, hasDifferentShippingDetails: areAddressesDifferent))
496+
}
484497
}
485498

486499
private extension NewOrderViewModel {

0 commit comments

Comments
 (0)