Skip to content

Commit

Permalink
[Product Creation AI] Tracking for M3 (#13411)
Browse files Browse the repository at this point in the history
  • Loading branch information
selanthiraiyan authored Jul 25, 2024
2 parents c804d83 + c5aacd4 commit 6b9d5a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WooFoundation

extension WooAnalyticsEvent {
enum ProductCreationAI {
Expand All @@ -10,6 +11,7 @@ extension WooAnalyticsEvent {
case shortDescription = "short_description"
case description
case field
case featureWordCount = "feature_word_count"
}

static func entryPointDisplayed() -> WooAnalyticsEvent {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 6b9d5a9

Please sign in to comment.