File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
ViewRelated/Orders/Order Creation Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -361,19 +361,19 @@ extension WooAnalyticsEvent {
361361 ] )
362362 }
363363
364- static func orderStatusChange( flow: Flow , from oldStatus: OrderStatus , to newStatus: OrderStatus ) -> WooAnalyticsEvent {
364+ static func orderStatusChange( flow: Flow , from oldStatus: OrderStatusEnum , to newStatus: OrderStatusEnum ) -> WooAnalyticsEvent {
365365 WooAnalyticsEvent ( statName: . orderStatusChange, properties: [
366366 Keys . flow: flow. rawValue,
367- Keys . from: oldStatus. slug ,
368- Keys . to: newStatus. slug
367+ Keys . from: oldStatus. rawValue ,
368+ Keys . to: newStatus. rawValue
369369 ] )
370370 }
371371
372- static func orderCreateButtonTapped( status: OrderStatus ,
372+ static func orderCreateButtonTapped( status: OrderStatusEnum ,
373373 productCount: Int ,
374374 hasCustomerDetails: Bool ) -> WooAnalyticsEvent {
375375 WooAnalyticsEvent ( statName: . orderCreateButtonTapped, properties: [
376- Keys . orderStatus: status. slug ,
376+ Keys . orderStatus: status. rawValue ,
377377 Keys . productCount: Int64 ( productCount) ,
378378 Keys . hasCustomerDetails: hasCustomerDetails
379379 ] )
Original file line number Diff line number Diff line change @@ -224,6 +224,7 @@ final class NewOrderViewModel: ObservableObject {
224224 }
225225 }
226226 stores. dispatch ( action)
227+ trackCreateButtonTapped ( )
227228 }
228229
229230 /// Assign this closure to be notified when a new order is created
@@ -494,6 +495,18 @@ private extension NewOrderViewModel {
494495 } ( )
495496 analytics. track ( event: WooAnalyticsEvent . Orders. orderCustomerAdd ( flow: . creation, hasDifferentShippingDetails: areAddressesDifferent) )
496497 }
498+
499+ /// Tracks when the create order button is tapped.
500+ ///
501+ /// Warning: This methods assume that `orderDetails.items.count` is equal to the product count,
502+ /// We probably should update this property to something like `itemsCount` or include better way to get the product count as the module evolves.
503+ ///
504+ func trackCreateButtonTapped( ) {
505+ let hasCustomerDetails = orderDetails. billingAddress != nil || orderDetails. shippingAddress != nil
506+ analytics. track ( event: WooAnalyticsEvent . Orders. orderCreateButtonTapped ( status: orderDetails. status,
507+ productCount: orderDetails. items. count,
508+ hasCustomerDetails: hasCustomerDetails) )
509+ }
497510}
498511
499512private extension NewOrderViewModel {
You can’t perform that action at this time.
0 commit comments