diff --git a/WooCommerce/Classes/Analytics/WooAnalyticsEvent+ProductCreationAI.swift b/WooCommerce/Classes/Analytics/WooAnalyticsEvent+ProductCreationAI.swift index c66493e063f..293fd5ca1a5 100644 --- a/WooCommerce/Classes/Analytics/WooAnalyticsEvent+ProductCreationAI.swift +++ b/WooCommerce/Classes/Analytics/WooAnalyticsEvent+ProductCreationAI.swift @@ -1,4 +1,5 @@ import Foundation +import WooFoundation extension WooAnalyticsEvent { enum ProductCreationAI { @@ -10,6 +11,7 @@ extension WooAnalyticsEvent { case shortDescription = "short_description" case description case field + case featureWordCount = "feature_word_count" } static func entryPointDisplayed() -> WooAnalyticsEvent { @@ -32,9 +34,12 @@ extension WooAnalyticsEvent { properties: [Key.value.rawValue: tone.rawValue.lowercased()]) } - static func generateDetailsTapped(isFirstAttempt: Bool) -> WooAnalyticsEvent { - WooAnalyticsEvent(statName: .productCreationAIGenerateDetailsTapped, - properties: [Key.isFirstAttempt.rawValue: isFirstAttempt]) + static func generateDetailsTapped(isFirstAttempt: Bool, + features: String) -> WooAnalyticsEvent { + let wordCount = features.components(separatedBy: .whitespacesAndNewlines).count + return WooAnalyticsEvent(statName: .productCreationAIGenerateDetailsTapped, + properties: [Key.isFirstAttempt.rawValue: isFirstAttempt, + Key.featureWordCount.rawValue: wordCount]) } static func generateProductDetailsSuccess() -> WooAnalyticsEvent { diff --git a/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Container/AddProductWithAIContainerViewModel.swift b/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Container/AddProductWithAIContainerViewModel.swift index 2bb1a470566..075fcdf8996 100644 --- a/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Container/AddProductWithAIContainerViewModel.swift +++ b/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Container/AddProductWithAIContainerViewModel.swift @@ -78,7 +78,8 @@ final class AddProductWithAIContainerViewModel: ObservableObject { } func onProductFeaturesAdded(features: String) { - analytics.track(event: .ProductCreationAI.generateDetailsTapped(isFirstAttempt: isFirstAttemptGeneratingDetails)) + analytics.track(event: .ProductCreationAI.generateDetailsTapped(isFirstAttempt: isFirstAttemptGeneratingDetails, + features: features)) productFeatures = features currentStep = .preview isFirstAttemptGeneratingDetails = false diff --git a/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Preview/ProductDetailPreviewViewModel.swift b/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Preview/ProductDetailPreviewViewModel.swift index 3c881c19446..0a592fde6ee 100644 --- a/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Preview/ProductDetailPreviewViewModel.swift +++ b/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Preview/ProductDetailPreviewViewModel.swift @@ -265,7 +265,8 @@ final class ProductDetailPreviewViewModel: ObservableObject { } func didTapGenerateAgain() { - analytics.track(event: .ProductCreationAI.generateDetailsTapped(isFirstAttempt: false)) + analytics.track(event: .ProductCreationAI.generateDetailsTapped(isFirstAttempt: false, + features: productFeatures)) Task { @MainActor in await generateProductDetails() }