diff --git a/Modules/Sources/Experiments/DefaultFeatureFlagService.swift b/Modules/Sources/Experiments/DefaultFeatureFlagService.swift index 8b044ffff3d..7c5b8b081d0 100644 --- a/Modules/Sources/Experiments/DefaultFeatureFlagService.swift +++ b/Modules/Sources/Experiments/DefaultFeatureFlagService.swift @@ -109,7 +109,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 } diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index f487f0d607f..ca75e89a093 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -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 ----- diff --git a/WooCommerce/Classes/Analytics/WooAnalyticsStat.swift b/WooCommerce/Classes/Analytics/WooAnalyticsStat.swift index 0e923535c26..8ab003392c5 100644 --- a/WooCommerce/Classes/Analytics/WooAnalyticsStat.swift +++ b/WooCommerce/Classes/Analytics/WooAnalyticsStat.swift @@ -1276,6 +1276,8 @@ enum WooAnalyticsStat: String { case backgroundUpdatesDisabled = "background_updates_disabled" // MARK: Point of Sale events + case pointOfSaleTabSelected = "main_tab_pos_selected" + case pointOfSaleTabVisibilityChecked = "pos_tab_visibility_checked" case pointOfSaleLoaded = "loaded" case pointOfSaleItemsFetched = "items_fetched" case pointOfSaleItemsPullToRefresh = "items_pull_to_refresh" diff --git a/WooCommerce/Classes/ViewRelated/MainTabBarController.swift b/WooCommerce/Classes/ViewRelated/MainTabBarController.swift index b54214e1f41..b27b1649300 100644 --- a/WooCommerce/Classes/ViewRelated/MainTabBarController.swift +++ b/WooCommerce/Classes/ViewRelated/MainTabBarController.swift @@ -352,7 +352,7 @@ private extension MainTabBarController { case .hubMenu: ServiceLocator.analytics.track(.hubMenuTabSelected) case .pointOfSale: - // TODO: WOOMOB-571 - analytics + ServiceLocator.analytics.track(.pointOfSaleTabSelected) break } } @@ -373,7 +373,7 @@ private extension MainTabBarController { ServiceLocator.analytics.track(.hubMenuTabReselected) break case .pointOfSale: - // TODO: WOOMOB-571 - analytics + assertionFailure("Point of Sale tab should not be reselected as it cannot be selected from `tabBarController(_:shouldSelect:)`.") break } } @@ -672,6 +672,7 @@ private extension MainTabBarController { guard let self, let posEligibilityChecker = self.posEligibilityChecker else { return } let eligibility = await posEligibilityChecker.checkEligibility() let isPOSTabVisible = eligibility == .eligible + analytics.track(.pointOfSaleTabVisibilityChecked, withProperties: ["is_visible": isPOSTabVisible]) cachePOSTabVisibility(siteID: siteID, isPOSTabVisible: isPOSTabVisible) updateTabViewControllers(isPOSTabVisible: isPOSTabVisible) viewModel.loadHubMenuTabBadge() diff --git a/WooCommerce/WooCommerceTests/ViewRelated/MainTabBarControllerTests.swift b/WooCommerce/WooCommerceTests/ViewRelated/MainTabBarControllerTests.swift index 6e57ea407b2..cfde0034772 100644 --- a/WooCommerce/WooCommerceTests/ViewRelated/MainTabBarControllerTests.swift +++ b/WooCommerce/WooCommerceTests/ViewRelated/MainTabBarControllerTests.swift @@ -560,6 +560,41 @@ final class MainTabBarControllerTests: XCTestCase { // Then XCTAssertEqual(mockPOSEligibilityService.loadCachedPOSTabVisibility(siteID: 1216), true) } + + 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 {