Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added protectionsState to breakage form submissions #1790

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion DuckDuckGo/Feedback/Model/WebsiteBreakage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ struct WebsiteBreakage {
case privacyDashboard = "dashboard"
}

enum ProtectionsState: String {
case enabled = "1"
case disabled = "0"
}
Comment on lines +40 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Not sure what is the expected way of extending the values range here, but maybe a simple bool would suffice?
  2. Either with the above change or not I suggest replacing "1"/"0" to "true"/"false" to be consistent with other parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miasma13 as we discussed in MM - this mapping to "1" | "0" was done intentionally to match what 'other' platforms are doing with this parameter - since I'm adding to all 5 :)


let category: Category?
let description: String?
let siteUrlString: String
Expand All @@ -50,6 +55,7 @@ struct WebsiteBreakage {
let urlParametersRemoved: Bool
let manufacturer: String
let reportFlow: ReportFlow
let protectionsState: ProtectionsState

init(
category: Category?,
Expand All @@ -63,6 +69,7 @@ struct WebsiteBreakage {
isGPCEnabled: Bool,
ampURL: String,
urlParametersRemoved: Bool,
protected: Bool,
manufacturer: String = "Apple",
reportFlow: ReportFlow = .native
) {
Expand All @@ -76,6 +83,7 @@ struct WebsiteBreakage {
self.installedSurrogates = installedSurrogates
self.isGPCEnabled = isGPCEnabled
self.ampURL = ampURL
self.protectionsState = protected ? .enabled : .disabled
self.urlParametersRemoved = urlParametersRemoved
self.manufacturer = manufacturer
self.reportFlow = reportFlow
Expand All @@ -95,7 +103,8 @@ struct WebsiteBreakage {
"urlParametersRemoved": urlParametersRemoved ? "true" : "false",
"os": osVersion,
"manufacturer": manufacturer,
"reportFlow": reportFlow.rawValue
"reportFlow": reportFlow.rawValue,
"protectionsState": protectionsState.rawValue
]
}
}
4 changes: 4 additions & 0 deletions DuckDuckGo/Feedback/View/FeedbackViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ final class FeedbackViewController: NSViewController {
let installedSurrogates = currentTab?.privacyInfo?.trackerInfo.installedSurrogates.map {$0} ?? []
let ampURL = currentTab?.linkProtection.lastAMPURLString ?? ""
let urlParametersRemoved = currentTab?.linkProtection.urlParametersRemoved ?? false
let configuration = ContentBlocking.shared.privacyConfigurationManager.privacyConfig
let protected = configuration.isFeature(.contentBlocking, enabledForDomain: currentTabUrl?.host)

let websiteBreakage = WebsiteBreakage(category: selectedWebsiteBreakageCategory,
description: browserFeedbackTextView.string,
siteUrlString: urlTextField.stringValue,
Expand All @@ -317,6 +320,7 @@ final class FeedbackViewController: NSViewController {
isGPCEnabled: PrivacySecurityPreferences.shared.gpcEnabled,
ampURL: ampURL,
urlParametersRemoved: urlParametersRemoved,
protected: protected,
reportFlow: .native)
websiteBreakageSender.sendWebsiteBreakage(websiteBreakage)
}
Expand Down
5 changes: 5 additions & 0 deletions DuckDuckGo/PrivacyDashboard/WebsiteBreakageReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ final class WebsiteBreakageReporter {
let ampURL = currentTab?.linkProtection.lastAMPURLString ?? ""
let urlParametersRemoved = currentTab?.linkProtection.urlParametersRemoved ?? false

// current domain's protection status
let configuration = ContentBlocking.shared.privacyConfigurationManager.privacyConfig
let protected = configuration.isFeature(.contentBlocking, enabledForDomain: currentTab?.content.url?.host)

let websiteBreakage = WebsiteBreakage(category: WebsiteBreakage.Category(rawValue: category.lowercased()),
description: description,
siteUrlString: currentURL,
Expand All @@ -52,6 +56,7 @@ final class WebsiteBreakageReporter {
isGPCEnabled: PrivacySecurityPreferences.shared.gpcEnabled,
ampURL: ampURL,
urlParametersRemoved: urlParametersRemoved,
protected: protected,
reportFlow: reportFlow)
return websiteBreakage
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ final class BrokenSiteReportingReferenceTests: XCTestCase {
isGPCEnabled: test.gpcEnabled ?? false,
ampURL: "",
urlParametersRemoved: false,
protected: true,
manufacturer: test.manufacturer ?? "")

let request = makeURLRequest(with: breakage.requestParameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class WebsiteBreakageReportTests: XCTestCase {
],
isGPCEnabled: true,
ampURL: "https://example.test",
urlParametersRemoved: false
urlParametersRemoved: false,
protected: true
)

let urlRequest = makeURLRequest(with: breakage.requestParameters)
Expand All @@ -57,6 +58,7 @@ class WebsiteBreakageReportTests: XCTestCase {
XCTAssertEqual(queryItems[valueFor: "tds"], "abc123")
XCTAssertEqual(queryItems[valueFor: "blockedTrackers"], "bad.tracker.test,tracking.test")
XCTAssertEqual(queryItems[valueFor: "surrogates"], "surrogate.domain.test")
XCTAssertEqual(queryItems[valueFor: "protectionsState"], "1")
}

func testThatNativeAppSpecificFieldsAreReported() throws {
Expand All @@ -77,6 +79,7 @@ class WebsiteBreakageReportTests: XCTestCase {
isGPCEnabled: true,
ampURL: "https://example.test",
urlParametersRemoved: false,
protected: true,
manufacturer: "IBM"
)

Expand All @@ -95,6 +98,7 @@ class WebsiteBreakageReportTests: XCTestCase {
XCTAssertEqual(queryItems[valueFor: "tds"], "abc123")
XCTAssertEqual(queryItems[valueFor: "blockedTrackers"], "bad.tracker.test,tracking.test")
XCTAssertEqual(queryItems[valueFor: "surrogates"], "surrogate.domain.test")
XCTAssertEqual(queryItems[valueFor: "protectionsState"], "1")
XCTAssertEqual(queryItems[valueFor: "manufacturer"], "IBM")
XCTAssertEqual(queryItems[valueFor: "os"], "12")
XCTAssertEqual(queryItems[valueFor: "gpc"], "true")
Expand Down