Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MBL-696] Cleanup Optimizely Experiments #1812

Merged
merged 32 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
738a49f
remove nativeOnboarding experiment
scottkicks Apr 11, 2023
f8f943b
remove onboardingCategoryPersonalizationFlow experiment
scottkicks Apr 11, 2023
0adadf4
remove nativeProjectCards experiment
scottkicks Apr 11, 2023
a85ebe3
remove nativeRiskMessaging experiment. leave affected code for now un…
scottkicks Apr 12, 2023
b979933
remove OptimizelyExperiment file
scottkicks Apr 12, 2023
9cf5163
remove goToLandingPage flow and LandingPage files
scottkicks Apr 12, 2023
aa6fbba
remove hasSeenLandingPage from KeyValueStoreType
scottkicks Apr 17, 2023
fe2743a
remove hasSeenCategoryPersonalizationFlow from KeyValueStoreType
scottkicks Apr 17, 2023
d2ef0b1
remove shouldSeeCategoryPersonalization(), goToCategoryPersonalizatio…
scottkicks Apr 17, 2023
1950b3b
rename testDeeplink and testOpenPushNotification_WhenOnboardingFlowIs…
scottkicks Apr 17, 2023
31ef1f0
add _Success suffix to testContinueUserActivity
scottkicks Apr 17, 2023
91ebb47
add _Success suffix to testPerformShortcutItem_
scottkicks Apr 17, 2023
b2fb981
remove experiment name from testLaunchShortcutItem_WhenOnboardingFlow…
scottkicks Apr 17, 2023
e1de13f
remove testEmailDeepLinking_WhenOnboardingFlowIsNotActive
scottkicks Apr 17, 2023
47f82e3
clean up projectsLoaded output in DiscoveryPageViewModel
scottkicks Apr 17, 2023
68bfcd3
.zero format suggestion
scottkicks Apr 17, 2023
771b6b5
put testConfigureDataSourceOptimizelyConfiguration test back
scottkicks Apr 17, 2023
415bb23
put testProjectsLoaded_Success back
scottkicks Apr 17, 2023
ecd1a95
put testContentInset_Success back
scottkicks Apr 17, 2023
a23f0e1
put testShowPersonalization_LoggedOut and testShowPersonalization_Log…
scottkicks Apr 17, 2023
82304a0
put testShowPersonalization_When_HasCompletedCategorySelection_IsFals…
scottkicks Apr 17, 2023
f2517e8
put testShowPersonalization_When_HasDismissedPersonalizationCell_IsTr…
scottkicks Apr 17, 2023
17e1e4e
remove experiments property and related methods from MockOptimizelyCl…
scottkicks Apr 17, 2023
b34e2d0
remove _Control suffix from testDiscoveryPageBackgroundColor
scottkicks Apr 17, 2023
2535c6b
clean up experiments related code from MockOptimizelyClient
scottkicks Apr 17, 2023
a4ced6f
Merge branch 'main' into scott/clean-up-experiments
msadoon Apr 17, 2023
2c48644
remove LandingViewModel and LandingViewModelTests
scottkicks Apr 18, 2023
71eab2f
Merge branch 'scott/clean-up-experiments' of https://github.com/kicks…
scottkicks Apr 18, 2023
696d888
remove unecessary test
scottkicks Apr 18, 2023
3f927b2
update testDiscoveryPageBackgroundColor test name to testIsNativeRisk…
scottkicks Apr 18, 2023
fd5bfda
undo naming since there is already a test with that name and use case
scottkicks Apr 18, 2023
2ca694e
remov LandingPageViewControllerTests and LandingViewControllerTests s…
scottkicks Apr 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 0 additions & 21 deletions Kickstarter-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,6 @@ internal final class AppDelegate: UIResponder, UIApplicationDelegate {
.observeForUI()
.observeValues { UIApplication.shared.open($0) }

self.viewModel.outputs.goToLandingPage
.observeForUI()
.observeValues { [weak self] in
let isIpad = AppEnvironment.current.device.userInterfaceIdiom == .pad

let landingPage = LandingPageViewController()
|> \.modalPresentationStyle .~ (isIpad ? .formSheet : .fullScreen)
self?.rootTabBarController?.present(landingPage, animated: true)
}

self.viewModel.outputs.applicationIconBadgeNumber
.observeForUI()
.observeValues { UIApplication.shared.applicationIconBadgeNumber = $0 }
Expand Down Expand Up @@ -217,17 +207,6 @@ internal final class AppDelegate: UIResponder, UIApplicationDelegate {
.observeForUI()
.observeValues { [weak self] in self?.findRedirectUrl($0) }

self.viewModel.outputs.goToCategoryPersonalizationOnboarding
.observeForControllerAction()
.observeValues { [weak self] in
let categorySelectionViewController = LandingViewController.instantiate()
let navController = NavigationController(rootViewController: categorySelectionViewController)
let isIpad = AppEnvironment.current.device.userInterfaceIdiom == .pad
navController.modalPresentationStyle = isIpad ? .formSheet : .fullScreen

self?.rootTabBarController?.present(navController, animated: true)
}

self.viewModel.outputs.emailVerificationCompleted
.observeForUI()
.observeValues { [weak self] message, success in
Expand Down
74 changes: 0 additions & 74 deletions Kickstarter-iOS/AppDelegateViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ public protocol AppDelegateViewModelOutputs {
/// Emits when the root view controller should navigate to activity.
var goToActivity: Signal<(), Never> { get }

/// Emits when the root view controller should navigate to the onboarding flow
var goToCategoryPersonalizationOnboarding: Signal<Void, Never> { get }

/// Emits when application should navigate to the creator's message thread
var goToCreatorMessageThread: Signal<(Param, MessageThread), Never> { get }

Expand All @@ -141,9 +138,6 @@ public protocol AppDelegateViewModelOutputs {
/// Emits when the root view controller should navigate to the creator dashboard.
var goToDiscovery: Signal<DiscoveryParams?, Never> { get }

/// Emits when the root view controller should present the Landing Page for new users.
var goToLandingPage: Signal<(), Never> { get }

/// Emits when the root view controller should present the login modal.
var goToLoginWithIntent: Signal<LoginIntent, Never> { get }

Expand Down Expand Up @@ -336,14 +330,6 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi

self.registerPushTokenInSegment = self.deviceTokenDataProperty.signal

// Onboarding

self.goToCategoryPersonalizationOnboarding = Signal.combineLatest(
self.applicationLaunchOptionsProperty.signal.ignoreValues(),
self.didUpdateOptimizelyClientProperty.signal.skipNil().ignoreValues()
).ignoreValues()
.filter(shouldSeeCategoryPersonalization)

// Deep links

let deepLinkFromNotification = self.remoteNotificationProperty.signal.skipNil()
Expand Down Expand Up @@ -405,13 +391,7 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
)
.skipNil()

self.goToLandingPage = self.applicationLaunchOptionsProperty.signal.ignoreValues()
.takeWhen(self.didUpdateOptimizelyClientProperty.signal.ignoreValues())
.filter(shouldGoToLandingPage)

let deepLink = deeplinkActivated
.filter { _ in shouldGoToLandingPage() == false && shouldSeeCategoryPersonalization() == false }
.take(until: self.goToLandingPage)

let updatedUserNotificationSettings = deepLink.filter { nav in
guard case .settings(.notifications(_, _)) = nav else { return false }
Expand Down Expand Up @@ -979,11 +959,9 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
public let findRedirectUrl: Signal<URL, Never>
public let forceLogout: Signal<(), Never>
public let goToActivity: Signal<(), Never>
public let goToCategoryPersonalizationOnboarding: Signal<Void, Never>
public let goToCreatorMessageThread: Signal<(Param, MessageThread), Never>
public let goToDashboard: Signal<Param?, Never>
public let goToDiscovery: Signal<DiscoveryParams?, Never>
public let goToLandingPage: Signal<(), Never>
public let goToLoginWithIntent: Signal<LoginIntent, Never>
public let goToMessageThread: Signal<MessageThread, Never>
public let goToPerimeterXCaptcha: Signal<PerimeterXBlockResponseType, Never>
Expand Down Expand Up @@ -1278,14 +1256,6 @@ extension ShortcutItem {
private func configureOptimizely(for _: Environment) -> OptimizelyClientType? {
// FIXME: This is until we add a new feature flagging client
let mockOptimizelyClient = MockOptimizelyClient()
msadoon marked this conversation as resolved.
Show resolved Hide resolved
|> \.experiments .~ [
OptimizelyExperiment.Key.nativeRiskMessaging.rawValue: OptimizelyExperiment.Variant.control.rawValue,
OptimizelyExperiment.Key.nativeProjectCards.rawValue: OptimizelyExperiment.Variant.control.rawValue,
OptimizelyExperiment.Key.onboardingCategoryPersonalizationFlow.rawValue: OptimizelyExperiment.Variant
.control.rawValue,
OptimizelyExperiment.Key.nativeOnboarding.rawValue: OptimizelyExperiment.Variant.control.rawValue
]
_ = mockOptimizelyClient
|> \.features .~
[
OptimizelyFeature.commentFlaggingEnabled.rawValue: false,
Expand Down Expand Up @@ -1330,50 +1300,6 @@ private func visitorCookies() -> [HTTPCookie] {
.compact()
}

private func shouldSeeCategoryPersonalization() -> Bool {
let isLoggedIn = AppEnvironment.current.currentUser != nil
let hasSeenCategoryPersonalization = AppEnvironment.current.userDefaults.hasSeenCategoryPersonalizationFlow
msadoon marked this conversation as resolved.
Show resolved Hide resolved

if isLoggedIn || hasSeenCategoryPersonalization {
// Currently logged-in users should not see the onboarding flow
AppEnvironment.current.userDefaults.hasSeenCategoryPersonalizationFlow = true

return false
}

guard let variant = AppEnvironment.current.optimizelyClient?
.variant(for: .onboardingCategoryPersonalizationFlow) else {
return false
}

switch variant {
case .control, .variant2:
return false
case .variant1:
return true
}
}

private func shouldGoToLandingPage() -> Bool {
let hasNotSeenLandingPage = !AppEnvironment.current.userDefaults.hasSeenLandingPage

guard AppEnvironment.current.currentUser == nil, hasNotSeenLandingPage else {
AppEnvironment.current.userDefaults.hasSeenLandingPage = true
msadoon marked this conversation as resolved.
Show resolved Hide resolved

return false
}

let optimizelyVariant = AppEnvironment.current.optimizelyClient?
.variant(for: OptimizelyExperiment.Key.nativeOnboarding)

switch optimizelyVariant {
case .variant1, .variant2:
return hasNotSeenLandingPage
case .control, nil:
return false
}
}

private func accessTokenFromUrl(_ url: URL?) -> String? {
return url.flatMap { url in
URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems
Expand Down