-
Notifications
You must be signed in to change notification settings - Fork 120
[Woo POS] Coupons: Analytics #15516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Woo POS] Coupons: Analytics #15516
Conversation
In two cases: - When coupon is removed from cart - When coupon is removed by tapping 'Remove coupon' button
Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the missing analytics events for coupon-related actions in the POS flow while updating related tracking calls and analytics event definitions. Key changes include:
- Adding and applying new analytics events for coupon settings, creation, cart actions, and checkout with coupons.
- Refactoring tracking methods (e.g. replacing direct tracking calls with helper functions) in views like ItemListView and CartView.
- Updating analytics event definitions and tracks provider lists to support these new coupon events.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Yosemite/Yosemite/Stores/CouponsError.swift | Added a constant property ‘code’ using an error code constant from Constants. |
| WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncCouponsErrorMessageView.swift | Added a tracking call for coupon removal inside the retry button action. |
| WooCommerce/Classes/POS/Presentation/ItemListView.swift | Updated various tracking calls to use the new events and helper functions (e.g. trackPullToRefresh and trackSelectedItemListTypeTapped). |
| WooCommerce/Classes/POS/Presentation/CartView.swift | Revised checkout tracking to include counts for both products and coupons; added a tracking call on coupon removal. |
| WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift | Modified the order creation failure tracking to use a helper that differentiates coupon errors using the new CouponsError code property. |
| WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift | Updated the checkoutTapped event method and added a new event property for coupons in cart. |
| WooCommerce/Classes/POS/Analytics/WooAnalyticsStat.swift | Introduced new analytics stat cases for coupon-related events. |
| WooCommerce/Classes/Analytics/TracksProvider.swift | Added the new coupon event cases to the list of valid POS events. |
Comments suppressed due to low confidence (3)
Yosemite/Yosemite/Stores/CouponsError.swift:5
- [nitpick] Consider adding inline documentation or a brief comment clarifying that the property 'code' is intentionally hard-coded to the invalid coupon constant so that future maintainers understand it is not meant to vary per error instance.
public let code: String = Constants.invalidCouponCode
WooCommerce/Classes/Analytics/TracksProvider.swift:205
- [nitpick] Double-check that the naming of the newly added coupon event cases (e.g. couponCreationSuccess, couponSettingEnabled) remains consistent with existing naming conventions in the codebase.
WooAnalyticsStat.couponSettingEnabled,
WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift:37
- Verify that all callers of the 'checkoutTapped' method have been updated to pass both products and coupons counts to avoid runtime issues.
static func checkoutTapped(productsInCart: Int, couponsInCart: Int) -> WooAnalyticsEvent {
|
|
joshheald
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All work well 👍
94dff69 to
59584f8
Compare

Description
Add missing analytics events for the POS Coupons implementation.
Specs:
pos_coupon_settings_enabledpos_coupon_creation_successpos_checkout_tappedNew parameter:coupons_in_cart : Integerpos_order_creation_failedwith improved error_context.pos_order_creation_failedUpdate parameter:error_context to specific errorwoocommerce_rest_invalid_couponrather than the whole error message since it's difficult to filter it out.New Events
We will track the new data using the same conventions as products in POS.
pos_products_tappedpos_coupons_tappedpos_coupons_create_tappedpos_coupons_pull_to_refreshpos_coupon_added_to_cartpos_coupon_removed_from_cartSteps to reproduce
Prerequisites:
Enable the use of coupon codessetting in WooCommerce->SettingsenableCouponsInPointOfSalefeature flagpos_coupons_tappedshould be trackedpos_coupon_settings_enabledshould be trackedpos_coupons_create_tappedshould be trackedpos_coupon_creation_successshould be trackedpos_coupon_added_to_cartshould be trackedpos_coupon_removed_from_cartshould be trackedpos_coupons_pull_to_refreshshould be trackedpos_checkout_tappedshould be tracked withcoupons_in_cartparameter and number of coupons added to cartpos_order_creation_failedshould be tracked witherror_contextset towoocommerce_rest_invalid_couponRegistration PRs of new events:
Testing information
Tested on iPad Air 11 Inch M2 iOS 18.2 Simulator
RELEASE-NOTES.txtif necessary.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: