@@ -124,18 +124,14 @@ final class DashboardViewModel {
124124 if isEligible {
125125 ServiceLocator . analytics. track ( event: . ProductsOnboarding. storeIsEligible ( ) )
126126
127- if ABTest . productsOnboardingBanner. variation == . treatment( nil ) {
128- let viewModel = ProductsOnboardingAnnouncementCardViewModel ( onCTATapped: { [ weak self] in
129- self ? . announcementViewModel = nil // Dismiss announcement
130- MainTabBarController . presentAddProductFlow ( )
131- } )
132- self ? . announcementViewModel = viewModel
133- // For now, products onboarding takes precedence over Just In Time Messages,
134- // so we can stop if there is an onboarding announcement to display.
135- // This should be revisited when either onboarding or JITMs are expanded. See:
136- // pe5pgL-11B-p2
137- return
138- }
127+ self ? . setProductsOnboardingBannerIfNeeded ( )
128+ }
129+
130+ // For now, products onboarding takes precedence over Just In Time Messages,
131+ // so we can stop if there is an onboarding announcement to display.
132+ // This should be revisited when either onboarding or JITMs are expanded. See: pe5pgL-11B-p2
133+ if self ? . announcementViewModel is ProductsOnboardingAnnouncementCardViewModel {
134+ return
139135 }
140136 onCompletion ( )
141137 case . failure( let error) :
@@ -146,6 +142,27 @@ final class DashboardViewModel {
146142 stores. dispatch ( action)
147143 }
148144
145+ /// Sets the view model for the products onboarding banner if the user hasn't dismissed it before,
146+ /// and if the user is part of the treatment group for the products onboarding A/B test.
147+ ///
148+ private func setProductsOnboardingBannerIfNeeded( ) {
149+ guard ABTest . productsOnboardingBanner. variation == . treatment( nil ) else {
150+ return
151+ }
152+
153+ let getVisibility = AppSettingsAction . getFeatureAnnouncementVisibility ( campaign: . productsOnboarding) { [ weak self] result in
154+ guard let self else { return }
155+ if case let . success( isVisible) = result, isVisible {
156+ let viewModel = ProductsOnboardingAnnouncementCardViewModel ( onCTATapped: { [ weak self] in
157+ self ? . announcementViewModel = nil // Dismiss announcement
158+ MainTabBarController . presentAddProductFlow ( )
159+ } )
160+ self . announcementViewModel = viewModel
161+ }
162+ }
163+ stores. dispatch ( getVisibility)
164+ }
165+
149166 /// Checks for Just In Time Messages and prepares the announcement if needed.
150167 ///
151168 private func syncJustInTimeMessages( for siteID: Int64 ) {
0 commit comments