Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,7 @@ extension WooAnalyticsEvent {
enum ProductsOnboarding {
enum Keys: String {
case type
case templateEligible = "template_eligible"
}

enum CreationType: String {
Expand All @@ -1746,5 +1747,9 @@ extension WooAnalyticsEvent {
static func productCreationTypeSelected(type: CreationType) -> WooAnalyticsEvent {
WooAnalyticsEvent(statName: .addProductCreationTypeSelected, properties: [Keys.type.rawValue: type.rawValue])
}

static func productListAddProductButtonTapped(templateEligible: Bool) -> WooAnalyticsEvent {
WooAnalyticsEvent(statName: .productListAddProductTapped, properties: [Keys.templateEligible.rawValue: templateEligible])
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ final class AddProductCoordinator: Coordinator {
}

func start() {

ServiceLocator.analytics.track(event: .ProductsOnboarding.productListAddProductButtonTapped(templateEligible: isTemplateOptionsEligible()))

if shouldPresentProductCreationBottomSheet() {
presentProductCreationTypeBottomSheet()
} else {
Expand All @@ -77,10 +80,16 @@ final class AddProductCoordinator: Coordinator {
private extension AddProductCoordinator {

/// Defines if the product creation bottom sheet should be presented.
/// Currently returns `true` when the feature is enabled and the number of products is fewer than 3.
/// Currently returns `true` when the feature is enabled and the store is eligible for displaying template options.
///
func shouldPresentProductCreationBottomSheet() -> Bool {
isProductCreationTypeEnabled && productsResultsController.numberOfObjects < 3
isProductCreationTypeEnabled && isTemplateOptionsEligible()
}

/// Returns `true` when the number of products is fewer than 3.
///
func isTemplateOptionsEligible() -> Bool {
productsResultsController.numberOfObjects < 3
}

/// Presents a bottom sheet for users to choose if they want a create a product manually or via a template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ private extension ProductsViewController {
return
}

ServiceLocator.analytics.track(.productListAddProductTapped)

let coordinatingController: AddProductCoordinator
if let sourceBarButtonItem = sourceBarButtonItem {
coordinatingController = AddProductCoordinator(siteID: siteID,
Expand Down