Skip to content

Commit

Permalink
Update pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx committed Dec 18, 2024
1 parent b7f7ba9 commit 723dbb9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Sources/MaliciousSiteProtection/MaliciousSiteDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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
}

Expand Down
46 changes: 23 additions & 23 deletions Sources/MaliciousSiteProtection/Model/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 723dbb9

Please sign in to comment.