Skip to content

Commit

Permalink
Merge pull request wordpress-mobile#18298 from wordpress-mobile/task/…
Browse files Browse the repository at this point in the history
…ab-test-site-name

[Site Name] A/B Test the site name screen
  • Loading branch information
twstokes authored Apr 8, 2022
2 parents 9dddadb + 8667345 commit eff2124
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 134 deletions.
1 change: 1 addition & 0 deletions WordPress/Classes/Utility/AB Testing/ABTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AutomatticTracks

enum ABTest: String, CaseIterable {
case unknown = "unknown"
case siteNameV1 = "wpios_site_name_v1"

/// Returns a variation for the given experiment
var variation: Variation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ final class SiteIntentStep: WizardStep {
}
}()

init?(siteIntentAB: SiteIntentABTestable = SiteIntentAB.shared, creator: SiteCreator) {
let variant = siteIntentAB.variant
SiteCreationAnalyticsHelper.trackSiteIntentExperiment(variant)
guard FeatureFlag.siteIntentQuestion.enabled && variant == .treatment else {
return nil
}

init(creator: SiteCreator) {
self.creator = creator
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Foundation

/// Site Creation: Allows creation of the site's name.
final class SiteNameStep: WizardStep {
weak var delegate: WizardDelegate?
private let creator: SiteCreator

private(set) lazy var content: UIViewController = {
return SiteNameViewController(creator: creator)
}()

init(creator: SiteCreator) {
self.creator = creator
}

private func didSet(name: String?) {
if let name = name {
let currentTagline = creator.information?.tagLine
creator.information = SiteInformation(title: name, tagLine: currentTagline)
}

delegate?.nextStep()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

enum SiteCreationStep {
case address
case design
case intent
case name
case segments
case siteAssembly
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,53 @@
import AutomatticTracks

/// Puts together the Site creation wizard, assembling steps.
final class SiteCreationWizardLauncher {
private let intentVariant: SiteIntentAB.Variant
private let nameVariant: Variation

private lazy var creator: SiteCreator = {
return SiteCreator()
}()

private lazy var segmentsStep: WizardStep = {
let segmentsService = SiteCreationSegmentsService(managedObjectContext: ContextManager.sharedInstance().mainContext)
return SiteSegmentsStep(creator: self.creator, service: segmentsService)
}()

private lazy var intentStep: WizardStep? = {
return SiteIntentStep(creator: self.creator)
}()
private var shouldShowSiteIntent: Bool {
return intentVariant == .treatment && FeatureFlag.siteIntentQuestion.enabled
}

private lazy var designStep: WizardStep = {
return SiteDesignStep(creator: self.creator)
}()
private var shouldShowSiteName: Bool {
return nameVariant == .treatment(nil) && FeatureFlag.siteName.enabled
}

private lazy var addressStep: WizardStep = {
let addressService = DomainsServiceAdapter(managedObjectContext: ContextManager.sharedInstance().mainContext)
return WebAddressStep(creator: self.creator, service: addressService)
}()
lazy var steps: [SiteCreationStep] = {
// If Site Intent shouldn't be shown, fall back to the original steps.
guard shouldShowSiteIntent else {
return [
.design,
.address,
.siteAssembly
]
}

private lazy var siteAssemblyStep: WizardStep = {
let siteAssemblyService = EnhancedSiteCreationService(managedObjectContext: ContextManager.sharedInstance().mainContext)
return SiteAssemblyStep(creator: self.creator, service: siteAssemblyService, onDismiss: onDismiss)
}()
// If Site Intent should be shown but not the Site Name, only add Site Intent.
guard shouldShowSiteName else {
return [
.intent,
.design,
.address,
.siteAssembly
]
}

private lazy var steps: [WizardStep] = {
// If Site Name should be shown, swap out the Site Address step.
return [
self.intentStep,
self.designStep,
self.addressStep,
self.siteAssemblyStep
].compactMap { $0 }
.intent,
.name,
.design,
.siteAssembly
]
}()

private lazy var wizard: SiteCreationWizard = {
return SiteCreationWizard(steps: self.steps)
return SiteCreationWizard(steps: steps.map { initStep($0) })
}()

lazy var ui: UIViewController? = {
Expand All @@ -55,7 +65,40 @@ final class SiteCreationWizardLauncher {
///
private let onDismiss: ((Blog, Bool) -> Void)?

init(onDismiss: ((Blog, Bool) -> Void)? = nil) {
init(
intentVariant: SiteIntentAB.Variant = SiteIntentAB.shared.variant,
nameVariant: Variation = ABTest.siteNameV1.variation,
onDismiss: ((Blog, Bool) -> Void)? = nil
) {
self.onDismiss = onDismiss
self.intentVariant = intentVariant
self.nameVariant = nameVariant

trackVariants()
}

private func trackVariants() {
SiteCreationAnalyticsHelper.trackSiteIntentExperiment(intentVariant)
// TODO: Track Site Name
}

private func initStep(_ step: SiteCreationStep) -> WizardStep {
switch step {
case .address:
let addressService = DomainsServiceAdapter(managedObjectContext: ContextManager.sharedInstance().mainContext)
return WebAddressStep(creator: self.creator, service: addressService)
case .design:
return SiteDesignStep(creator: self.creator)
case .intent:
return SiteIntentStep(creator: self.creator)
case .name:
return SiteNameStep(creator: self.creator)
case .segments:
let segmentsService = SiteCreationSegmentsService(managedObjectContext: ContextManager.sharedInstance().mainContext)
return SiteSegmentsStep(creator: self.creator, service: segmentsService)
case .siteAssembly:
let siteAssemblyService = EnhancedSiteCreationService(managedObjectContext: ContextManager.sharedInstance().mainContext)
return SiteAssemblyStep(creator: self.creator, service: siteAssemblyService, onDismiss: onDismiss)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
protocol SiteIntentABTestable {
var variant: SiteIntentAB.Variant { get }
}
import Foundation

class SiteIntentAB: SiteIntentABTestable {
class SiteIntentAB {
static let shared = SiteIntentAB()

enum Variant {
Expand Down
20 changes: 16 additions & 4 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,6 @@
B084E61F27E3B79F007BF7A8 /* SiteIntentStep.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0960C8627D14BD400BC9717 /* SiteIntentStep.swift */; };
B084E62027E3B7A4007BF7A8 /* SiteIntentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B089140C27E1255D00CF468B /* SiteIntentViewController.swift */; };
B089140D27E1255D00CF468B /* SiteIntentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B089140C27E1255D00CF468B /* SiteIntentViewController.swift */; };
B089140F27E1352B00CF468B /* SiteCreationIntentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B089140E27E1352B00CF468B /* SiteCreationIntentTests.swift */; };
B0960C8727D14BD400BC9717 /* SiteIntentStep.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0960C8627D14BD400BC9717 /* SiteIntentStep.swift */; };
B0960C8927D17B1200BC9717 /* SiteIntentAB.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0960C8827D17B1200BC9717 /* SiteIntentAB.swift */; };
B0960C8A27D17B1200BC9717 /* SiteIntentAB.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0960C8827D17B1200BC9717 /* SiteIntentAB.swift */; };
Expand Down Expand Up @@ -2162,6 +2161,11 @@
C3234F5227EB9925004ADB29 /* SiteIntentData.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3234F5027EB9925004ADB29 /* SiteIntentData.swift */; };
C3234F5427EBBACA004ADB29 /* SiteIntentVertical.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3234F5327EBBACA004ADB29 /* SiteIntentVertical.swift */; };
C3234F5527EBBACA004ADB29 /* SiteIntentVertical.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3234F5327EBBACA004ADB29 /* SiteIntentVertical.swift */; };
C3439B5F27FE3A3C0058DA55 /* SiteCreationWizardLauncherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3439B5E27FE3A3C0058DA55 /* SiteCreationWizardLauncherTests.swift */; };
C352870527FDD35C004E2E51 /* SiteNameStep.swift in Sources */ = {isa = PBXBuildFile; fileRef = C352870427FDD35C004E2E51 /* SiteNameStep.swift */; };
C352870627FDD35C004E2E51 /* SiteNameStep.swift in Sources */ = {isa = PBXBuildFile; fileRef = C352870427FDD35C004E2E51 /* SiteNameStep.swift */; };
C35D4FF1280077F100DB90B5 /* SiteCreationStep.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35D4FF0280077F100DB90B5 /* SiteCreationStep.swift */; };
C35D4FF2280077F100DB90B5 /* SiteCreationStep.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35D4FF0280077F100DB90B5 /* SiteCreationStep.swift */; };
C387B7A22638D66F00BDEF86 /* PostAuthorSelectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E2462826277B7700B99EA6 /* PostAuthorSelectorViewController.swift */; };
C38C5D8127F61D2C002F517E /* MenuItemTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38C5D8027F61D2C002F517E /* MenuItemTests.swift */; };
C3C39B0726F50D3900B1238D /* WordPressSupportSourceTag+Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C39B0626F50D3900B1238D /* WordPressSupportSourceTag+Editor.swift */; };
Expand Down Expand Up @@ -6700,7 +6704,6 @@
B06378BE253F639D00FD45D2 /* SiteSuggestion+CoreDataClass.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SiteSuggestion+CoreDataClass.swift"; sourceTree = "<group>"; };
B06378BF253F639D00FD45D2 /* SiteSuggestion+CoreDataProperties.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SiteSuggestion+CoreDataProperties.swift"; sourceTree = "<group>"; };
B089140C27E1255D00CF468B /* SiteIntentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteIntentViewController.swift; sourceTree = "<group>"; };
B089140E27E1352B00CF468B /* SiteCreationIntentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteCreationIntentTests.swift; sourceTree = "<group>"; };
B0960C8627D14BD400BC9717 /* SiteIntentStep.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteIntentStep.swift; sourceTree = "<group>"; };
B0960C8827D17B1200BC9717 /* SiteIntentAB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteIntentAB.swift; sourceTree = "<group>"; };
B0A6DEBE2626335F00B5B8EF /* AztecPostViewController+MenuTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "AztecPostViewController+MenuTests.swift"; path = "Aztec/AztecPostViewController+MenuTests.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6901,6 +6904,9 @@
C3234F5327EBBACA004ADB29 /* SiteIntentVertical.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteIntentVertical.swift; sourceTree = "<group>"; };
C3302CC427EB67D0004229D3 /* IntentCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IntentCell.xib; sourceTree = "<group>"; };
C3302CC527EB67D0004229D3 /* IntentCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntentCell.swift; sourceTree = "<group>"; };
C3439B5E27FE3A3C0058DA55 /* SiteCreationWizardLauncherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteCreationWizardLauncherTests.swift; sourceTree = "<group>"; };
C352870427FDD35C004E2E51 /* SiteNameStep.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteNameStep.swift; sourceTree = "<group>"; };
C35D4FF0280077F100DB90B5 /* SiteCreationStep.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteCreationStep.swift; sourceTree = "<group>"; };
C38C5D8027F61D2C002F517E /* MenuItemTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MenuItemTests.swift; path = Menus/MenuItemTests.swift; sourceTree = "<group>"; };
C3ABE791263099F7009BD402 /* WordPress 121.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 121.xcdatamodel"; sourceTree = "<group>"; };
C3C39B0626F50D3900B1238D /* WordPressSupportSourceTag+Editor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "WordPressSupportSourceTag+Editor.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -9675,6 +9681,7 @@
children = (
3FBB2D2A27FB6CB200C57BBF /* SiteNameViewController.swift */,
3FBB2D2D27FB715900C57BBF /* SiteNameView.swift */,
C352870427FDD35C004E2E51 /* SiteNameStep.swift */,
);
path = "Site Name";
sourceTree = "<group>";
Expand Down Expand Up @@ -10521,8 +10528,8 @@
73178C2321BEE09300E37C9A /* SiteSegmentsStepTests.swift */,
73178C3421BEE9AC00E37C9A /* TitleSubtitleHeaderTests.swift */,
32C6CDDA23A1FF0D002556FF /* SiteCreationRotatingMessageViewTests.swift */,
B089140E27E1352B00CF468B /* SiteCreationIntentTests.swift */,
B030FE0927EBF0BC000F6F5E /* SiteCreationIntentTracksEventTests.swift */,
C3439B5E27FE3A3C0058DA55 /* SiteCreationWizardLauncherTests.swift */,
);
path = SiteCreation;
sourceTree = "<group>";
Expand Down Expand Up @@ -10643,6 +10650,7 @@
children = (
738B9A4021B85CF20005062B /* SiteCreationWizard.swift */,
738B9A4421B85CF20005062B /* SiteCreationWizardLauncher.swift */,
C35D4FF0280077F100DB90B5 /* SiteCreationStep.swift */,
738B9A4121B85CF20005062B /* SiteCreator.swift */,
738B9A4621B85CF20005062B /* WizardNavigation.swift */,
B0960C8827D17B1200BC9717 /* SiteIntentAB.swift */,
Expand Down Expand Up @@ -18235,6 +18243,7 @@
B560914C208A671F00399AE4 /* WPStyleGuide+SiteCreation.swift in Sources */,
B0960C8727D14BD400BC9717 /* SiteIntentStep.swift in Sources */,
9801E682274EEBC4002FDDB6 /* ReaderDetailCommentsHeader.swift in Sources */,
C352870527FDD35C004E2E51 /* SiteNameStep.swift in Sources */,
B5EFB1C21B31B98E007608A3 /* NotificationSettingsService.swift in Sources */,
5903AE1B19B60A98009D5354 /* WPButtonForNavigationBar.m in Sources */,
1717139F265FE59700F3A022 /* ButtonStyles.swift in Sources */,
Expand Down Expand Up @@ -18333,6 +18342,7 @@
4388FF0020A4E19C00783948 /* NotificationsViewController+PushPrimer.swift in Sources */,
5D3D559718F88C3500782892 /* ReaderPostService.m in Sources */,
7EA30DB521ADA20F0092F894 /* EditorMediaUtility.swift in Sources */,
C35D4FF1280077F100DB90B5 /* SiteCreationStep.swift in Sources */,
7492F78E1F9BD94500B5A04A /* ShareMediaFileManager.swift in Sources */,
17A4A36C20EE55320071C2CA /* ReaderCoordinator.swift in Sources */,
FAB800B225AEE3C600D5D54A /* RestoreCompleteView.swift in Sources */,
Expand Down Expand Up @@ -19448,7 +19458,6 @@
7E53AB0420FE6681005796FE /* ActivityContentRouterTests.swift in Sources */,
F11023A323186BCA00C4E84A /* MediaBuilder.swift in Sources */,
17AF92251C46634000A99CFB /* BlogSiteVisibilityHelperTest.m in Sources */,
B089140F27E1352B00CF468B /* SiteCreationIntentTests.swift in Sources */,
73B6693A21CAD960008456C3 /* ErrorStateViewTests.swift in Sources */,
8BD34F0927D144FF005E931C /* BlogDashboardStateTests.swift in Sources */,
1759F1721FE017F20003EC81 /* QueueTests.swift in Sources */,
Expand Down Expand Up @@ -19633,6 +19642,7 @@
C856749A243F4292001A995E /* TenorMockDataHelper.swift in Sources */,
D81C2F5820F86CEA002AE1F1 /* NetworkStatus.swift in Sources */,
E1C545801C6C79BB001CEB0E /* MediaSettingsTests.swift in Sources */,
C3439B5F27FE3A3C0058DA55 /* SiteCreationWizardLauncherTests.swift in Sources */,
7E987F5A2108122A00CAFB88 /* NotificationUtility.swift in Sources */,
4688E6CC26AB571D00A5D894 /* RequestAuthenticatorTests.swift in Sources */,
7E442FC720F677CB00DEACA5 /* ActivityLogRangesTest.swift in Sources */,
Expand Down Expand Up @@ -20885,6 +20895,7 @@
FABB249F2602FC2C00C8785C /* RevisionBrowserState.swift in Sources */,
982DDF93263238A6002B3904 /* LikeUser+CoreDataProperties.swift in Sources */,
FAADE42626159AFE00BF29FE /* AppConstants.swift in Sources */,
C352870627FDD35C004E2E51 /* SiteNameStep.swift in Sources */,
FABB24A02602FC2C00C8785C /* KeyValueDatabase.swift in Sources */,
FABB24A12602FC2C00C8785C /* UITableViewCell+enableDisable.swift in Sources */,
FABB24A22602FC2C00C8785C /* WPAnalyticsTrackerAutomatticTracks.m in Sources */,
Expand Down Expand Up @@ -21312,6 +21323,7 @@
F10D635026F0B78E00E46CC7 /* Blog+Organization.swift in Sources */,
FABB26112602FC2C00C8785C /* LastPostStatsRecordValue+CoreDataClass.swift in Sources */,
FABB26122602FC2C00C8785C /* ActivityRangesFactory.swift in Sources */,
C35D4FF2280077F100DB90B5 /* SiteCreationStep.swift in Sources */,
C79C308026EA975000E88514 /* ReferrerDetailsRow.swift in Sources */,
FABB26132602FC2C00C8785C /* SFHFKeychainUtils.m in Sources */,
FABB26142602FC2C00C8785C /* CircularProgressView+ActivityIndicatorType.swift in Sources */,
Expand Down
53 changes: 0 additions & 53 deletions WordPress/WordPressTest/SiteCreation/SiteCreationIntentTests.swift

This file was deleted.

Loading

0 comments on commit eff2124

Please sign in to comment.