Skip to content

Commit

Permalink
Implement Pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroboron committed Jan 10, 2025
1 parent 5be55a9 commit 6aeb628
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import Foundation
import Combine
import Core
import SwiftUI
import PixelKit
import MaliciousSiteProtection

final class MaliciousSiteProtectionSettingsViewModel: ObservableObject {
@Published var shouldShowMaliciousSiteProtectionSection = false
Expand Down Expand Up @@ -60,6 +62,6 @@ final class MaliciousSiteProtectionSettingsViewModel: ObservableObject {
private func updateMaliciousSiteProtection(enabled isEnabled: Bool) {
manager.isEnabled = isEnabled
isMaliciousSiteProtectionEnabled = isEnabled
PixelKit.fire(MaliciousSiteProtection.Event.settingToggled(to: isEnabled))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Core
import SpecialErrorPages
import WebKit
import MaliciousSiteProtection
import PixelKit

enum MaliciousSiteProtectionNavigationResult: Equatable {
case navigationHandled(NavigationType)
Expand Down Expand Up @@ -109,6 +110,7 @@ extension MaliciousSiteProtectionNavigationHandler: MaliciousSiteProtectionNavig
let response = MaliciousSiteDetectionNavigationResponse(navigationAction: navigationAction, errorData: errorData)
return .navigationHandled(.mainFrame(response))
} else {
PixelKit.fire(MaliciousSiteProtection.Event.iframeLoaded(category: threatKind))
// Extract the URL of the source frame (the iframe) that initiated the navigation action
let iFrameTopURL = navigationAction.sourceFrame.safeRequest?.url ?? url
let errorData = SpecialErrorData.maliciousSite(kind: threatKind, url: iFrameTopURL)
Expand Down Expand Up @@ -137,19 +139,19 @@ extension MaliciousSiteProtectionNavigationHandler: MaliciousSiteProtectionNavig
extension MaliciousSiteProtectionNavigationHandler: SpecialErrorPageActionHandler {

func visitSite(url: URL, errorData: SpecialErrorData) {
maliciousURLExemptions[url] = errorData.threatKind
bypassedMaliciousSiteThreatKind = errorData.threatKind
guard let threatKind = errorData.threatKind else {
assertionFailure("Error Data should have a threat kind")
return
}
maliciousURLExemptions[url] = threatKind
bypassedMaliciousSiteThreatKind = threatKind

// Fire Pixel
PixelKit.fire(MaliciousSiteProtection.Event.visitSite(category: threatKind))
}

func leaveSite() {
// Fire Pixel
}
func leaveSite() { }

func advancedInfoPresented() {
// Fire Pixel
}
func advancedInfoPresented() { }

}

Expand Down

0 comments on commit 6aeb628

Please sign in to comment.