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

Add new iOS pixels for measuring navigation #2730

Merged
merged 13 commits into from
Apr 16, 2024
93 changes: 79 additions & 14 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ extension Pixel {
case appLaunch
case refreshPressed
case pullToRefresh


case deviceOrientationLandscape

case keyboardGoWhileOnNTP
case keyboardGoWhileOnWebsite
case keyboardGoWhileOnSERP

case forgetAllPressedBrowsing
case forgetAllPressedTabSwitching
case forgetAllExecuted
Expand All @@ -48,7 +54,12 @@ extension Pixel {
case tabSwitcherNewLayoutSeen
case tabSwitcherListEnabled
case tabSwitcherGridEnabled

case tabSwitcherNewTab
case tabSwitcherSwitchTabs
case tabSwitcherClickCloseTab
case tabSwitcherSwipeCloseTab
case tabSwitchLongPressNewTab

case settingsDoNotSellShown
case settingsDoNotSellOn
case settingsDoNotSellOff
Expand Down Expand Up @@ -77,7 +88,17 @@ extension Pixel {

case addressBarShare
case addressBarSettings

case addressBarCancelPressedOnNTP
case addressBarCancelPressedOnWebsite
case addressBarCancelPressedOnSERP
case addressBarClickOnNTP
case addressBarClickOnWebsite
case addressBarClickOnSERP
case addressBarClearPressedOnNTP
case addressBarClearPressedOnWebsite
case addressBarClearPressedOnSERP
case addressBarGestureDismiss

case shareSheetResultSuccess
case shareSheetResultFail
case shareSheetActivityCopy
Expand All @@ -95,10 +116,13 @@ extension Pixel {
case tabBarTabSwitcherPressed

case homeScreenShown
case homeScreenFavouriteLaunched
case homeScreenEditFavorite
case homeScreenDeleteFavorite


case favoriteLaunchedNTP
case favoriteLaunchedWebsite
case favoriteLaunchedWidget

case autocompleteClickPhrase
case autocompleteClickWebsite
case autocompleteClickBookmark
Expand Down Expand Up @@ -135,7 +159,14 @@ extension Pixel {
case voiceSearchDone
case openVoiceSearch
case voiceSearchCancelled


case bookmarkLaunchList
case bookmarkLaunchScored
case bookmarkAddFavoriteFromBookmark
case bookmarkRemoveFavoriteFromBookmark
case bookmarkAddFavoriteBySwipe
case bookmarkDeletedFromBookmark

case bookmarkImportSuccess
case bookmarkImportFailure
case bookmarkImportFailureParsingDL
Expand Down Expand Up @@ -509,7 +540,8 @@ extension Pixel {

case swipeTabsUsed
case swipeTabsUsedDaily

case swipeToOpenNewTab

case bookmarksCleanupFailed
case bookmarksCleanupAttemptedWhileSyncWasEnabled
case favoritesCleanupFailed
Expand Down Expand Up @@ -657,7 +689,13 @@ extension Pixel.Event {
case .appLaunch: return "ml"
case .refreshPressed: return "m_r"
case .pullToRefresh: return "m_pull-to-reload"


case .deviceOrientationLandscape: return "m_device_orientation_landscape"

case .keyboardGoWhileOnNTP: return "m_keyboard_go_click_ntp"
case .keyboardGoWhileOnWebsite: return "m_keyboard_go_click_website"
case .keyboardGoWhileOnSERP: return "m_keyboard_go_click_serp"

case .forgetAllPressedBrowsing: return "mf_bp"
case .forgetAllPressedTabSwitching: return "mf_tp"
case .forgetAllExecuted: return "mf"
Expand All @@ -673,7 +711,12 @@ extension Pixel.Event {
case .tabSwitcherNewLayoutSeen: return "m_ts_n"
case .tabSwitcherListEnabled: return "m_ts_l"
case .tabSwitcherGridEnabled: return "m_ts_g"

case .tabSwitcherNewTab: return "m_tab_manager_new_tab_click"
case .tabSwitcherSwitchTabs: return "m_tab_manager_switch_tabs"
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 .settingsDoNotSellShown: return "ms_dns"
case .settingsDoNotSellOn: return "ms_dns_on"
case .settingsDoNotSellOff: return "ms_dns_off"
Expand All @@ -700,9 +743,20 @@ extension Pixel.Event {
case .browsingMenuAutofill: return "m_nav_autofill_menu_item_pressed"

case .browsingMenuShare: return "m_browsingmenu_share"

case .addressBarShare: return "m_addressbar_share"
case .addressBarSettings: return "m_addressbar_settings"
case .addressBarCancelPressedOnNTP: return "m_addressbar_cancel_ntp"
case .addressBarCancelPressedOnWebsite: return "m_addressbar_cancel_website"
case .addressBarCancelPressedOnSERP: return "m_addressbar_cancel_serp"
case .addressBarClickOnNTP: return "m_addressbar_click_ntp"
case .addressBarClickOnWebsite: return "m_addressbar_click_website"
case .addressBarClickOnSERP: return "m_addressbar_click_serp"
case .addressBarClearPressedOnNTP: return "m_addressbar_focus_clear_entry_ntp"
case .addressBarClearPressedOnWebsite: return "m_addressbar_focus_clear_entry_website"
case .addressBarClearPressedOnSERP: return "m_addressbar_focus_clear_entry_serp"
case .addressBarGestureDismiss: return "m_addressbar_focus_dismiss_gesture"

case .shareSheetResultSuccess: return "m_sharesheet_result_success"
case .shareSheetResultFail: return "m_sharesheet_result_fail"
case .shareSheetActivityCopy: return "m_sharesheet_activity_copy"
Expand All @@ -718,12 +772,22 @@ extension Pixel.Event {
case .bookmarksButtonPressed: return "mt_bm"
case .tabBarBookmarksLongPressed: return "mt_bl"
case .tabBarTabSwitcherPressed: return "mt_tb"


case .bookmarkLaunchList: return "m_bookmark_launch_list"
case .bookmarkLaunchScored: return "m_bookmark_launch_scored"
case .bookmarkAddFavoriteFromBookmark: return "m_add_favorite_from_bookmark"
case .bookmarkRemoveFavoriteFromBookmark: return "m_remove_favorite_from_bookmark"
case .bookmarkAddFavoriteBySwipe: return "m_add_favorite_by_swipe"
case .bookmarkDeletedFromBookmark: return "m_bookmark_deleted_from_bookmark"

case .homeScreenShown: return "mh"
case .homeScreenFavouriteLaunched: return "mh_fl"
case .homeScreenEditFavorite: return "mh_ef"
case .homeScreenDeleteFavorite: return "mh_df"


case .favoriteLaunchedNTP: return "m_favorite_launched_ntp"
case .favoriteLaunchedWebsite: return "m_favorite_launched_website"
case .favoriteLaunchedWidget: return "m_favorite_launched_widget"

case .autocompleteClickPhrase: return "m_autocomplete_click_phrase"
case .autocompleteClickWebsite: return "m_autocomplete_click_website"
case .autocompleteClickBookmark: return "m_autocomplete_click_bookmark"
Expand Down Expand Up @@ -1120,7 +1184,8 @@ extension Pixel.Event {

case .swipeTabsUsed: return "m_swipe-tabs-used"
case .swipeTabsUsedDaily: return "m_swipe-tabs-used-daily"

case .swipeToOpenNewTab: return "m_addressbar_swipe_new_tab"

case .bookmarksCleanupFailed: return "m_d_bookmarks_cleanup_failed"
case .bookmarksCleanupAttemptedWhileSyncWasEnabled: return "m_d_bookmarks_cleanup_attempted_while_sync_was_enabled"
case .favoritesCleanupFailed: return "m_d_favorites_cleanup_failed"
Expand Down
9 changes: 9 additions & 0 deletions DuckDuckGo/AddOrEditBookmarkViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ class AddOrEditBookmarkViewController: UIViewController {
}

func saveAndDismiss() {
let changes = viewModel.bookmark.changedValues()
if changes.contains(where: { $0.key == #keyPath(BookmarkEntity.favoriteFolders) }) {
if viewModel.bookmark.isFavorite(on: viewModel.favoritesDisplayMode.displayedFolder) {
Pixel.fire(pixel: .bookmarkAddFavoriteFromBookmark)
} else {
Pixel.fire(pixel: .bookmarkRemoveFavoriteFromBookmark)
}
}

viewModel.save()
WidgetCenter.shared.reloadAllTimelines()
self.delegate?.finishedEditing(self, entityID: viewModel.bookmark.objectID)
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/AutocompleteViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class AutocompleteViewController: UIViewController {
}

@IBAction func onAutocompleteDismissed(_ sender: Any) {
Pixel.fire(pixel: .addressBarGestureDismiss)
delegate?.autocompleteWasDismissed()
}
}
Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/BlankSnapshotViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ extension BlankSnapshotViewController: OmniBarDelegate {
userInteractionDetected()
}

func onTextFieldWillBeginEditing(_ omniBar: OmniBar, tapped: Bool) {
// No-op
}

func onTextFieldDidBeginEditing(_ omniBar: OmniBar) -> Bool {
DispatchQueue.main.async {
self.viewCoordinator.omniBar.resignFirstResponder()
Expand All @@ -186,6 +190,10 @@ extension BlankSnapshotViewController: OmniBarDelegate {
func onEnterPressed() {
userInteractionDetected()
}

func onClearPressed() {
// No-op
}
}

extension BlankSnapshotViewController: TabSwitcherButtonDelegate {
Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/BookmarksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ class BookmarksViewController: UIViewController, UITableViewDelegate {
private func didSelectScoredBookmarkAtIndex(_ index: Int) {
guard searchDataSource.results.indices.contains(index) else { return }
dismiss()

Pixel.fire(pixel: .bookmarkLaunchScored)
delegate?.bookmarksDidSelect(url: searchDataSource.results[index].url)
}

Expand Down Expand Up @@ -351,6 +353,10 @@ class BookmarksViewController: UIViewController, UITableViewDelegate {
}

private func toggleFavoriteAfterSwipe(_ bookmark: BookmarkEntity, _ indexPath: IndexPath) {
if !bookmark.isFavorite(on: viewModel.favoritesDisplayMode.displayedFolder) {
Pixel.fire(pixel: .bookmarkAddFavoriteBySwipe)
}

self.viewModel.toggleFavorite(bookmark)
WidgetCenter.shared.reloadAllTimelines()

Expand Down Expand Up @@ -826,6 +832,7 @@ class BookmarksViewController: UIViewController, UITableViewDelegate {
fileprivate func select(bookmark: BookmarkEntity) {
guard let url = bookmark.urlObject else { return }
dismiss()
Pixel.fire(pixel: .bookmarkLaunchList)
delegate?.bookmarksDidSelect(url: url)
}

Expand Down Expand Up @@ -926,6 +933,7 @@ extension BookmarksViewController: AddOrEditBookmarkViewControllerDelegate {
assertionFailure()
return
}
Pixel.fire(pixel: .bookmarkDeletedFromBookmark)
showBookmarkDeletedMessage(bookmark)
viewModel.softDeleteBookmark(bookmark)
refreshFooterView()
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ extension HomeViewController: FavoritesHomeViewSectionRendererDelegate {

func favoritesRenderer(_ renderer: FavoritesHomeViewSectionRenderer, didSelect favorite: BookmarkEntity) {
guard let url = favorite.urlObject else { return }
Pixel.fire(pixel: .homeScreenFavouriteLaunched)
Pixel.fire(pixel: .favoriteLaunchedNTP)
Favicons.shared.loadFavicon(forDomain: url.host, intoCache: .fireproof, fromCache: .tabs)
delegate?.home(self, didRequestUrl: url)
}
Expand Down
8 changes: 4 additions & 4 deletions DuckDuckGo/MainViewController+KeyCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ extension MainViewController {
guard tabSwitcherController == nil else { return }
findInPageView.done()
hideSuggestionTray()
onCancelPressed()
performCancel()
}

@objc func keyboardNewTab() {
Expand All @@ -188,7 +188,7 @@ extension MainViewController {
guard let tab = currentTab else { return }
guard let index = tabManager.model.indexOf(tab: tab.tabModel) else { return }
let targetTabIndex = index + 1 >= tabManager.model.count ? 0 : index + 1
onCancelPressed()
performCancel()
select(tabAt: targetTabIndex)
}

Expand All @@ -198,14 +198,14 @@ extension MainViewController {
guard let tab = currentTab else { return }
guard let index = tabManager.model.indexOf(tab: tab.tabModel) else { return }
let targetTabIndex = index - 1 < 0 ? tabManager.model.count - 1 : index - 1
onCancelPressed()
performCancel()
select(tabAt: targetTabIndex)
}

@objc func keyboardShowAllTabs() {
guard tabSwitcherController == nil else { return }

onCancelPressed()
performCancel()
showTabSwitcher()
}

Expand Down
Loading
Loading