Skip to content

Commit

Permalink
Add Pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Oct 26, 2023
1 parent e858801 commit ed94d4a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 33 deletions.
9 changes: 0 additions & 9 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,6 @@ extension MainViewController {
LocalPinningManager.shared.togglePinning(for: .networkProtection)
}

@objc func toggleHomeButton(_ sender: Any) {
LocalPinningManager.shared.togglePinning(for: .homeButton)
if LocalPinningManager.shared.isPinned(.homeButton) {
Pixel.fire(.enableHomeButton)
} else {
Pixel.fire(.disableHomeButton)
}
}

// MARK: - History

@objc func back(_ sender: Any?) {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/NavigationBar/PinningManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ final class LocalPinningManager: PinningManager {
case .autofill: return isPinned(.autofill) ? UserText.hideAutofillShortcut : UserText.showAutofillShortcut
case .bookmarks: return isPinned(.bookmarks) ? UserText.hideBookmarksShortcut : UserText.showBookmarksShortcut
case .downloads: return isPinned(.downloads) ? UserText.hideDownloadsShortcut : UserText.showDownloadsShortcut
case .homeButton: return isPinned(.homeButton) ? UserText.hideHomeShortcut : UserText.showHomeShortcut
case .homeButton: return ""
case .networkProtection:
#if NETWORK_PROTECTION
if !networkProtectionFeatureActivation.isFeatureActivated {
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/NavigationBar/View/HomeButtonMenuFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct HomeButtonMenuFactory {
let buttonPosition = AppearancePreferences.shared.homeButtonposition

let hiddenItem: NSMenuItem = BlockMenuItem(title: UserText.mainMenuHomeButton(for: .hidden), isChecked: !isButtonVisible, block: {
AppearancePreferences.shared.homeButtonposition = .hidden
LocalPinningManager.shared.unpin(.homeButton)
})
let leftItem: NSMenuItem = BlockMenuItem(title: UserText.mainMenuHomeButton(for: .left), isChecked: isButtonVisible && buttonPosition == .left, block: {
Expand Down
11 changes: 0 additions & 11 deletions DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ final class NavigationBarViewController: NSViewController {
private func updateHomeButton() {
let menu = NSMenu()
let title = LocalPinningManager.shared.toggleShortcutInterfaceTitle(for: .homeButton)
menu.addItem(withTitle: title, action: #selector(toggleHomeButtonPinning), keyEquivalent: "")

homeButton.menu = menu
homeButton.toolTip = UserText.homeButtonTooltip
Expand Down Expand Up @@ -854,16 +853,6 @@ extension NavigationBarViewController: NSMenuDelegate {
LocalPinningManager.shared.togglePinning(for: .networkProtection)
}

@objc
private func toggleHomeButtonPinning(_ sender: NSMenuItem) {
LocalPinningManager.shared.togglePinning(for: .homeButton)
if LocalPinningManager.shared.isPinned(.homeButton) {
Pixel.fire(.enableHomeButton)
} else {
Pixel.fire(.disableHomeButton)
}
}

// MARK: - Network Protection

#if NETWORK_PROTECTION
Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/Preferences/Model/AppearancePreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ final class AppearancePreferences: ObservableObject {
@Published var homeButtonposition: HomeButtonPosition {
didSet {
persistor.homeButtonPosition = homeButtonposition
switch homeButtonposition {
case .hidden:
Pixel.fire(.homeButtonHidden)
case .left:
Pixel.fire(.homeButtonLeft)
case .right:
Pixel.fire(.homeButtonRight)
}
}
}

Expand Down
18 changes: 9 additions & 9 deletions DuckDuckGo/Statistics/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ extension Pixel {
case networkProtectionRemoteMessageOpened(messageID: String)

// 28-day Home Button
case enableHomeButton
case disableHomeButton
case setnewHomePage
case homeButtonHidden
case homeButtonLeft
case homeButtonRight

case dailyPixel(Event, isFirst: Bool)

Expand Down Expand Up @@ -470,12 +470,12 @@ extension Pixel.Event {
return "m_mac_netp_remote_message_opened_\(messageID)"

// 28-day Home Button
case .enableHomeButton:
return "m_mac_enable_home_button"
case .disableHomeButton:
return "m_mac_disable_home_button"
case .setnewHomePage:
return "m_mac_set_new_homepage"
case .homeButtonHidden:
return "m_mac_home_button_hidden"
case .homeButtonLeft:
return "m_mac_home_button_left"
case .homeButtonRight:
return "m_mac_home_button_right"

case .dailyPixel(let pixel, isFirst: let isFirst):
return pixel.name + (isFirst ? "_d" : "_c")
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGo/Statistics/PixelParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ extension Pixel.Event {
.networkProtectionRemoteMessageDisplayed,
.networkProtectionRemoteMessageDismissed,
.networkProtectionRemoteMessageOpened,
.enableHomeButton,
.disableHomeButton,
.setnewHomePage:
.homeButtonLeft,
.homeButtonRight,
.homeButtonHidden:
return nil
}
}
Expand Down

0 comments on commit ed94d4a

Please sign in to comment.