Skip to content

Commit

Permalink
Add Events Firing for Phishing Detection Settings (#3379)
Browse files Browse the repository at this point in the history
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"]`

<!--
Tagging instructions
If this PR isn't ready to be merged for whatever reason it should be
marked with the `DO NOT MERGE` label (particularly if it's a draft)
If it's pending Product Review/PFR, please add the `Pending Product
Review` label.

If at any point it isn't actively being worked on/ready for
review/otherwise moving forward (besides the above PR/PFR exception)
strongly consider closing it (or not opening it in the first place). If
you decide not to close it, make sure it's labelled to make it clear the
PRs state and comment with more information.
-->

**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)
  • Loading branch information
not-a-rootkit authored Oct 15, 2024
1 parent f9fbb59 commit b881cd1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/PhishingDetection/PhishingDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/Preferences/View/PreferencesGeneralView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import PreferencesViews
import SwiftUI
import SwiftUIExtensions
import PixelKit
import PhishingDetection

extension Preferences {

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SubscriptionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit b881cd1

Please sign in to comment.