File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
ViewRelated/Orders/Collect Payments Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -155,8 +155,11 @@ extension PointOfSaleAggregateModel {
155155 }
156156
157157 private func trackCustomerInteractionStarted( ) {
158- // TODO: Only track if no cart items yet
159- collectOrderPaymentAnalyticsTracker. trackCustomerInteractionStarted ( )
158+ // At the moment we're assumming that an interaction starts simply when the cart is zero
159+ // but a more complex logic will be needed for other cases
160+ if cart. count == 0 {
161+ collectOrderPaymentAnalyticsTracker. trackCustomerInteractionStarted ( )
162+ }
160163 }
161164}
162165
Original file line number Diff line number Diff line change @@ -37,9 +37,8 @@ final class POSCollectOrderPaymentAnalytics: CollectOrderPaymentAnalyticsTrackin
3737 func trackProcessingCompletion( intent: Yosemite . PaymentIntent ) { }
3838
3939 func trackSuccessfulPayment( capturedPaymentData: CardPresentCapturedPaymentData ) {
40- let customerInteractionFinished = Date ( ) . timeIntervalSince1970 - customerInteractionStarted
41- debugPrint ( " end at \( customerInteractionFinished) " )
42- ServiceLocator . analytics. track ( event: WooAnalyticsEvent . PointOfSale. cardPresentCollectPaymentSuccess ( millisecondsSinceCustomerIteractionStated: customerInteractionFinished) )
40+ let elapsedTime = calculateElapsedTimeInMilliseconds ( start: customerInteractionStarted, end: Date ( ) . timeIntervalSince1970)
41+ ServiceLocator . analytics. track ( event: WooAnalyticsEvent . PointOfSale. cardPresentCollectPaymentSuccess ( millisecondsSinceCustomerIteractionStated: elapsedTime) )
4342 }
4443
4544 func trackPaymentFailure( with error: any Error ) { }
@@ -52,7 +51,10 @@ final class POSCollectOrderPaymentAnalytics: CollectOrderPaymentAnalyticsTrackin
5251
5352 func trackCustomerInteractionStarted( ) {
5453 customerInteractionStarted = Date ( ) . timeIntervalSince1970
55- debugPrint ( " started at \( customerInteractionStarted) " )
54+ }
55+
56+ private func calculateElapsedTimeInMilliseconds( start: Double , end: Double ) -> Double {
57+ ( end - start) * 1000
5658 }
5759}
5860
You can’t perform that action at this time.
0 commit comments