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

[NT-483] View manage pledge event #932

Merged
merged 10 commits into from
Nov 11, 2019
Merged

[NT-483] View manage pledge event #932

merged 10 commits into from
Nov 11, 2019

Conversation

cdolm92
Copy link
Contributor

@cdolm92 cdolm92 commented Nov 5, 2019

📲 What

Improvements in monitoring user behavior for v1 checkout. This tracks the menu options tapped event in the manage pledge screen.

🤔 Why

We track the menu option event with the Manage Pledge Option Clicked. This event includes a property called cta which value would be the menu option tapped.

✅ Acceptance criteria

  • Navigate to a live/backed project. Tap on the Menu Options:
  • If Update pledge tapped cta value should be "update_pledge"
  • If Change payment method tapped cta value should be "change_payment_method"
  • If Choose another reward tapped cta value should be "choose_another_reward"
  • If Contact creator tapped cta value should be "contact_creator"
  • If Cancel pledge tapped cta value should be "cancel_pledge"

Copy link
Contributor

@Scollaco Scollaco left a comment

Choose a reason for hiding this comment

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

Looking good, @cdolm92 . I left a couple of suggestions that might improve readability.

@@ -216,6 +216,26 @@ public final class Koala {
}
}

public enum ManagePledgeMenuCTAType {
case updatePledge
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you alphabetize the enum?


var trackingString: String {
switch self {
case .updatePledge: return "update_pledge"
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

let properties = client.properties.last
XCTAssertEqual(["Manage Pledge Option Clicked"], client.events)
XCTAssertEqual("cancel_pledge", properties?["cta"] as? String)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since all the ManagePledgeOptionClicked related tests are basically the same, here we could save some code and refactor by creating a private func

private func assertManagePledgeOptionClickedProperties(of type: Koala.ManagePledgeMenuCTAType, property: String) {
    let client = MockTrackingClient()
    let loggedInUser = User.template
    let koala = Koala(client: client, loggedInUser: loggedInUser)

    koala.trackManagePledgeOptionClicked(project: .template, managePledgeMenuCTA: type)

    let properties = client.properties.last
    XCTAssertEqual(["Manage Pledge Option Clicked"], client.events)
    XCTAssertEqual(property, properties?["cta"] as? String)
  }

And writing the tests just doing:

func testTrackManagePledgeOptionClicked_CancelPledgeSelected() {
    self.assertManagePledgeOptionClickedProperties(of: .cancelPledge, property: "cancel_pledge")
  }

self.menuOptionSelectedSignal.filter { $0 == .changePaymentMethod }.mapConst(.changePaymentMethod),
self.menuOptionSelectedSignal.filter { $0 == .chooseAnotherReward }.mapConst(.chooseAnotherReward),
self.menuOptionSelectedSignal.filter { $0 == .contactCreator }.mapConst(.contactCreator),
self.menuOptionSelectedSignal.filter { $0 == .cancelPledge }.mapConst(.cancelPledge)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here it's simpler if you create a function that takes a ManagePledgeAlertAction and returns a Koala.ManagePledgeMenuCTAType, using a switch statement.

This would simplify a lot this code by just using:

let managePledgeMenuType: Signal<Koala.ManagePledgeMenuCTAType, Never> = self.menuOptionSelectedSignal
      .map(managePledgeMenuCTAType(for:))

Copy link
Contributor

@Scollaco Scollaco left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the feedback! ⭐️

@cdolm92 cdolm92 merged commit 3409c87 into master Nov 11, 2019
@cdolm92 cdolm92 deleted the view-manage-pledge-event branch November 11, 2019 20:28
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

2 participants