Skip to content

Commit

Permalink
Refactor domainPurchasingExperiment event tracking to take into ExPla…
Browse files Browse the repository at this point in the history
…t changes
  • Loading branch information
salimbraksa committed May 2, 2023
1 parent c4b3cc9 commit a58884f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions WordPress/Classes/Utility/AB Testing/ABTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ enum ABTest: String, CaseIterable {
/// Flag indicating whether the experiment's variation is treament or not.
var isTreatmentVariation: Bool {
switch variation {
case .treatment: return true
default: return false
case .treatment, .customTreatment: return true
case .control: return false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,22 @@ class SiteCreationAnalyticsHelper {
private static let variationKey = "variation"
private static let siteNameKey = "site_name"
private static let recommendedKey = "recommended"
private static let treatmentVariationValue = "treatment_variation_value"
private static let customTreatmentNameKey = "custom_treatment_variation_name"

// MARK: - Lifecycle
static func trackSiteCreationAccessed(source: String) {
WPAnalytics.track(.enhancedSiteCreationAccessed, withProperties: ["source": source])

if FeatureFlag.siteCreationDomainPurchasing.enabled {

let domainPurchasingExperimentProperties: [String: String] = {
var dict: [String: String]
switch ABTest.siteCreationDomainPurchasing.variation {
case .control:
dict = [Self.variationKey: "control"]
case .treatment(let val):
dict = [Self.variationKey: "treatment"]
if let val {
dict[Self.treatmentVariationValue] = val
}
var dict: [String: String] = [Self.variationKey: ABTest.siteCreationDomainPurchasing.variation.tracksProperty]

if case let .customTreatment(name) = ABTest.siteCreationDomainPurchasing.variation {
dict[Self.customTreatmentNameKey] = name
}

return dict
}()

Self.track(.domainPurchasingExperiment, properties: domainPurchasingExperimentProperties)
}
}
Expand Down

0 comments on commit a58884f

Please sign in to comment.