Skip to content

Commit

Permalink
Temporary pixel for visit site suggestions CTA display count (#5309)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/488551667048375/1208778105886340/f

### Description
Add temporary pixel for counting display of visit site suggestions
dialog

### Steps to test this PR

_Feature 1_
- [x] Fresh install
- [x] Once in the browser, tap on a search suggestion
- [x] Dismiss SERP dialog
- [x] _Logcat:_ Check `onboarding_visit_site_cta_shown` pixel is fired
with parameter `count = 0`
- [x] Open a new tab
- [x] _Logcat:_ Check `onboarding_visit_site_cta_shown` pixel is fired
with parameter `count = 1`
- [x] Close and open the app
- [x] _Logcat:_ Check `onboarding_visit_site_cta_shown` pixel is fired
with parameter `count = 2`
- [x] Perform a search
- [x] Open a new tab
- [x] _Logcat:_ Check `onboarding_visit_site_cta_shown` pixel is fired
with parameter `count = 3`
- [x] Tap on a site suggestion or navigate to a site
- [x] Check Trackers dialog appears
- [x] Open a new tab
- [x] Check End dialog is shown and `onboarding_visit_site_cta_shown`
pixel is not fired

### No UI changes
  • Loading branch information
nalcalag authored Nov 29, 2024
1 parent f542da6 commit 808b6a0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ class BrowserTabViewModelTest {
highlightsOnboardingExperimentManager = mockHighlightsOnboardingExperimentManager,
brokenSitePrompt = mockBrokenSitePrompt,
extendedOnboardingPixelsPlugin = extendedOnboardingPixelsPlugin,
userBrowserProperties = mockUserBrowserProperties,
)

val siteFactory = SiteFactoryImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import com.duckduckgo.app.trackerdetection.model.TrackerType
import com.duckduckgo.app.trackerdetection.model.TrackingEvent
import com.duckduckgo.app.widget.ui.WidgetCapabilities
import com.duckduckgo.brokensite.api.BrokenSitePrompt
import com.duckduckgo.browser.api.UserBrowserProperties
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.common.test.InstantSchedulersRule
import com.duckduckgo.duckplayer.api.DuckPlayer
Expand Down Expand Up @@ -124,6 +125,8 @@ class CtaViewModelTest {

private val mockBrokenSitePrompt: BrokenSitePrompt = mock()

private val mockUserBrowserProperties: UserBrowserProperties = mock()

private val requiredDaxOnboardingCtas: List<CtaId> = listOf(
CtaId.DAX_INTRO,
CtaId.DAX_DIALOG_SERP,
Expand Down Expand Up @@ -183,6 +186,7 @@ class CtaViewModelTest {
highlightsOnboardingExperimentManager = mockHighlightsOnboardingExperimentManager,
brokenSitePrompt = mockBrokenSitePrompt,
extendedOnboardingPixelsPlugin = extendedOnboardingPixelsPlugin,
userBrowserProperties = mockUserBrowserProperties,
)
}

Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.HighlightsOnboar
import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.testPrivacyProOnboardingPrimaryButtonMetricPixel
import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.testPrivacyProOnboardingSecondaryButtonMetricPixel
import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.testPrivacyProOnboardingShownMetricPixel
import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.pixels.AppPixelName.ONBOARDING_SKIP_MAJOR_NETWORK_UNIQUE
import com.duckduckgo.app.privacy.db.UserAllowListRepository
import com.duckduckgo.app.settings.db.SettingsDataStore
Expand All @@ -49,6 +50,7 @@ import com.duckduckgo.app.statistics.pixels.Pixel.PixelType.Unique
import com.duckduckgo.app.tabs.model.TabRepository
import com.duckduckgo.app.widget.ui.WidgetCapabilities
import com.duckduckgo.brokensite.api.BrokenSitePrompt
import com.duckduckgo.browser.api.UserBrowserProperties
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.duckplayer.api.DuckPlayer
Expand Down Expand Up @@ -90,6 +92,7 @@ class CtaViewModel @Inject constructor(
private val highlightsOnboardingExperimentManager: HighlightsOnboardingExperimentManager,
private val brokenSitePrompt: BrokenSitePrompt,
private val extendedOnboardingPixelsPlugin: ExtendedOnboardingPixelsPlugin,
private val userBrowserProperties: UserBrowserProperties,
) {
@ExperimentalCoroutinesApi
@VisibleForTesting
Expand Down Expand Up @@ -158,6 +161,20 @@ class CtaViewModel @Inject constructor(
}
}
}

// Temporary pixel
val isVisitSiteSuggestionsCta =
cta is DaxBubbleCta.DaxIntroVisitSiteOptionsCta || cta is DaxBubbleCta.DaxExperimentIntroVisitSiteOptionsCta ||
cta is OnboardingDaxDialogCta.DaxSiteSuggestionsCta || cta is OnboardingDaxDialogCta.DaxExperimentSiteSuggestionsCta
if (isVisitSiteSuggestionsCta) {
if (userBrowserProperties.daysSinceInstalled() <= MIN_DAYS_TO_COUNT_ONBOARDING_CTA_SHOWN) {
val count = onboardingStore.visitSiteCtaDisplayCount ?: 0
pixel.fire(AppPixelName.ONBOARDING_VISIT_SITE_CTA_SHOWN, mapOf("count" to count.toString()))
onboardingStore.visitSiteCtaDisplayCount = count + 1
} else {
onboardingStore.clearVisitSiteCtaDisplayCount()
}
}
}

suspend fun registerDaxBubbleCtaDismissed(cta: Cta) {
Expand Down Expand Up @@ -572,5 +589,6 @@ class CtaViewModel @Inject constructor(

companion object {
private const val MAX_TABS_OPEN_FIRE_EDUCATION = 2
private const val MIN_DAYS_TO_COUNT_ONBOARDING_CTA_SHOWN = 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import com.duckduckgo.app.cta.ui.DaxBubbleCta.DaxDialogIntroOption

interface OnboardingStore {
var onboardingDialogJourney: String?
var visitSiteCtaDisplayCount: Int
fun getSearchOptions(): List<DaxDialogIntroOption>
fun getSitesOptions(): List<DaxDialogIntroOption>
fun getExperimentSearchOptions(): List<DaxDialogIntroOption>
fun clearVisitSiteCtaDisplayCount()
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class OnboardingStoreImpl @Inject constructor(
get() = preferences.getString(ONBOARDING_JOURNEY, null)
set(dialogJourney) = preferences.edit { putString(ONBOARDING_JOURNEY, dialogJourney) }

override var visitSiteCtaDisplayCount: Int
get() = preferences.getInt(VISIT_SITE_CTA_DISPLAY_COUNT, 0)
set(count) = preferences.edit { putInt(VISIT_SITE_CTA_DISPLAY_COUNT, count) }

override fun getSearchOptions(): List<DaxDialogIntroOption> {
val country = Locale.getDefault().country
val language = Locale.getDefault().language
Expand Down Expand Up @@ -207,8 +211,13 @@ class OnboardingStoreImpl @Inject constructor(
)
}

override fun clearVisitSiteCtaDisplayCount() {
preferences.edit { remove(VISIT_SITE_CTA_DISPLAY_COUNT) }
}

companion object {
const val FILENAME = "com.duckduckgo.app.onboarding.settings"
const val ONBOARDING_JOURNEY = "onboardingJourney"
const val VISIT_SITE_CTA_DISPLAY_COUNT = "visitSiteCtaDisplayCount"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
ONBOARDING_DAX_CTA_OK_BUTTON("m_odc_ok"),
ONBOARDING_DAX_CTA_CANCEL_BUTTON("m_onboarding_dax_cta_cancel"),
ONBOARDING_SKIP_MAJOR_NETWORK_UNIQUE("m_onboarding_skip_major_network_unique"),
ONBOARDING_VISIT_SITE_CTA_SHOWN("onboarding_visit_site_cta_shown"),

BROWSER_MENU_ALLOWLIST_ADD("mb_wla"),
BROWSER_MENU_ALLOWLIST_REMOVE("mb_wlr"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.duckduckgo.app.statistics.pixels.Pixel
import com.duckduckgo.app.tabs.model.TabRepository
import com.duckduckgo.app.widget.ui.WidgetCapabilities
import com.duckduckgo.brokensite.api.BrokenSitePrompt
import com.duckduckgo.browser.api.UserBrowserProperties
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.duckplayer.api.DuckPlayer
Expand Down Expand Up @@ -78,6 +79,7 @@ class OnboardingDaxDialogTests {
private val mockHighlightsOnboardingExperimentManager: HighlightsOnboardingExperimentManager = mock()
private val mockBrokenSitePrompt: BrokenSitePrompt = mock()
private val mockExtendedOnboardingPixelsPlugin: ExtendedOnboardingPixelsPlugin = mock()
private val mockUserBrowserProperties: UserBrowserProperties = mock()

val mockEnabledToggle: Toggle = org.mockito.kotlin.mock { on { it.isEnabled() } doReturn true }
val mockDisabledToggle: Toggle = org.mockito.kotlin.mock { on { it.isEnabled() } doReturn false }
Expand All @@ -99,6 +101,7 @@ class OnboardingDaxDialogTests {
mockHighlightsOnboardingExperimentManager,
mockBrokenSitePrompt,
mockExtendedOnboardingPixelsPlugin,
mockUserBrowserProperties,
)
}

Expand Down

0 comments on commit 808b6a0

Please sign in to comment.