From 723dbb9db3ca6852c2ebc92408c9893fe1c338de Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Wed, 18 Dec 2024 14:47:01 +0600 Subject: [PATCH 1/3] Update pixels --- .../MaliciousSiteDetector.swift | 4 +- .../MaliciousSiteProtection/Model/Event.swift | 46 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Sources/MaliciousSiteProtection/MaliciousSiteDetector.swift b/Sources/MaliciousSiteProtection/MaliciousSiteDetector.swift index 1a637a73a..998c397c6 100644 --- a/Sources/MaliciousSiteProtection/MaliciousSiteDetector.swift +++ b/Sources/MaliciousSiteProtection/MaliciousSiteDetector.swift @@ -110,7 +110,7 @@ public final class MaliciousSiteDetector: MaliciousSiteDetecting { for threatKind in hashPrefixMatchingThreatKinds { let matches = await checkLocalFilters(hostHash: hostHash, canonicalUrl: canonicalUrl, for: threatKind) if matches { - eventMapping.fire(.errorPageShown(clientSideHit: true, threatKind: threatKind)) + eventMapping.fire(.errorPageShown(category: threatKind, clientSideHit: true)) return threatKind } } @@ -120,7 +120,7 @@ public final class MaliciousSiteDetector: MaliciousSiteDetecting { let match = await checkApiMatches(hostHash: hostHash, canonicalUrl: canonicalUrl) if let match { let threatKind = match.category.flatMap(ThreatKind.init) ?? hashPrefixMatchingThreatKinds[0] - eventMapping.fire(.errorPageShown(clientSideHit: false, threatKind: threatKind)) + eventMapping.fire(.errorPageShown(category: threatKind, clientSideHit: false)) return threatKind } diff --git a/Sources/MaliciousSiteProtection/Model/Event.swift b/Sources/MaliciousSiteProtection/Model/Event.swift index 8903f4d70..2f3136433 100644 --- a/Sources/MaliciousSiteProtection/Model/Event.swift +++ b/Sources/MaliciousSiteProtection/Model/Event.swift @@ -21,52 +21,52 @@ import PixelKit public extension PixelKit { enum Parameters: Hashable { - public static let clientSideHit = "client_side_hit" - public static let settingToggledTo = "setting_toggled_to" + public static let clientSideHit = "clientSideHit" + public static let category = "category" + public static let settingToggledTo = "newState" } } public enum Event: PixelKitEventV2 { - case errorPageShown(clientSideHit: Bool, threatKind: ThreatKind) - case visitSite - case iframeLoaded - case updateTaskFailed48h(error: Error?) + case errorPageShown(category: ThreatKind, clientSideHit: Bool) + case visitSite(category: ThreatKind) + case iframeLoaded(category: ThreatKind) case settingToggled(to: Bool) public var name: String { switch self { case .errorPageShown: - return "phishing_detection_error-page-shown" + return "malicious-site-protection_error-page-shown" case .visitSite: - return "phishing_detection_visit-site" + return "malicious-site-protection_visit-site" case .iframeLoaded: - return "phishing_detection_iframe-loaded" - case .updateTaskFailed48h: - return "phishing_detection_update-task-failed-48h" + return "malicious-site-protection_iframe-loaded" case .settingToggled: - return "phishing_detection_setting-toggled" + return "malicious-site-protection_feature-toggled" } } public var parameters: [String: String]? { switch self { - case .errorPageShown(let clientSideHit, threatKind: _): - return [PixelKit.Parameters.clientSideHit: String(clientSideHit)] - case .visitSite: - return [:] - case .iframeLoaded: - return [:] - case .updateTaskFailed48h(let error): - return error?.pixelParameters + case .errorPageShown(category: let category, clientSideHit: let clientSideHit): + return [ + PixelKit.Parameters.category: category.rawValue, + PixelKit.Parameters.clientSideHit: String(clientSideHit), + ] + case .visitSite(category: let category), + .iframeLoaded(category: let category): + return [ + PixelKit.Parameters.category: category.rawValue, + ] case .settingToggled(let state): - return [PixelKit.Parameters.settingToggledTo: String(state)] + return [ + PixelKit.Parameters.settingToggledTo: String(state) + ] } } public var error: (any Error)? { switch self { - case .updateTaskFailed48h(let error): - return error case .errorPageShown: return nil case .visitSite: From 2686d3b15309d60b25b0e2913ada53362cb37b4d Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Wed, 18 Dec 2024 16:01:25 +0600 Subject: [PATCH 2/3] fix build --- Tests/MaliciousSiteProtectionTests/Mocks/MockEventMapping.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/MaliciousSiteProtectionTests/Mocks/MockEventMapping.swift b/Tests/MaliciousSiteProtectionTests/Mocks/MockEventMapping.swift index 1edbb98a2..bf739a450 100644 --- a/Tests/MaliciousSiteProtectionTests/Mocks/MockEventMapping.swift +++ b/Tests/MaliciousSiteProtectionTests/Mocks/MockEventMapping.swift @@ -32,8 +32,6 @@ public class MockEventMapping: EventMapping { switch event { case .errorPageShown: Self.clientSideHitParam = params?[PixelKit.Parameters.clientSideHit] - case .updateTaskFailed48h(error: let error): - Self.errorParam = error default: break } From 6ebb657ff44df3ce17bcb93b3103946db470f52b Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Wed, 18 Dec 2024 18:09:58 +0600 Subject: [PATCH 3/3] update C-S-S, Privacy Dashboard packages --- Package.resolved | 8 ++++---- Package.swift | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Package.resolved b/Package.resolved index dd10b441d..54664d324 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/content-scope-scripts", "state" : { - "revision" : "93ea6c3e771bc0b743b38cefbff548c10add9898", - "version" : "6.42.0" + "revision" : "bc808eb735d9eb72d5c54cf2452b104b6a370e25", + "version" : "6.43.0" } }, { @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { - "revision" : "022c845b06ace6a4aa712a4fa3e79da32193d5c6", - "version" : "7.4.0" + "revision" : "2e2baf7d31c7d8e158a58bc1cb79498c1c727fd2", + "version" : "7.5.0" } }, { diff --git a/Package.swift b/Package.swift index 21a162064..a3c25a798 100644 --- a/Package.swift +++ b/Package.swift @@ -55,8 +55,8 @@ let package = Package( .package(url: "https://github.com/duckduckgo/TrackerRadarKit", exact: "3.0.0"), .package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.3.0"), .package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"), - .package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "6.42.0"), - .package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "7.4.0"), + .package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "6.43.0"), + .package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "7.5.0"), .package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"), .package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"), .package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1"),