Skip to content

Commit f0562ad

Browse files
committed
Adds a templateElegible property to productListAddProductTapped event
1 parent 0b26114 commit f0562ad

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,7 @@ extension WooAnalyticsEvent {
17221722
enum ProductsOnboarding {
17231723
enum Keys: String {
17241724
case type
1725+
case templateEligible = "template_eligible"
17251726
}
17261727

17271728
enum CreationType: String {
@@ -1746,5 +1747,9 @@ extension WooAnalyticsEvent {
17461747
static func productCreationTypeSelected(type: CreationType) -> WooAnalyticsEvent {
17471748
WooAnalyticsEvent(statName: .addProductCreationTypeSelected, properties: [Keys.type.rawValue: type.rawValue])
17481749
}
1750+
1751+
static func productListAddProductButtonTapped(templateEligible: Bool) -> WooAnalyticsEvent {
1752+
WooAnalyticsEvent(statName: .productListAddProductTapped, properties: [Keys.templateEligible.rawValue: templateEligible])
1753+
}
17491754
}
17501755
}

WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductCoordinator.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ final class AddProductCoordinator: Coordinator {
6565
}
6666

6767
func start() {
68+
69+
ServiceLocator.analytics.track(event: .ProductsOnboarding.productListAddProductButtonTapped(templateEligible: isTemplateOptionsEligible()))
70+
6871
if shouldPresentProductCreationBottomSheet() {
6972
presentProductCreationTypeBottomSheet()
7073
} else {
@@ -77,10 +80,16 @@ final class AddProductCoordinator: Coordinator {
7780
private extension AddProductCoordinator {
7881

7982
/// Defines if the product creation bottom sheet should be presented.
80-
/// Currently returns `true` when the feature is enabled and the number of products is fewer than 3.
83+
/// Currently returns `true` when the feature is enabled and the store is eligible for displaying template options.
8184
///
8285
func shouldPresentProductCreationBottomSheet() -> Bool {
83-
isProductCreationTypeEnabled && productsResultsController.numberOfObjects < 3
86+
isProductCreationTypeEnabled && isTemplateOptionsEligible()
87+
}
88+
89+
/// Returns `true` when the number of products is fewer than 3.
90+
///
91+
func isTemplateOptionsEligible() -> Bool {
92+
productsResultsController.numberOfObjects < 3
8493
}
8594

8695
/// Presents a bottom sheet for users to choose if they want a create a product manually or via a template.

WooCommerce/Classes/ViewRelated/Products/ProductsViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ private extension ProductsViewController {
258258
return
259259
}
260260

261-
ServiceLocator.analytics.track(.productListAddProductTapped)
262-
263261
let coordinatingController: AddProductCoordinator
264262
if let sourceBarButtonItem = sourceBarButtonItem {
265263
coordinatingController = AddProductCoordinator(siteID: siteID,

0 commit comments

Comments
 (0)