diff --git a/DuckDuckGo/BrokenSiteInfo.swift b/DuckDuckGo/BrokenSiteInfo.swift index ed96e5e460..063784c78f 100644 --- a/DuckDuckGo/BrokenSiteInfo.swift +++ b/DuckDuckGo/BrokenSiteInfo.swift @@ -24,6 +24,11 @@ public struct BrokenSiteInfo { static let allowedQueryReservedCharacters = CharacterSet(charactersIn: ",") + enum ProtectionsState: String { + case enabled = "1" + case disabled = "0" + } + private struct Keys { static let url = "siteUrl" static let category = "category" @@ -40,6 +45,7 @@ public struct BrokenSiteInfo { static let gpc = "gpc" static let ampUrl = "ampUrl" static let urlParametersRemoved = "urlParametersRemoved" + static let protectionsState = "protectionsState" } private let url: URL? @@ -54,12 +60,14 @@ public struct BrokenSiteInfo { private let manufacturer: String private let systemVersion: String private let gpc: Bool - + private let protectionsState: ProtectionsState + public init(url: URL?, httpsUpgrade: Bool, blockedTrackerDomains: [String], installedSurrogates: [String], isDesktop: Bool, tdsETag: String?, ampUrl: String?, urlParametersRemoved: Bool, + protected: Bool, model: String = UIDevice.current.model, manufacturer: String = "Apple", systemVersion: String = UIDevice.current.systemVersion, @@ -76,7 +84,8 @@ public struct BrokenSiteInfo { self.model = model self.manufacturer = manufacturer self.systemVersion = systemVersion - + self.protectionsState = protected ? .enabled : .disabled + if let gpcParam = gpc { self.gpc = gpcParam } else { @@ -101,7 +110,8 @@ public struct BrokenSiteInfo { Keys.model: model, Keys.gpc: gpc ? "true" : "false", Keys.ampUrl: ampUrl ?? "", - Keys.urlParametersRemoved: urlParametersRemoved ? "true" : "false" + Keys.urlParametersRemoved: urlParametersRemoved ? "true" : "false", + Keys.protectionsState: protectionsState.rawValue ] Pixel.fire(pixel: .brokenSiteReport, diff --git a/DuckDuckGo/TabViewController.swift b/DuckDuckGo/TabViewController.swift index 04a448e738..5e4da0f41b 100644 --- a/DuckDuckGo/TabViewController.swift +++ b/DuckDuckGo/TabViewController.swift @@ -866,7 +866,10 @@ class TabViewController: UIViewController { public func getCurrentWebsiteInfo() -> BrokenSiteInfo { let blockedTrackerDomains = privacyInfo?.trackerInfo.trackersBlocked.compactMap { $0.domain } ?? [] - + + let configuration = ContentBlocking.shared.privacyConfigurationManager.privacyConfig + let protected = configuration.isFeature(.contentBlocking, enabledForDomain: url?.host) + return BrokenSiteInfo(url: url, httpsUpgrade: httpsForced, blockedTrackerDomains: blockedTrackerDomains, @@ -874,7 +877,8 @@ class TabViewController: UIViewController { isDesktop: tabModel.isDesktop, tdsETag: ContentBlocking.shared.contentBlockingManager.currentMainRules?.etag ?? "", ampUrl: linkProtection.lastAMPURLString, - urlParametersRemoved: linkProtection.urlParametersRemoved) + urlParametersRemoved: linkProtection.urlParametersRemoved, + protected: protected) } public func print() { diff --git a/DuckDuckGoTests/BrokenSiteReportingTests.swift b/DuckDuckGoTests/BrokenSiteReportingTests.swift index b36c95b240..82b3d25c2a 100644 --- a/DuckDuckGoTests/BrokenSiteReportingTests.swift +++ b/DuckDuckGoTests/BrokenSiteReportingTests.swift @@ -75,6 +75,7 @@ final class BrokenSiteReportingTests: XCTestCase { tdsETag: test.blocklistVersion, ampUrl: nil, urlParametersRemoved: false, + protected: true, model: test.model ?? "", manufacturer: test.manufacturer ?? "", systemVersion: test.os ?? "",