From 723dbb9db3ca6852c2ebc92408c9893fe1c338de Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Wed, 18 Dec 2024 14:47:01 +0600 Subject: [PATCH] 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: