Skip to content

Commit aa5392d

Browse files
authored
Add pixel for VPN menu item (#6908)
Task/Issue URL: https://app.asana.com/1/137249556945/task/1211542874528796?focus=true ### Description Add temporary pixel when VPN menu item is selected ### Steps to test this PR _Pre-steps_ - [x] Apply PPro patch -> https://app.asana.com/1/137249556945/project/1209991789468715/task/1210448620621729?focus=true - [x] Set device language to English (United Kingdom) _Not Subscribed_ - [x] Fresh install - [x] Open a new tab page - [x] VPN menu item will show with yellow pill "TRY FOR FREE" - [x] Tap on VPN menu item - [x] Check in Logcat pixel is sent: `Pixel sent: m_nav_vpn_menu_item_pressed with params: {status=pill}` _Not Subscribed & No Pill_ - [x] Open a new tab - [x] Open overflow menu at least 3 more times - [x] Open a new tab - [x] Open overflow menu - [x] VPN menu item doesn't have the yellow 'TRY FOR FREE' pill anymore - [x] Tab on VPN item - [x] Check in Logcat pixel is sent: `Pixel sent: m_nav_vpn_menu_item_pressed with params: {status=no_pill}` _Subscribed_ - [ ] Purchase a test subscription - [ ] Go to browser and open a new tab - [ ] Open overflow menu - [ ] Tap on VPN menu item - [ ] Check in Logcat pixel is sent: `Pixel sent: m_nav_vpn_menu_item_pressed with params: {status=subscribed}` ### No UI changes
1 parent 1ff382e commit aa5392d

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7928,4 +7928,46 @@ class BrowserTabViewModelTest {
79287928

79297929
override fun getPlugins(): Collection<PostMessageWrapperPlugin> = listOf(plugin)
79307930
}
7931+
7932+
@Test
7933+
fun whenVpnMenuClickedWithNotSubscribedStateThenPixelFiredWithPillStatus() {
7934+
testee.browserViewState.value = browserViewState().copy(
7935+
vpnMenuState = VpnMenuState.NotSubscribed,
7936+
)
7937+
7938+
testee.onVpnMenuClicked()
7939+
7940+
verify(mockPixel).fire(
7941+
AppPixelName.MENU_ACTION_VPN_PRESSED,
7942+
mapOf(PixelParameter.STATUS to "pill"),
7943+
)
7944+
}
7945+
7946+
@Test
7947+
fun whenVpnMenuClickedWithNotSubscribedNoPillStateThenPixelFiredWithNoPillStatus() {
7948+
testee.browserViewState.value = browserViewState().copy(
7949+
vpnMenuState = VpnMenuState.NotSubscribedNoPill,
7950+
)
7951+
7952+
testee.onVpnMenuClicked()
7953+
7954+
verify(mockPixel).fire(
7955+
AppPixelName.MENU_ACTION_VPN_PRESSED,
7956+
mapOf(PixelParameter.STATUS to "no_pill"),
7957+
)
7958+
}
7959+
7960+
@Test
7961+
fun whenVpnMenuClickedWithSubscribedStateThenPixelFiredWithSubscribedStatus() {
7962+
testee.browserViewState.value = browserViewState().copy(
7963+
vpnMenuState = VpnMenuState.Subscribed(isVpnEnabled = true),
7964+
)
7965+
7966+
testee.onVpnMenuClicked()
7967+
7968+
verify(mockPixel).fire(
7969+
AppPixelName.MENU_ACTION_VPN_PRESSED,
7970+
mapOf(PixelParameter.STATUS to "subscribed"),
7971+
)
7972+
}
79317973
}

app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4469,18 +4469,22 @@ class BrowserTabViewModel @Inject constructor(
44694469

44704470
fun onVpnMenuClicked() {
44714471
val vpnMenuState = currentBrowserViewState().vpnMenuState
4472-
when (vpnMenuState) {
4472+
val statusParam = when (vpnMenuState) {
44734473
VpnMenuState.NotSubscribed -> {
44744474
command.value = LaunchPrivacyPro("https://duckduckgo.com/pro?origin=funnel_appmenu_android".toUri())
4475+
"pill"
44754476
}
44764477
VpnMenuState.NotSubscribedNoPill -> {
44774478
command.value = LaunchPrivacyPro("https://duckduckgo.com/pro?origin=funnel_appmenu_android".toUri())
4479+
"no_pill"
44784480
}
44794481
is VpnMenuState.Subscribed -> {
44804482
command.value = LaunchVpnManagement
4483+
"subscribed"
44814484
}
4482-
VpnMenuState.Hidden -> {} // Should not happen as menu item should not be visible
4485+
VpnMenuState.Hidden -> "" // Should not happen as menu item should not be visible
44834486
}
4487+
pixel.fire(AppPixelName.MENU_ACTION_VPN_PRESSED, mapOf(PixelParameter.STATUS to statusParam))
44844488
}
44854489

44864490
fun onAutoConsentPopUpHandled(isCosmetic: Boolean) {

app/src/main/java/com/duckduckgo/app/pixels/AppPixelName.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
263263
MENU_ACTION_APP_LINKS_OPEN_PRESSED("m_nav_app_links_open_menu_item_pressed"),
264264
MENU_ACTION_DOWNLOADS_PRESSED("m_nav_downloads_menu_item_pressed"),
265265
MENU_ACTION_AUTOFILL_PRESSED("m_nav_autofill_menu_item_pressed"),
266+
MENU_ACTION_VPN_PRESSED("m_nav_vpn_menu_item_pressed"),
266267

267268
FIREPROOF_WEBSITE_ADDED("m_fw_a"),
268269
FIREPROOF_WEBSITE_REMOVE("m_fw_r"),

statistics/statistics-api/src/main/java/com/duckduckgo/app/statistics/pixels/Pixel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ interface Pixel {
7171
const val IS_TAB_SWITCHER_BUTTON_SHOWN = "is_tab_switcher_button_shown"
7272
const val IS_FIRE_BUTTON_SHOWN = "is_fire_button_shown"
7373
const val IS_BROWSER_MENU_BUTTON_SHOWN = "is_browser_menu_button_shown"
74+
const val STATUS = "status"
7475
}
7576

7677
object PixelValues {

0 commit comments

Comments
 (0)