From b881cd19eb307895d2a1b9ddbd07517c22f3da28 Mon Sep 17 00:00:00 2001 From: Thom Espach Date: Tue, 15 Oct 2024 17:39:34 +0100 Subject: [PATCH] Add Events Firing for Phishing Detection Settings (#3379) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task/Issue URL: https://app.asana.com/0/72649045549333/1208270234071171/f Tech Design URL: n/a CC: **Description**: In [✓ Phishing Detection Pixels](https://app.asana.com/0/0/1207699541075655/f) we defined several pixels to include, and one of them did not make it into the initial release: - macos.phishing-detection.feature-toggled: - Parameters: - newState - on/off, indicating whether the user turned it on or off - Condition - triggers when a user disables the feature from the settings page - Reasoning - the aim is to use this as a "do-no-harm" KPI, to determine how many users are actively choosing to disable/enable phishing protection **Steps to test this PR**: 1. Point BSK to tespach/phish-det-settings-event 2. Build the browser 3. Filter by `m_mac_phishing_detection_setting-toggled` in the debug output of the app 4. Ensure you're authenticated via use-login.duckduckgo.com - this feature is internal only 5. Go to Settings>General 6. Toggle "Malicious Site Protection" 7. Return to debug output and ensure you see: 8. `👾[Standard-Fired] m_mac_phishing_detection_setting-toggled ["appVersion": "1.109.0", "pixelSource": "browser-dmg", "setting_toggled_to": "false"]` **Definition of Done**: * [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)? --- ###### Internal references: [Pull Request Review Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f) [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) [Pull Request Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f) --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- DuckDuckGo/PhishingDetection/PhishingDetection.swift | 2 ++ DuckDuckGo/Preferences/View/PreferencesGeneralView.swift | 4 ++++ LocalPackages/DataBrokerProtection/Package.swift | 2 +- LocalPackages/NetworkProtectionMac/Package.swift | 2 +- LocalPackages/SubscriptionUI/Package.swift | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 48d2f3b408..d349bbcc7c 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -14288,7 +14288,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 199.1.0; + version = 199.2.0; }; }; 9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo/PhishingDetection/PhishingDetection.swift b/DuckDuckGo/PhishingDetection/PhishingDetection.swift index b6acd15486..67f2313f1a 100644 --- a/DuckDuckGo/PhishingDetection/PhishingDetection.swift +++ b/DuckDuckGo/PhishingDetection/PhishingDetection.swift @@ -156,6 +156,8 @@ public class PhishingDetection: PhishingSiteDetecting { PixelKit.fire(PhishingDetectionEvents.visitSite) case .updateTaskFailed48h(error: let error): PixelKit.fire(PhishingDetectionEvents.updateTaskFailed48h(error: error)) + case .settingToggled(to: let settingState): + PixelKit.fire(PhishingDetectionEvents.settingToggled(to: settingState)) } }) let resolvedUpdateManager = updateManager ?? PhishingDetectionUpdateManager(client: detectionClient, dataStore: resolvedDataStore) diff --git a/DuckDuckGo/Preferences/View/PreferencesGeneralView.swift b/DuckDuckGo/Preferences/View/PreferencesGeneralView.swift index 8ecab2ee30..36a0d4768c 100644 --- a/DuckDuckGo/Preferences/View/PreferencesGeneralView.swift +++ b/DuckDuckGo/Preferences/View/PreferencesGeneralView.swift @@ -22,6 +22,7 @@ import PreferencesViews import SwiftUI import SwiftUIExtensions import PixelKit +import PhishingDetection extension Preferences { @@ -199,6 +200,9 @@ extension Preferences { PreferencePaneSubSection { ToggleMenuItem(UserText.phishingDetectionIsEnabled, isOn: $phishingDetectionModel.isEnabled) + .onChange(of: phishingDetectionModel.isEnabled) { newValue in + PixelKit.fire(PhishingDetectionEvents.settingToggled(to: newValue)) + } }.padding(.bottom, 5) Text(UserText.phishingDetectionEnabledWarning) .font(.footnote) diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index 4f5df8ebf9..f8efa75684 100644 --- a/LocalPackages/DataBrokerProtection/Package.swift +++ b/LocalPackages/DataBrokerProtection/Package.swift @@ -29,7 +29,7 @@ let package = Package( targets: ["DataBrokerProtection"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "199.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "199.2.0"), .package(path: "../SwiftUIExtensions"), .package(path: "../XPCHelper"), ], diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index 92ee8f95e3..05c43f14b1 100644 --- a/LocalPackages/NetworkProtectionMac/Package.swift +++ b/LocalPackages/NetworkProtectionMac/Package.swift @@ -32,7 +32,7 @@ let package = Package( .library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "199.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "199.2.0"), .package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"), .package(path: "../AppLauncher"), .package(path: "../UDSHelper"), diff --git a/LocalPackages/SubscriptionUI/Package.swift b/LocalPackages/SubscriptionUI/Package.swift index 47e68ab6d7..3ef44085af 100644 --- a/LocalPackages/SubscriptionUI/Package.swift +++ b/LocalPackages/SubscriptionUI/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["SubscriptionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "199.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "199.2.0"), .package(path: "../SwiftUIExtensions") ], targets: [