diff --git a/app/src/androidTest/java/com/duckduckgo/app/cta/ui/CtaViewModelTest.kt b/app/src/androidTest/java/com/duckduckgo/app/cta/ui/CtaViewModelTest.kt index bf0fbf2de667..05f60543c4fc 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/cta/ui/CtaViewModelTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/cta/ui/CtaViewModelTest.kt @@ -764,10 +764,39 @@ class CtaViewModelTest { whenever(mockDuckPlayer.isSimulatedYoutubeNoCookie(any())).thenReturn(false) val value = testee.refreshCta(coroutineRule.testDispatcher, isBrowserShowing = true, site = site) - verify(mockPixel).fire(eq(ONBOARDING_SKIP_MAJOR_NETWORK_UNIQUE), any(), any(), eq(Unique())) assertNull(value) } + @Test + fun givenDuckPlayerSiteWhenRefreshCtaWhileBrowsingThenFireSkipMajorNetworkPixel() = runTest { + givenDaxOnboardingActive() + val site = site(url = "duck://player/12345", entity = TestEntity("Google", "Google", 9.0)) + + whenever(mockDuckPlayer.isDuckPlayerUri(any())).thenReturn(true) + whenever(mockDuckPlayer.getDuckPlayerState()).thenReturn(ENABLED) + whenever(mockDuckPlayer.getUserPreferences()).thenReturn(UserPreferences(false, AlwaysAsk)) + whenever(mockDuckPlayer.isYouTubeUrl(any())).thenReturn(false) + whenever(mockDuckPlayer.isSimulatedYoutubeNoCookie(any())).thenReturn(false) + + testee.refreshCta(coroutineRule.testDispatcher, isBrowserShowing = true, site = site) + verify(mockPixel).fire(eq(ONBOARDING_SKIP_MAJOR_NETWORK_UNIQUE), any(), any(), eq(Unique())) + } + + @Test + fun givenDuckPlayerSiteWhenRefreshCtaWhileBrowsingAndTrackersDialogAlreadyShownThenDontSentSkipMajorNetworkPixel() = runTest { + givenDaxOnboardingActive() + val site = site(url = "duck://player/12345", entity = TestEntity("Google", "Google", 9.0)) + + whenever(mockDuckPlayer.isDuckPlayerUri(any())).thenReturn(true) + whenever(mockDuckPlayer.getDuckPlayerState()).thenReturn(ENABLED) + whenever(mockDuckPlayer.getUserPreferences()).thenReturn(UserPreferences(false, AlwaysAsk)) + whenever(mockDuckPlayer.isYouTubeUrl(any())).thenReturn(false) + whenever(mockDuckPlayer.isSimulatedYoutubeNoCookie(any())).thenReturn(false) + + testee.refreshCta(coroutineRule.testDispatcher, isBrowserShowing = true, site = site) + verify(mockPixel).fire(eq(ONBOARDING_SKIP_MAJOR_NETWORK_UNIQUE), any(), any(), eq(Unique())) + } + @Test fun givenHighlightsExperimentWhenRefreshCtaOnHomeTabAndIntroCtaWasNotPreviouslyShownThenExperimentIntroCtaShown() = runTest { givenDaxOnboardingActive() diff --git a/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt b/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt index 9ea650d1de45..36febc9b8554 100644 --- a/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt +++ b/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt @@ -291,7 +291,7 @@ class CtaViewModel @Inject constructor( val nonNullSite = site ?: return null val host = nonNullSite.domain - if (host == null || userAllowListRepository.isDomainInUserAllowList(host) || isSiteNotAllowedForOnboarding(nonNullSite.url)) { + if (host == null || userAllowListRepository.isDomainInUserAllowList(host) || isSiteNotAllowedForOnboarding(nonNullSite)) { return null } @@ -368,8 +368,8 @@ class CtaViewModel @Inject constructor( } } - private suspend fun isSiteNotAllowedForOnboarding(url: String?): Boolean { - val uri = url?.toUri() ?: return true + private suspend fun isSiteNotAllowedForOnboarding(site: Site): Boolean { + val uri = site.url.toUri() if (subscriptions.isPrivacyProUrl(uri)) return true @@ -377,11 +377,16 @@ class CtaViewModel @Inject constructor( duckPlayer.getDuckPlayerState() == DuckPlayerState.ENABLED && ( (duckPlayer.getUserPreferences().privatePlayerMode == AlwaysAsk && duckPlayer.isYouTubeUrl(uri)) || - duckPlayer.isDuckPlayerUri(url) || duckPlayer.isSimulatedYoutubeNoCookie(uri) + duckPlayer.isDuckPlayerUri(site.url) || duckPlayer.isSimulatedYoutubeNoCookie(uri) ) - if (isDuckPlayerUrl) { - pixel.fire(pixel = ONBOARDING_SKIP_MAJOR_NETWORK_UNIQUE, type = Unique()) + if (isDuckPlayerUrl) { // temporary pixel + val isMayorNetwork = !daxDialogNetworkShown() && !daxDialogTrackersFoundShown() && OnboardingDaxDialogCta.mainTrackerNetworks.any { + site.entity?.displayName?.contains(it) ?: false + } + if (isMayorNetwork) { + pixel.fire(pixel = ONBOARDING_SKIP_MAJOR_NETWORK_UNIQUE, type = Unique()) + } } return isDuckPlayerUrl