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

Native checkout experiment #801

Merged
merged 14 commits into from
Aug 19, 2019
Merged

Native checkout experiment #801

merged 14 commits into from
Aug 19, 2019

Conversation

Scollaco
Copy link
Contributor

@Scollaco Scollaco commented Aug 15, 2019

πŸ“² What

  • Implements an A/B experiment that brings users to the new Native Checkout or to the old checkout flow, depending on which bucket they are.

πŸ€” Why

  • To investigate the impact the new Native Checkout will have in comparison to the old checkout flow.
    And this is the JIRA ticket

πŸ›  How

The app now receives the native_checkout_v1 on the Config response.
Note The users will only see the checkout if the nativeCheckout feature is enabled AND they are on the experimental bucket.

βœ… Acceptance criteria

One way to test this is first go to Config.swift and add a breakpoint to see the values of stringsArray (line 30).

If the value of native_checkout_v1 is experimental:

  • Go to the Debug menu, turn on the Native Checkout feature flag and select any project. You should see the Native Checkout flow.
  • Turn off the feature flag and select any project. You should see the old checkout flow.

If the value of native_checkout_v1 is control:

  • Go to the Debug menu, turn on the Native Checkout feature flag and select any project. You should see the old checkout flow.
  • Turn off the feature flag and select any project. You should see the old checkout flow.

If you wanna test all the scenarios, simply go to ExperimentName +Helpers.swift and change the value of return Experiment.Variant(rawValue: variant) == .experimental to control. Here we are just changing the logic simulating a different bucket.

GIF

Copy link
Contributor

@dusi dusi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good..had couple minor comments

@@ -64,10 +65,22 @@ final class ProjectPamphletContentDataSourceTests: TestCase {
}
}

func testRewardsSection_nativeCheckoutFeature_showsWithTurnedOff() {
func testRewardsSection_showsWhen_nativeCheckoutFeatureEnabled_checkoutExperimentDisabled() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these tests cover the following combinations? (I think we might be missing one)

  1. feature enable + experiment disabled
  2. feature disabled + experiment enabled
  3. feature disabled + experiment disabled (I think we're missing this one)

@@ -1,6 +1,7 @@
public enum Experiment {
public enum Name: String {
case creatorsNameDiscovery = "show_created_by_discovery"
case nativeCheckoutV1 = "native_checkout_v1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering about the naming of this ... is this named native after our team (hence it's a native team feature) or is this named after the feature native checkout?

If it's the first then I think it's fine.
If it's the later then V1 is technically web checkout so not sure if it makes sense but don't feel strongly about it (just wanted to bring this up).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name starts with native so it becomes clear on the Kickstarter app that it's a native experiment (so no one deletes it by accident).

@@ -2,8 +2,8 @@ import Foundation
import KsApi

extension Experiment.Name {
public func isEnabled(in _: Environment) -> Bool {
guard let experiments = AppEnvironment.current.config?.abExperiments else { return false }
public func isEnabled(in environment: Environment = AppEnvironment.current) -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed this function is not tested...can we add appropriate tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function stayed untested for over a year! πŸ‘€ I will add a test for it.

@@ -5,6 +5,14 @@ public enum Feature: String {
case nativeCheckoutPledgeView = "ios_native_checkout_pledge_view"
}

extension Feature {
public func isEnabled(in environment: Environment = AppEnvironment.current) -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also looks untested..

Co-Authored-By: Pavel Dusatko <pavel.dusatko@gmail.com>
@ksr-ci-bot
Copy link

ksr-ci-bot commented Aug 15, 2019

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

Copy link
Contributor

@dusi dusi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had couple questions and noticed some issues

  1. ExperimentName+Helpers & ExperimentName+HelpersTests are not ordered alphabetically within their enclosing folder

  2. SwiftFormat seems to have some issues πŸ˜… (just run bin/format .)
    giphy

}
}

func testIsEnabled_Experimental() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we name these 2 tests similarly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops!


func testIsEnabled_Experimental() {
let config = Config.template
|> \.abExperiments .~ [Experiment.Name.nativeCheckoutV1.rawValue: "experimental"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also suggest we test when abExperiments is empty or does not include nativeCheckoutV1. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

import KsApi

public func userCanSeeNativeCheckout() -> Bool {
return nativeCheckoutExperimentIsEnabled() && featureNativeCheckoutEnabled()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely missed the naming the first time around...

What do you say we make this more consistent so that we:

  • use isEnabled for both
  • use the same pattern (either: nativeCheckoutExperimentIsEnabled & nativeCheckoutFeatureIsEnabled or experimentNativeCheckoutIsEnabled & featureNativeCheckoutIsEnabled)?

@@ -80,10 +80,10 @@ public final class ProjectPamphletViewModel: ProjectPamphletViewModelType, Proje
}

self.goToRewards = goToRewards
.filter { _ in featureNativeCheckoutPledgeViewEnabled() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that when merging master this is actually using the correct feature flag Native Checkout not Native Checkout Pledge View ... @justinswart has recently changed it since it was causing issue with deep links πŸ˜…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I noticed that. Actually we now will use userCanSeeNativeCheckout because of the experiment πŸ˜„

Copy link
Contributor

@dusi dusi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚒 🚒 🚒
🚒 🚒 🚒
🚒 🚒 🚒

Tested on iPad Air 2 (Cher)

@Scollaco Scollaco merged commit 0b3efb7 into master Aug 19, 2019
@Scollaco Scollaco deleted the native_checkout_experiment branch August 19, 2019 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants