Skip to content

Commit

Permalink
re-add settings pixels (#3716)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/392891325557410/1207818776591137/f
Tech Design URL:
CC:

**Description**:
Add pixels for various actions and views in settings.

**Steps to test this PR**:
1. Go through the list of pixels in the linked Asana task and check they
fire at the correct time
2. A pixel fired when a view is opened should not fire again if the user
pops the stack back to that view
3. None of the pixels should have any addition parameters other than the
default (ie app version)
  • Loading branch information
brindy authored Dec 12, 2024
1 parent e0da1b9 commit 52343e2
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 4 deletions.
46 changes: 45 additions & 1 deletion Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ extension Pixel {

// MARK: Pixel Experiment
case pixelExperimentEnrollment

// MARK: Settings
case settingsPresented
case settingsSetAsDefault
case settingsVoiceSearchOn
Expand All @@ -790,6 +792,26 @@ extension Pixel {
case settingsAccessibilityOpen
case settingsAccessiblityTextZoom

case settingsPrivateSearchOpen
case settingsEmailProtectionOpen
case settingsEmailProtectionEnable
case settingsGeneralOpen
case settingsSyncOpen
case settingsAppearanceOpen
case settingsThemeSelectorPressed
case settingsAddressBarTopSelected
case settingsAddressBarBottomSelected
case settingsShowFullURLOn
case settingsShowFullURLOff
case settingsDataClearingOpen
case settingsFireButtonSelectorPressed
case settingsDataClearingClearDataOpen
case settingsAutomaticallyClearDataOn
case settingsAutomaticallyClearDataOff
case settingsNextStepsAddAppToDock
case settingsNextStepsAddWidget
case settingsMoreSearchSettings

// Web pixels
case privacyProOfferMonthlyPriceClick
case privacyProOfferYearlyPriceClick
Expand Down Expand Up @@ -970,7 +992,27 @@ extension Pixel.Event {
case .settingsAutoconsentShown: return "m_settings_autoconsent_shown"
case .settingsAutoconsentOn: return "m_settings_autoconsent_on"
case .settingsAutoconsentOff: return "m_settings_autoconsent_off"


case .settingsPrivateSearchOpen: return "m_settings_private_search_open"
case .settingsEmailProtectionOpen: return "m_settings_email_protection_open"
case .settingsEmailProtectionEnable: return "m_settings_email_protection_enable"
case .settingsGeneralOpen: return "m_settings_general_open"
case .settingsSyncOpen: return "m_settings_sync_open"
case .settingsAppearanceOpen: return "m_settings_appearance_open"
case .settingsThemeSelectorPressed: return "m_settings_theme_selector_pressed"
case .settingsAddressBarTopSelected: return "m_settings_address_bar_top_selected"
case .settingsAddressBarBottomSelected: return "m_settings_address_bar_bottom_selected"
case .settingsShowFullURLOn: return "m_settings_show_full_url_on"
case .settingsShowFullURLOff: return "m_settings_show_full_url_off"
case .settingsDataClearingOpen: return "m_settings_data_clearing_open"
case .settingsFireButtonSelectorPressed: return "m_settings_fire_button_selector_pressed"
case .settingsDataClearingClearDataOpen: return "m_settings_data_clearing_clear_data_open"
case .settingsAutomaticallyClearDataOn: return "m_settings_automatically_clear_data_on"
case .settingsAutomaticallyClearDataOff: return "m_settings_automatically_clear_data_off"
case .settingsNextStepsAddAppToDock: return "m_settings_next_steps_add_app_to_dock"
case .settingsNextStepsAddWidget: return "m_settings_next_steps_add_widget"
case .settingsMoreSearchSettings: return "m_settings_more_search_settings"

case .browsingMenuOpened: return "mb"
case .browsingMenuNewTab: return "mb_tb"
case .browsingMenuAddToBookmarks: return "mb_abk"
Expand Down Expand Up @@ -1673,6 +1715,8 @@ extension Pixel.Event {

// MARK: Pixel Experiment
case .pixelExperimentEnrollment: return "pixel_experiment_enrollment"

// MARK: Settings
case .settingsPresented: return "m_settings_presented"
case .settingsSetAsDefault: return "m_settings_set_as_default"
case .settingsVoiceSearchOn: return "m_settings_voice_search_on"
Expand Down
9 changes: 8 additions & 1 deletion DuckDuckGo/AutoClearSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ class AutoClearSettingsViewController: UITableViewController {

decorate()
}


override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Pixel.fire(pixel: .settingsDataClearingClearDataOpen)
}

private func loadClearDataSettings() -> AutoClearSettingsModel? {
return AutoClearSettingsModel(settings: appSettings)
}
Expand Down Expand Up @@ -152,6 +157,8 @@ class AutoClearSettingsViewController: UITableViewController {
}

@IBAction func onClearDataToggled(_ sender: UISwitch) {
Pixel.fire(pixel: sender.isOn ? .settingsAutomaticallyClearDataOn : .settingsAutomaticallyClearDataOff)

if sender.isOn {
clearDataSettings = AutoClearSettingsModel()
tableView.insertSections(.init(integersIn: Sections.action.rawValue...Sections.timing.rawValue), with: .fade)
Expand Down
8 changes: 7 additions & 1 deletion DuckDuckGo/EmailProtectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ struct EmailProtectionView: View {
.onChange(of: viewModel.shouldShowEmailAlert) { value in
shouldShowEmailAlert = value
}
.onFirstAppear {
Pixel.fire(pixel: .settingsEmailProtectionOpen)
}
}
}

Expand Down Expand Up @@ -90,7 +93,10 @@ struct EmailProtectionViewSettings: View {
// Enable Email Protection
Section {
SettingsCellView(label: UserText.enableEmailProtection,
action: { viewModel.openEmailProtection() },
action: {
viewModel.openEmailProtection()
Pixel.fire(pixel: .settingsEmailProtectionEnable)
},
webLinkIndicator: true,
isButton: true)
}
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/HomeRowInstructionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class HomeRowInstructionsViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
HomeRowReminder().setShown()
Pixel.fire(pixel: .settingsNextStepsAddAppToDock)
}

@IBAction func dismiss() {
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/PrivateSearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct PrivateSearchView: View {
.applySettingsListModifiers(title: UserText.privateSearch,
displayMode: .inline,
viewModel: viewModel)
.onFirstAppear {
Pixel.fire(pixel: .settingsPrivateSearchOpen)
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/SettingsAppearanceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ struct SettingsAppearanceView: View {
.applySettingsListModifiers(title: UserText.settingsAppearanceSection,
displayMode: .inline,
viewModel: viewModel)
.onFirstAppear {
Pixel.fire(pixel: .settingsAppearanceOpen)
}
}
}
3 changes: 3 additions & 0 deletions DuckDuckGo/SettingsDataClearingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ struct SettingsDataClearingView: View {
.applySettingsListModifiers(title: UserText.dataClearing,
displayMode: .inline,
viewModel: viewModel)
.onFirstAppear {
Pixel.fire(pixel: .settingsDataClearingOpen)
}
}
}
3 changes: 3 additions & 0 deletions DuckDuckGo/SettingsGeneralView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,8 @@ struct SettingsGeneralView: View {
.applySettingsListModifiers(title: UserText.general,
displayMode: .inline,
viewModel: viewModel)
.onFirstAppear {
Pixel.fire(pixel: .settingsGeneralOpen)
}
}
}
5 changes: 5 additions & 0 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ final class SettingsViewModel: ObservableObject {
Binding<ThemeName>(
get: { self.state.appTheme },
set: {
Pixel.fire(pixel: .settingsThemeSelectorPressed)
self.state.appTheme = $0
ThemeManager.shared.enableTheme(with: $0)
}
Expand All @@ -118,6 +119,7 @@ final class SettingsViewModel: ObservableObject {
Binding<FireButtonAnimationType>(
get: { self.state.fireButtonAnimation },
set: {
Pixel.fire(pixel: .settingsFireButtonSelectorPressed)
self.appSettings.currentFireButtonAnimation = $0
self.state.fireButtonAnimation = $0
NotificationCenter.default.post(name: AppUserDefaults.Notifications.currentFireButtonAnimationChange, object: self)
Expand All @@ -138,6 +140,7 @@ final class SettingsViewModel: ObservableObject {
self.state.addressBar.position
},
set: {
Pixel.fire(pixel: $0 == .top ? .settingsAddressBarTopSelected : .settingsAddressBarBottomSelected)
self.appSettings.currentAddressBarPosition = $0
self.state.addressBar.position = $0
}
Expand All @@ -148,6 +151,7 @@ final class SettingsViewModel: ObservableObject {
Binding<Bool>(
get: { self.state.showsFullURL },
set: {
Pixel.fire(pixel: $0 ? .settingsShowFullURLOn : .settingsShowFullURLOff)
self.state.showsFullURL = $0
self.appSettings.showFullSiteAddress = $0
}
Expand Down Expand Up @@ -598,6 +602,7 @@ extension SettingsViewModel {
}

func openMoreSearchSettings() {
Pixel.fire(pixel: .settingsMoreSearchSettings)
UIApplication.shared.open(URL.searchSettings)
}

Expand Down
5 changes: 5 additions & 0 deletions DuckDuckGo/SyncSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ class SyncSettingsViewController: UIHostingController<SyncSettingsView> {
syncService.scheduler.requestSyncImmediately()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Pixel.fire(pixel: .settingsSyncOpen)
}

func updateOptions() {
syncService.scheduler.requestSyncImmediately()
}
Expand Down
6 changes: 5 additions & 1 deletion DuckDuckGo/WidgetEducationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ struct WidgetEducationView: View {
.padding(.horizontal)
.padding(.top, Const.Padding.top)
}
}.navigationBarTitle(navBarTitle, displayMode: .inline)
}
.navigationBarTitle(navBarTitle, displayMode: .inline)
.onFirstAppear {
Pixel.fire(pixel: .settingsNextStepsAddWidget)
}
}

private var secondParagraphText: Text {
Expand Down

0 comments on commit 52343e2

Please sign in to comment.