Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
// Enables a simulated barcode scanner in dev builds for testing. Do not ship this one!
return buildConfig == .localDeveloper || buildConfig == .alpha
case .pointOfSaleAsATabi1:
return buildConfig == .localDeveloper || buildConfig == .alpha
return true
default:
return true
}
Expand Down
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

22.7
-----

- [**] POS: a POS tab in the tab bar is now available in the app for stores eligible for Point of Sale, instead of the previous entry point in the Menu tab. [https://github.com/woocommerce/woocommerce-ios/pull/15766]

22.6
-----
Expand Down
3 changes: 3 additions & 0 deletions WooCommerce/Classes/Analytics/WooAnalyticsStat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,9 @@ enum WooAnalyticsStat: String {
case backgroundUpdatesDisabled = "background_updates_disabled"

// MARK: Point of Sale events
case pointOfSaleTabSelected = "main_tab_pos_selected"
case pointOfSaleTabReselected = "main_tab_pos_reselected"
case pointOfSaleTabVisibilityChecked = "pos_tab_visibility_checked"
case pointOfSaleLoaded = "loaded"
case pointOfSaleItemsFetched = "items_fetched"
case pointOfSaleItemsPullToRefresh = "items_pull_to_refresh"
Expand Down
5 changes: 3 additions & 2 deletions WooCommerce/Classes/ViewRelated/MainTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private extension MainTabBarController {
case .hubMenu:
ServiceLocator.analytics.track(.hubMenuTabSelected)
case .pointOfSale:
// TODO: WOOMOB-571 - analytics
ServiceLocator.analytics.track(.pointOfSaleTabSelected)
break
}
}
Expand All @@ -369,7 +369,7 @@ private extension MainTabBarController {
ServiceLocator.analytics.track(.hubMenuTabReselected)
break
case .pointOfSale:
// TODO: WOOMOB-571 - analytics
ServiceLocator.analytics.track(.pointOfSaleTabReselected)
break
}
}
Expand Down Expand Up @@ -667,6 +667,7 @@ private extension MainTabBarController {
guard let self, let posEligibilityChecker else { return }
let eligibility = await posEligibilityChecker.checkEligibility()
let isPOSTabVisible = eligibility == .eligible
analytics.track(.pointOfSaleTabVisibilityChecked, withProperties: ["is_visible": isPOSTabVisible])
updateTabViewControllers(isPOSTabVisible: isPOSTabVisible)
viewModel.loadHubMenuTabBadge()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,41 @@ final class MainTabBarControllerTests: XCTestCase {
// Resets the tab bar controller mock at the end of the test.
TestingAppDelegate.mockTabBarController = nil
}

func test_event_is_tracked_after_eligibility_check() throws {
// Given
let featureFlagService = MockFeatureFlagService()
featureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleAsATabi1] = true

let mockPOSEligibilityChecker = MockPOSEligibilityChecker()
mockPOSEligibilityChecker.result = .eligible

let storesManager = MockStoresManager(sessionManager: .makeForTesting())

guard let tabBarController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController(creator: { coder in
return MainTabBarController(coder: coder,
featureFlagService: featureFlagService,
analytics: self.analytics,
stores: storesManager,
posEligibilityCheckerFactory: { _ in mockPOSEligibilityChecker })
}) else {
return
}

// Trigger `viewDidLoad`
XCTAssertNotNil(tabBarController.view)

// When
storesManager.updateDefaultStore(storeID: 322)

// Then
waitUntil {
tabBarController.tabRootViewControllers.count == 5
}

let indexOfEvent = try XCTUnwrap(analyticsProvider.receivedEvents.firstIndex(of: WooAnalyticsStat.pointOfSaleTabVisibilityChecked.rawValue))
assertEqual(true, analyticsProvider.receivedProperties[safe: indexOfEvent]?["is_visible"] as? Bool)
}
}

extension MainTabBarController {
Expand Down