Skip to content

Commit b3f30fb

Browse files
Merge pull request #8744 from woocommerce/feat/8679-replace-rest-api-feature-flag-with-ab-test
[REST API] Introduce A/B test and remove feature flag
2 parents 80e7f91 + c48427f commit b3f30fb

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

Experiments/Experiments/ABTest.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public enum ABTest: String, CaseIterable {
1515
/// Experiment ref: pbxNRc-1S0-p2
1616
case aaTestLoggedOut = "woocommerceios_explat_aa_test_logged_out_202212_v2"
1717

18+
/// A/B test for the REST API project
19+
/// Experiment ref: pbxNRc-2i4-p2
20+
case applicationPasswordAuthentication = "woocommerceios_login_rest_api_project_202301_v2"
21+
1822
/// Returns a variation for the given experiment
1923
public var variation: Variation {
2024
ExPlat.shared?.experiment(rawValue) ?? .control
@@ -27,7 +31,7 @@ public enum ABTest: String, CaseIterable {
2731
switch self {
2832
case .aaTestLoggedIn:
2933
return .loggedIn
30-
case .aaTestLoggedOut:
34+
case .aaTestLoggedOut, .applicationPasswordAuthentication:
3135
return .loggedOut
3236
case .null:
3337
return .none

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
5757
return buildConfig == .alpha
5858
case .tapToPayOnIPhone:
5959
return buildConfig == .localDeveloper
60-
case .applicationPasswordAuthenticationForSiteCredentialLogin:
61-
// Enable this to test application password authentication (WIP)
62-
return false
6360
case .domainSettings:
6461
return buildConfig == .localDeveloper || buildConfig == .alpha
6562
default:

Experiments/Experiments/FeatureFlag.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ public enum FeatureFlag: Int {
138138
/// - Note: The app will ignore this if `performanceMonitoring` is `false`.
139139
case performanceMonitoringViewController
140140

141-
/// Whether application password authentication should be used when a user logs in with site credentials.
142-
///
143-
case applicationPasswordAuthenticationForSiteCredentialLogin
144-
145141
/// Whether to enable domain updates from the settings for a WPCOM site.
146142
///
147143
case domainSettings

WooCommerce/Classes/Authentication/AuthenticationManager.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ class AuthenticationManager: Authentication {
6262
let isWPComMagicLinkPreferredToPassword = featureFlagService.isFeatureFlagEnabled(.loginMagicLinkEmphasis)
6363
let isWPComMagicLinkShownAsSecondaryActionOnPasswordScreen = featureFlagService.isFeatureFlagEnabled(.loginMagicLinkEmphasisM2)
6464
let isStoreCreationMVPEnabled = featureFlagService.isFeatureFlagEnabled(.storeCreationMVP)
65-
// TODO: Replace with A/B experiment
66-
let enableSiteAddressLoginOnly = featureFlagService.isFeatureFlagEnabled(.applicationPasswordAuthenticationForSiteCredentialLogin)
65+
let enableSiteAddressLoginOnly = ABTest.applicationPasswordAuthentication.variation == .treatment
6766
let configuration = WordPressAuthenticatorConfiguration(wpcomClientId: ApiCredentials.dotcomAppId,
6867
wpcomSecret: ApiCredentials.dotcomSecret,
6968
wpcomScheme: ApiCredentials.dotcomAuthScheme,
@@ -342,8 +341,7 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
342341
/// save the site to memory to check for jetpack requirement in epilogue
343342
currentSelfHostedSite = site
344343

345-
// TODO: Replace with A/B experiment
346-
let enableWPComOnlyForWPComSites = featureFlagService.isFeatureFlagEnabled(.applicationPasswordAuthenticationForSiteCredentialLogin)
344+
let enableWPComOnlyForWPComSites = ABTest.applicationPasswordAuthentication.variation == .treatment
347345

348346
switch (enableWPComOnlyForWPComSites, site.isWPCom) {
349347
case (true, true), (false, _):
@@ -389,7 +387,7 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
389387
/// If the user logged in with site credentials and application password feature flag is enabled,
390388
/// check if they can use the app and navigates to the home screen.
391389
if let siteCredentials = credentials.wporg,
392-
featureFlagService.isFeatureFlagEnabled(.applicationPasswordAuthenticationForSiteCredentialLogin) {
390+
ABTest.applicationPasswordAuthentication.variation == .treatment {
393391
return didAuthenticateUser(to: siteURL,
394392
with: siteCredentials,
395393
in: navigationController)
@@ -501,7 +499,7 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
501499
///
502500
func sync(credentials: AuthenticatorCredentials, onCompletion: @escaping () -> Void) {
503501
if let wporg = credentials.wporg,
504-
featureFlagService.isFeatureFlagEnabled(.applicationPasswordAuthenticationForSiteCredentialLogin) {
502+
ABTest.applicationPasswordAuthentication.variation == .treatment {
505503
ServiceLocator.stores.authenticate(credentials: .wporg(username: wporg.username,
506504
password: wporg.password,
507505
siteAddress: wporg.siteURL))

0 commit comments

Comments
 (0)