Skip to content

Commit

Permalink
add clear_cart_tapped event & test
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgabrielma committed Feb 5, 2025
1 parent 3f6ae93 commit f4509cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions WooCommerce/Classes/Analytics/WooAnalyticsStat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,7 @@ enum WooAnalyticsStat: String {
case pointOfSaleItemRemovedFromCart = "item_removed_from_cart"
case pointOfSaleCheckoutTapped = "checkout_tapped"
case pointOfSaleBackToCartTapped = "back_to_cart_tapped"
case pointOfSaleClearCartTapped = "clear_cart_tapped"
case pointOfSaleExitMenuItemTapped = "exit_pos_menu_item_tapped"
case pointOfSaleExitConfirmed = "exit_pos_confirmed"
case pointOfSaleGetSupportTapped = "get_support_tapped"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ extension PointOfSaleAggregateModel {

func removeAllItemsFromCart() {
cart.removeAll()
analytics.track(.pointOfSaleClearCartTapped)
}

func addMoreToCart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ struct PointOfSaleAggregateModelTests {
#expect(sut.cart.isEmpty)
}

@Test func removeAllItemsFromCart_tracks_event() {
// Given/When
sut.removeAllItemsFromCart()

// Then
#expect(analyticsProvider.receivedEvents.first(where: { $0 == "clear_cart_tapped" }) != nil)
}

@Test(.disabled(
"""
This test doesn't currently work; analytics extensions are not thread-safe,
Expand Down

0 comments on commit f4509cc

Please sign in to comment.