Skip to content

Commit

Permalink
fire tab switcher / manager sources pixel (#3722)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations. Feel free to change it, although assigning a GitHub
reviewer and the items in bold are required.

⚠️ If you're an external contributor, please file an issue first before
working on a PR, as we can't guarantee that we will accept your changes
if they haven't been discussed ahead of time. Thanks!
-->

Task/Issue URL:
https://app.asana.com/0/392891325557410/1208882840835128/f
Tech Design URL:
CC:

**Description**:
Fires a pixel depending on what is going on when the user opens the tab
switcher.

Also renames a couple of pixels for clarity.

**Steps to test this PR**: 

1. Open the tab switcher from anywhere should fire
`m_tab_manager_opened_daily` but only the first time during in a day
2. Open the tab switcher from anywhere should fire
`m_tab_manager_opened` every time
1. Open the tab switcher on the new tab page should fire
`m_tab_manager_open_from_newtabpage` every time
2. Open the tab switcher while on the serp should fire
`m_tab_manager_open_from_serp` every time
3. Open the tab switcher while on a website should fire
`m_tab_manager_open_from_website` every time
  • Loading branch information
brindy authored Dec 13, 2024
1 parent 6409067 commit 4d78d09
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
16 changes: 12 additions & 4 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ extension Pixel {
case tabSwitcherClickCloseTab
case tabSwitcherSwipeCloseTab
case tabSwitchLongPressNewTab
case tabSwitcherOpenDaily
case tabSwitcherOpenedDaily

case tabSwitcherOpenedFromSerp
case tabSwitcherOpenedFromWebsite
case tabSwitcherOpenedFromNewTabPage

case settingsDoNotSellShown
case settingsDoNotSellOn
Expand Down Expand Up @@ -118,7 +122,7 @@ extension Pixel {
case tabBarForwardPressed
case bookmarksButtonPressed
case tabBarBookmarksLongPressed
case tabBarTabSwitcherPressed
case tabBarTabSwitcherOpened

case homeScreenShown
case homeScreenEditFavorite
Expand Down Expand Up @@ -984,7 +988,11 @@ extension Pixel.Event {
case .tabSwitcherClickCloseTab: return "m_tab_manager_close_tab_click"
case .tabSwitcherSwipeCloseTab: return "m_tab_manager_close_tab_swipe"
case .tabSwitchLongPressNewTab: return "m_tab_manager_long_press_new_tab"
case .tabSwitcherOpenDaily: return "m_tab_manager_clicked_daily"
case .tabSwitcherOpenedDaily: return "m_tab_manager_opened_daily"

case .tabSwitcherOpenedFromSerp: return "m_tab_manager_open_from_serp"
case .tabSwitcherOpenedFromWebsite: return "m_tab_manager_open_from_website"
case .tabSwitcherOpenedFromNewTabPage: return "m_tab_manager_open_from_newtabpage"

case .settingsDoNotSellShown: return "ms_dns"
case .settingsDoNotSellOn: return "ms_dns_on"
Expand Down Expand Up @@ -1064,7 +1072,7 @@ extension Pixel.Event {
case .tabBarForwardPressed: return "mt_fw"
case .bookmarksButtonPressed: return "mt_bm"
case .tabBarBookmarksLongPressed: return "mt_bl"
case .tabBarTabSwitcherPressed: return "mt_tb"
case .tabBarTabSwitcherOpened: return "m_tab_manager_opened"

case .bookmarkLaunchList: return "m_bookmark_launch_list"
case .bookmarkLaunchScored: return "m_bookmark_launch_scored"
Expand Down
11 changes: 9 additions & 2 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2611,8 +2611,15 @@ extension MainViewController: TabSwitcherButtonDelegate {
}

func showTabSwitcher(_ button: TabSwitcherButton) {
Pixel.fire(pixel: .tabBarTabSwitcherPressed)
DailyPixel.fireDaily(.tabSwitcherOpenDaily, withAdditionalParameters: TabSwitcherOpenDailyPixel().parameters(with: tabManager.model.tabs))
Pixel.fire(pixel: .tabBarTabSwitcherOpened)
DailyPixel.fireDaily(.tabSwitcherOpenedDaily, withAdditionalParameters: TabSwitcherOpenDailyPixel().parameters(with: tabManager.model.tabs))
if currentTab?.url?.isDuckDuckGoSearch == true {
Pixel.fire(pixel: .tabSwitcherOpenedFromSerp)
} else if currentTab?.url != nil {
Pixel.fire(pixel: .tabSwitcherOpenedFromWebsite)
} else {
Pixel.fire(pixel: .tabSwitcherOpenedFromNewTabPage)
}

performCancel()
showTabSwitcher()
Expand Down

0 comments on commit 4d78d09

Please sign in to comment.