Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary pixel for visit site suggestions CTA display count #5309

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -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
17 changes: 17 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() <= 3) {
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
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 ?: 0) }

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
Loading