-
Notifications
You must be signed in to change notification settings - Fork 121
Add tracks for Customer Search #7907
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
Changes from 9 commits
bcb8d16
aed6852
d350d31
bb884ed
6aace88
6670176
56582c0
f20e20f
1ed53af
6a326f7
2be5053
169094d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,10 +70,6 @@ public enum FeatureFlag: Int { | |
| /// | ||
| case searchProductsBySKU | ||
|
|
||
| /// Enables the Search Customers functionality in the Order Creation screen | ||
| /// | ||
| case orderCreationSearchCustomers | ||
|
|
||
|
Comment on lines
-73
to
-76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well remembered |
||
| /// Enables signing up for a WP.com account. | ||
| /// | ||
| case wpcomSignup | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -405,6 +405,7 @@ open class AddressFormViewModel: ObservableObject { | |||||
| /// Fills Order AddressFormFields with Customer details | ||||||
| /// | ||||||
| func customerSelectedFromSearch(customer: Customer) { | ||||||
| analytics.analyticsProvider.track(WooAnalyticsStat.orderCreationCustomerAdded.rawValue) | ||||||
|
||||||
| analytics.analyticsProvider.track(WooAnalyticsStat.orderCreationCustomerAdded.rawValue) | |
| analytics.track(.orderCreationCustomerAdded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here: 6a326f7
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -701,6 +701,25 @@ final class EditOrderAddressFormViewModelTests: XCTestCase { | |
| assertEqual(analyticsProvider.receivedProperties.first?["subject"] as? String, "billing_address") | ||
| } | ||
|
|
||
| func test_view_model_when_customerSelectedFromSearch_then_tracks_orderCreationCustomerAdded() { | ||
| // Given | ||
| let analyticsProvider = MockAnalyticsProvider() | ||
| let viewModel = EditOrderAddressFormViewModel(order: Order.fake(), type: .billing, analytics: WooAnalytics(analyticsProvider: analyticsProvider)) | ||
| let customer = Customer.fake().copy( | ||
| email: "[email protected]", | ||
| firstName: "Johnny", | ||
| lastName: "Appleseed", | ||
| billing: sampleAddressWithEmptyNullableFields(), | ||
| shipping: sampleAddressWithEmptyNullableFields() | ||
| ) | ||
|
|
||
| // When | ||
| viewModel.customerSelectedFromSearch(customer: customer) | ||
|
|
||
| // Then | ||
| assertEqual(analyticsProvider.receivedEvents, [WooAnalyticsStat.orderCreationCustomerAdded.rawValue]) | ||
|
||
| } | ||
|
|
||
| func test_view_model_fires_error_notice_when_providing_an_invalid_email() { | ||
| // Given | ||
| let viewModel = EditOrderAddressFormViewModel(order: Order.fake(), type: .billing) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,13 @@ import Yosemite | |||||||||||
|
|
||||||||||||
| final class CustomerSearchUICommandTests: XCTestCase { | ||||||||||||
| private let sampleSiteID: Int64 = 123 | ||||||||||||
| private var analyticsProvider: MockAnalyticsProvider! | ||||||||||||
| private var analytics: Analytics! | ||||||||||||
|
|
||||||||||||
| override func setUp() { | ||||||||||||
| analyticsProvider = MockAnalyticsProvider() | ||||||||||||
| analytics = WooAnalytics(analyticsProvider: analyticsProvider) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func test_searchResultsPredicate_includes_siteID_and_keyword_when_keyword() { | ||||||||||||
| // Given | ||||||||||||
|
|
@@ -35,4 +42,26 @@ final class CustomerSearchUICommandTests: XCTestCase { | |||||||||||
| XCTAssertEqual(cellViewModel.title, "\(customer.firstName ?? "") \(customer.lastName ?? "")") | ||||||||||||
| XCTAssertEqual(cellViewModel.subtitle, String(customer.email)) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func test_CustomerSearchUICommand_when_synchronizeModels_then_tracks_orderCreationCustomerSearch_event() { | ||||||||||||
| // Given | ||||||||||||
| let command = CustomerSearchUICommand( | ||||||||||||
| siteID: sampleSiteID, | ||||||||||||
| analytics: analytics) { _ in } | ||||||||||||
|
|
||||||||||||
| // When | ||||||||||||
| command.synchronizeModels( | ||||||||||||
| siteID: sampleSiteID, | ||||||||||||
| keyword: "", | ||||||||||||
| pageNumber: 1, | ||||||||||||
| pageSize: 1, | ||||||||||||
| onCompletion: { _ in } | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| // Then | ||||||||||||
| guard let eventIndex = analyticsProvider.receivedEvents.firstIndex(of: "order_creation_customer_search") else { | ||||||||||||
| return XCTFail("Analytics not logged") | ||||||||||||
| } | ||||||||||||
| XCTAssertNotNil(eventIndex) | ||||||||||||
|
||||||||||||
| guard let eventIndex = analyticsProvider.receivedEvents.firstIndex(of: "order_creation_customer_search") else { | |
| return XCTFail("Analytics not logged") | |
| } | |
| XCTAssertNotNil(eventIndex) | |
| XCTAssert(analyticsProvider.receivedEvents.contains("order_creation_customer_search")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! That's true, if passes the guard, it would never fail. Thanks for the suggestion! Changed at 2be5053
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked a release build, and the feature is enabled there 👍