Skip to content
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 @@ -7902,4 +7902,46 @@ class BrowserTabViewModelTest {

override fun getPlugins(): Collection<PostMessageWrapperPlugin> = listOf(plugin)
}

@Test
fun whenVpnMenuClickedWithNotSubscribedStateThenPixelFiredWithPillStatus() {
testee.browserViewState.value = browserViewState().copy(
vpnMenuState = VpnMenuState.NotSubscribed,
)

testee.onVpnMenuClicked()

verify(mockPixel).fire(
AppPixelName.MENU_ACTION_VPN_PRESSED,
mapOf(PixelParameter.STATUS to "pill"),
)
}

@Test
fun whenVpnMenuClickedWithNotSubscribedNoPillStateThenPixelFiredWithNoPillStatus() {
testee.browserViewState.value = browserViewState().copy(
vpnMenuState = VpnMenuState.NotSubscribedNoPill,
)

testee.onVpnMenuClicked()

verify(mockPixel).fire(
AppPixelName.MENU_ACTION_VPN_PRESSED,
mapOf(PixelParameter.STATUS to "no_pill"),
)
}

@Test
fun whenVpnMenuClickedWithSubscribedStateThenPixelFiredWithSubscribedStatus() {
testee.browserViewState.value = browserViewState().copy(
vpnMenuState = VpnMenuState.Subscribed(isVpnEnabled = true),
)

testee.onVpnMenuClicked()

verify(mockPixel).fire(
AppPixelName.MENU_ACTION_VPN_PRESSED,
mapOf(PixelParameter.STATUS to "subscribed"),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4465,18 +4465,22 @@ class BrowserTabViewModel @Inject constructor(

fun onVpnMenuClicked() {
val vpnMenuState = currentBrowserViewState().vpnMenuState
when (vpnMenuState) {
val statusParam = when (vpnMenuState) {
VpnMenuState.NotSubscribed -> {
command.value = LaunchPrivacyPro("https://duckduckgo.com/pro?origin=funnel_appmenu_android".toUri())
"pill"
}
VpnMenuState.NotSubscribedNoPill -> {
command.value = LaunchPrivacyPro("https://duckduckgo.com/pro?origin=funnel_appmenu_android".toUri())
"no_pill"
}
is VpnMenuState.Subscribed -> {
command.value = LaunchVpnManagement
"subscribed"
}
VpnMenuState.Hidden -> {} // Should not happen as menu item should not be visible
VpnMenuState.Hidden -> "" // Should not happen as menu item should not be visible
}
pixel.fire(AppPixelName.MENU_ACTION_VPN_PRESSED, mapOf(PixelParameter.STATUS to statusParam))
}

fun onAutoConsentPopUpHandled(isCosmetic: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
MENU_ACTION_APP_LINKS_OPEN_PRESSED("m_nav_app_links_open_menu_item_pressed"),
MENU_ACTION_DOWNLOADS_PRESSED("m_nav_downloads_menu_item_pressed"),
MENU_ACTION_AUTOFILL_PRESSED("m_nav_autofill_menu_item_pressed"),
MENU_ACTION_VPN_PRESSED("m_nav_vpn_menu_item_pressed"),

FIREPROOF_WEBSITE_ADDED("m_fw_a"),
FIREPROOF_WEBSITE_REMOVE("m_fw_r"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ interface Pixel {
const val IS_TAB_SWITCHER_BUTTON_SHOWN = "is_tab_switcher_button_shown"
const val IS_FIRE_BUTTON_SHOWN = "is_fire_button_shown"
const val IS_BROWSER_MENU_BUTTON_SHOWN = "is_browser_menu_button_shown"
const val STATUS = "status"
}

object PixelValues {
Expand Down
Loading