Skip to content

Commit 51514f2

Browse files
committed
Enhance coupon creation initialization tracks
1 parent 9ef2712 commit 51514f2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

WooCommerce/Classes/ViewRelated/Coupons/Add and Edit Coupons/AddEditCouponViewModel.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ final class AddEditCouponViewModel: ObservableObject {
267267
}
268268

269269
private func createCoupon(coupon: Coupon) {
270-
ServiceLocator.analytics.track(.couponCreationInitiated)
270+
trackCouponCreateInitiated(with: coupon)
271271

272272
if let validationError = validateCouponLocally(coupon) {
273273
notice = NoticeFactory.createCouponErrorNotice(validationError,
@@ -459,6 +459,16 @@ private extension AddEditCouponViewModel {
459459
return coupon.freeShipping != initialCoupon.freeShipping
460460
}
461461

462+
func trackCouponCreateInitiated(with coupon: Coupon) {
463+
ServiceLocator.analytics.track(.couponCreationInitiated, withProperties: [
464+
"discount_type": coupon.discountType,
465+
"has_expiry_date": coupon.dateExpires != nil,
466+
"includes_free_shipping": coupon.freeShipping,
467+
"has_product_or_category_restrictions": coupon.excludedProductCategories.isNotEmpty || coupon.excludedProductIds.isNotEmpty,
468+
"has_usage_restrictions": coupon.usageLimit != nil && coupon.usageLimit > 0
469+
])
470+
}
471+
462472
func trackCouponUpdateInitiated(with coupon: Coupon) {
463473
ServiceLocator.analytics.track(.couponUpdateInitiated, withProperties: [
464474
"discount_type_updated": checkDiscountTypeUpdated(for: coupon),

0 commit comments

Comments
 (0)