From d3b6d2ba6d803b434a588765a58374ec55127aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20=C5=81yp?= Date: Fri, 8 Nov 2024 16:34:11 +0100 Subject: [PATCH 01/12] Remove experiment code --- Package.resolved | 4 +-- .../Features/PrivacyFeature.swift | 1 - .../PrivacyDashboardController.swift | 7 +---- .../PrivacyDashboardEntryPoint.swift | 19 +++++------- .../PrivacyDashboardEvents.swift | 1 - .../PrivacyDashboardURLBuilder.swift | 31 +++---------------- .../PrivacyDashboardUserScript.swift | 7 ----- .../PrivacyDashboardVariant.swift | 24 -------------- 8 files changed, 15 insertions(+), 79 deletions(-) delete mode 100644 Sources/PrivacyDashboard/PrivacyDashboardVariant.swift diff --git a/Package.resolved b/Package.resolved index a55ccb2cc..9ff7d822a 100644 --- a/Package.resolved +++ b/Package.resolved @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { - "revision" : "bea4d750913ef82c10cd06e791686501c8e648e4", - "version" : "7.6.0" + "branch" : "pr-releases/pr-196", + "revision" : "16a157e094006b309a7dee7d5af3fb7d3593c3af" } }, { diff --git a/Sources/BrowserServicesKit/PrivacyConfig/Features/PrivacyFeature.swift b/Sources/BrowserServicesKit/PrivacyConfig/Features/PrivacyFeature.swift index 2d268e55d..47143df0f 100644 --- a/Sources/BrowserServicesKit/PrivacyConfig/Features/PrivacyFeature.swift +++ b/Sources/BrowserServicesKit/PrivacyConfig/Features/PrivacyFeature.swift @@ -48,7 +48,6 @@ public enum PrivacyFeature: String { case performanceMetrics case privacyPro case sslCertificates - case brokenSiteReportExperiment case toggleReports case maliciousSiteProtection case brokenSitePrompt diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index 7f1bc6d7c..e6d823eef 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -89,7 +89,6 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { public private(set) weak var privacyInfo: PrivacyInfo? private let entryPoint: PrivacyDashboardEntryPoint - private let variant: PrivacyDashboardVariant private let eventMapping: EventMapping weak var webView: WKWebView? @@ -103,12 +102,10 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { public init(privacyInfo: PrivacyInfo?, entryPoint: PrivacyDashboardEntryPoint, - variant: PrivacyDashboardVariant, toggleReportingManager: ToggleReportingManaging, eventMapping: EventMapping) { self.privacyInfo = privacyInfo self.entryPoint = entryPoint - self.variant = variant self.eventMapping = eventMapping self.toggleReportingManager = toggleReportingManager script = PrivacyDashboardUserScript() @@ -373,7 +370,6 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { func userScriptDidRequestShowReportBrokenSite(_ userScript: PrivacyDashboardUserScript) { eventMapping.fire(.reportBrokenSiteShown, parameters: [ - PrivacyDashboardEvents.Parameters.variant: variant.rawValue, PrivacyDashboardEvents.Parameters.source: source.rawValue ]) eventMapping.fire(.showReportBrokenSite) @@ -384,7 +380,7 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { } func userScript(_ userScript: PrivacyDashboardUserScript, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String) { - var parameters = [PrivacyDashboardEvents.Parameters.variant: variant.rawValue] + var parameters = [String: String]() if case let .afterTogglePrompt(_, didToggleProtectionsFixIssue) = entryPoint { parameters[PrivacyDashboardEvents.Parameters.didToggleProtectionsFixIssue] = didToggleProtectionsFixIssue.description } @@ -418,7 +414,6 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { func userScript(_ userScript: PrivacyDashboardUserScript, didSelectBreakageCategory category: String) { eventMapping.fire(.breakageCategorySelected, parameters: [ - PrivacyDashboardEvents.Parameters.variant: variant.rawValue, PrivacyDashboardEvents.Parameters.category: category ]) delegate?.privacyDashboardController(self, didSelectBreakageCategory: category) diff --git a/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift b/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift index 4322eaf55..f0e5ff182 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift @@ -40,18 +40,13 @@ public enum PrivacyDashboardEntryPoint: Equatable { /// - didToggleProtectionsFixIssue: A Boolean indicating whether toggling protections resolved the issue. case afterTogglePrompt(category: String, didToggleProtectionsFixIssue: Bool) - func screen(for variant: PrivacyDashboardVariant) -> Screen { - switch (self, variant) { - case (.dashboard, _): return .primaryScreen - - case (.report, .control): return .breakageForm - case (.report, .a): return .categorySelection - case (.report, .b): return .categoryTypeSelection - - case (.afterTogglePrompt, _): return .choiceBreakageForm - - case (.prompt, _): return .promptBreakageForm - case (.toggleReport, _): return .toggleReport + var screen: Screen { + switch self { + case .dashboard: return .primaryScreen + case .report: return .breakageForm + case .afterTogglePrompt: return .choiceBreakageForm + case .prompt: return .promptBreakageForm + case .toggleReport: return .toggleReport } } diff --git a/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift b/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift index 454313255..2319de52f 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift @@ -22,7 +22,6 @@ public enum PrivacyDashboardEvents { public enum Parameters { - public static let variant = "variant" public static let source = "source" public static let category = "category" public static let didToggleProtectionsFixIssue = "didToggleProtectionsFixIssue" diff --git a/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift b/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift index 11e30afc1..18d7bcc75 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift @@ -22,7 +22,7 @@ final class PrivacyDashboardURLBuilder { enum Configuration { - case startScreen(entryPoint: PrivacyDashboardEntryPoint, variant: PrivacyDashboardVariant) + case startScreen(entryPoint: PrivacyDashboardEntryPoint) case segueToScreen(_ screen: Screen, entryPoint: PrivacyDashboardEntryPoint) } @@ -38,31 +38,17 @@ final class PrivacyDashboardURLBuilder { func build() -> URL { url.addingScreenParameter(from: configuration) - .addingBreakageScreenParameterIfNeeded(from: configuration) .addingCategoryParameterIfNeeded(from: configuration) .addingOpenerParameterIfNeeded(from: configuration) } } -private extension PrivacyDashboardVariant { - - var breakageScreen: BreakageScreen? { - switch self { - case .control: return nil - case .a: return .categorySelection - case .b: return .categoryTypeSelection - } - } - -} - private extension URL { private enum Constant { static let screenKey = "screen" - static let breakageScreenKey = "breakageScreen" static let openerKey = "opener" static let categoryKey = "category" @@ -74,30 +60,23 @@ private extension URL { func addingScreenParameter(from configuration: PrivacyDashboardURLBuilder.Configuration) -> URL { var screen: Screen switch configuration { - case .startScreen(let entryPoint, let variant): - screen = entryPoint.screen(for: variant) + case .startScreen(let entryPoint): + screen = entryPoint.screen case .segueToScreen(let destinationScreen, _): screen = destinationScreen } return appendingParameter(name: Constant.screenKey, value: screen.rawValue) } - func addingBreakageScreenParameterIfNeeded(from configuration: PrivacyDashboardURLBuilder.Configuration) -> URL { - if case .startScreen(_, let variant) = configuration, let breakageScreen = variant.breakageScreen?.rawValue { - return appendingParameter(name: Constant.breakageScreenKey, value: breakageScreen) - } - return self - } - func addingCategoryParameterIfNeeded(from configuration: PrivacyDashboardURLBuilder.Configuration) -> URL { - if case .startScreen(let entryPoint, _) = configuration, case .afterTogglePrompt(let category, _) = entryPoint { + if case .startScreen(let entryPoint) = configuration, case .afterTogglePrompt(let category, _) = entryPoint { return appendingParameter(name: Constant.categoryKey, value: category) } return self } func addingOpenerParameterIfNeeded(from configuration: PrivacyDashboardURLBuilder.Configuration) -> URL { - if case .startScreen(let entryPoint, _) = configuration, case .toggleReport = entryPoint { + if case .startScreen(let entryPoint) = configuration, case .toggleReport = entryPoint { return appendingParameter(name: Constant.openerKey, value: Constant.menuScreenKey) } if case .segueToScreen(_, let entryPoint) = configuration, entryPoint == .dashboard { diff --git a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift index 3fc35c46d..39e300a1e 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift @@ -71,13 +71,6 @@ public enum Screen: String, Decodable, CaseIterable { } -public enum BreakageScreen: String, Decodable { - - case categorySelection - case categoryTypeSelection - -} - public struct ProtectionState: Decodable { public let isProtected: Bool diff --git a/Sources/PrivacyDashboard/PrivacyDashboardVariant.swift b/Sources/PrivacyDashboard/PrivacyDashboardVariant.swift deleted file mode 100644 index 4eb557e45..000000000 --- a/Sources/PrivacyDashboard/PrivacyDashboardVariant.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// PrivacyDashboardVariant.swift -// -// Copyright © 2024 DuckDuckGo. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -public enum PrivacyDashboardVariant: String { - - case control - case a, b - -} From 2abc1d773f2251dab7bf6da8066507cd154ab97d Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Tue, 12 Nov 2024 16:46:14 +0000 Subject: [PATCH 02/12] Fixes the disappearing breakage form (#1068) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Please review the release process for BrowserServicesKit [here](https://app.asana.com/0/1200194497630846/1200837094583426). **Required**: Task/Issue URL: https://app.asana.com/0/1206594217596623/1208729801503622/f iOS PR: macOS PR: What kind of version bump will this require?: Major/Minor/Patch **Optional**: CC: @jaceklyp **Description**: When triggering `window.onGetToggleReportOptionsResponse` on the Privacy Dashboard, the native side would create a variable `json` in the global scope before sending it as a parameter to the callback. If GetToggleReportOptionsResponse was even invoked again in the same webview, the attempt to declare another variable with the same name (`json`) would result in a fatal error. This PR removes the declaration of the `json` variable, instead passing the data directly as a parameter to the callback. **Steps to test this PR**: 1. Check out branch `jacek/new-breakage-form` of the iOS app 2. Set BSK to point to `mgurgel/new-breakage-form` 3. Run the app 4. Click on three dots menu 5. Select Report Broken Site 6. Choose a category and a subcategory 7. The form should be visible 8. Navigate back to category selection page 9. Choose a category again 10. The form should still be visible **OS Testing**: * [ ] iOS 14 * [ ] iOS 15 * [ ] iOS 16 * [ ] macOS 10.15 * [ ] macOS 11 * [ ] macOS 12 — ###### Internal references: [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) --- Sources/PrivacyDashboard/PrivacyDashboardController.swift | 6 ++++++ Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index e6d823eef..7b2454cd2 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -114,6 +114,12 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { public func setup(for webView: WKWebView) { self.webView = webView webView.navigationDelegate = self + + if #available(iOS 16.4, macOS 13.3, *) { + webView.isInspectable = true + } else { + // Fallback on earlier versions + } setupPrivacyDashboardUserScript() loadStartScreen() diff --git a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift index 39e300a1e..98f9c8025 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift @@ -333,7 +333,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { atbEntry = "" #endif let js = """ - const json = { + window.onGetToggleReportOptionsResponse({ "data": [ { "id": "siteUrl", @@ -358,8 +358,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { {"id": "userRefreshCount"}, {"id": "locale"}, ] - } - window.onGetToggleReportOptionsResponse(json); + }); """ evaluate(js: js, in: webView) } From 4fe3ed686ba8f84f862abb66b42a75feac8cf45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20=C5=81yp?= Date: Wed, 20 Nov 2024 21:38:02 +0100 Subject: [PATCH 03/12] Remove unused code --- .../PrivacyDashboardController.swift | 16 ---------------- .../PrivacyDashboardEvents.swift | 4 ---- .../PrivacyDashboardUserScript.swift | 19 +------------------ 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index 7b2454cd2..514b345a3 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -338,9 +338,6 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { } func userScript(_ userScript: PrivacyDashboardUserScript, didChangeProtectionState protectionState: ProtectionState) { - if protectionState.eventOrigin.screen == .choiceToggle { - eventMapping.fire(.toggleProtectionOff) - } if shouldSegueToToggleReportScreen(with: protectionState) { segueToToggleReportScreen(with: protectionState) } else { @@ -412,16 +409,7 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { toggleReportingFlow?.userScriptDidSelectReportAction(shouldSendReport: shouldSendReport) } - // MARK: - Experiment flows (soon to be removed) - - func userScript(_ userScript: PrivacyDashboardUserScript, didSelectOverallCategory category: String) { - eventMapping.fire(.overallCategorySelected, parameters: [PrivacyDashboardEvents.Parameters.category: category]) - } - func userScript(_ userScript: PrivacyDashboardUserScript, didSelectBreakageCategory category: String) { - eventMapping.fire(.breakageCategorySelected, parameters: [ - PrivacyDashboardEvents.Parameters.category: category - ]) delegate?.privacyDashboardController(self, didSelectBreakageCategory: category) } @@ -433,8 +421,4 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { delegate?.privacyDashboardControllerDidRequestShowGeneralFeedback(self) } - func userScriptDidSkipTogglingStep(_ userScript: PrivacyDashboardUserScript) { - eventMapping.fire(.skipToggleStep) - } - } diff --git a/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift b/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift index 2319de52f..039c7cd89 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift @@ -31,10 +31,6 @@ public enum PrivacyDashboardEvents { case showReportBrokenSite case reportBrokenSiteShown - case breakageCategorySelected case reportBrokenSiteSent - case overallCategorySelected - case skipToggleStep - case toggleProtectionOff } diff --git a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift index 98f9c8025..7367a2761 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift @@ -41,11 +41,9 @@ protocol PrivacyDashboardUserScriptDelegate: AnyObject { func userScript(_ userScript: PrivacyDashboardUserScript, didSelectReportAction shouldSendReport: Bool) // Experiment flows - func userScript(_ userScript: PrivacyDashboardUserScript, didSelectOverallCategory category: String) func userScript(_ userScript: PrivacyDashboardUserScript, didSelectBreakageCategory category: String) func userScriptDidRequestShowAlertForMissingDescription(_ userScript: PrivacyDashboardUserScript) func userScriptDidRequestShowNativeFeedback(_ userScript: PrivacyDashboardUserScript) - func userScriptDidSkipTogglingStep(_ userScript: PrivacyDashboardUserScript) } @@ -279,16 +277,6 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { delegate?.userScript(self, didSelectReportAction: false) } - private func handleSelectOverallCategory(message: WKScriptMessage) { - guard let dict = message.body as? [String: Any], - let category = dict["category"] as? String - else { - assertionFailure("handleSelectOverallCategory: expected { category: String }") - return - } - delegate?.userScript(self, didSelectOverallCategory: category) - } - private func handleSelectBreakageCategory(message: WKScriptMessage) { guard let dict = message.body as? [String: Any], let category = dict["category"] as? String @@ -313,14 +301,9 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { return } - if telemetrySpan.attributes.name == "categoryTypeSelected" { - let category = telemetrySpan.attributes.value ?? "" - delegate?.userScript(self, didSelectOverallCategory: category) - } else if telemetrySpan.attributes.name == "categorySelected" { + if telemetrySpan.attributes.name == "categorySelected" { let category = telemetrySpan.attributes.value ?? "" delegate?.userScript(self, didSelectBreakageCategory: category) - } else if telemetrySpan.attributes.name == "toggleSkipped" { - delegate?.userScriptDidSkipTogglingStep(self) } } From 2f26a8accafff82e560f63e8c934752bcdef4d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20=C5=81yp?= Date: Thu, 21 Nov 2024 11:26:31 +0100 Subject: [PATCH 04/12] Remove unused methods Remove experimental code Update resolved Remove unused method Update Resolved --- Package.resolved | 2 +- .../PrivacyDashboardController.swift | 18 +--------- .../PrivacyDashboardEntryPoint.swift | 11 +----- .../PrivacyDashboardEvents.swift | 1 - .../PrivacyDashboardURLBuilder.swift | 8 ----- .../PrivacyDashboardUserScript.swift | 35 ------------------- .../Mocks/PrivacyDashboardDelegateMock.swift | 2 -- 7 files changed, 3 insertions(+), 74 deletions(-) diff --git a/Package.resolved b/Package.resolved index 9ff7d822a..0b83f2ec1 100644 --- a/Package.resolved +++ b/Package.resolved @@ -51,7 +51,7 @@ "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { "branch" : "pr-releases/pr-196", - "revision" : "16a157e094006b309a7dee7d5af3fb7d3593c3af" + "revision" : "fa89a728b92fdc623ddbd9b1c985b42bd3c6bfb4" } }, { diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index 514b345a3..c9101305a 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -40,12 +40,9 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { didRequestOpenUrlInNewTab url: URL) func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didRequestOpenSettings target: PrivacyDashboardOpenSettingsTarget) - func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, - didSelectBreakageCategory category: String) func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String) - func privacyDashboardControllerDidRequestShowAlertForMissingDescription(_ privacyDashboardController: PrivacyDashboardController) func privacyDashboardControllerDidRequestShowGeneralFeedback(_ privacyDashboardController: PrivacyDashboardController) func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didRequestSubmitToggleReportWithSource source: BrokenSiteReport.Source) @@ -184,7 +181,6 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { case .dashboard: source = .dashboard case .prompt: source = .prompt case .toggleReport: source = .onProtectionsOffMenu - case .afterTogglePrompt: source = .afterTogglePrompt } if let toggleReportingSource = toggleReportingFlow?.entryPoint.source { source = toggleReportingSource @@ -383,11 +379,7 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { } func userScript(_ userScript: PrivacyDashboardUserScript, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String) { - var parameters = [String: String]() - if case let .afterTogglePrompt(_, didToggleProtectionsFixIssue) = entryPoint { - parameters[PrivacyDashboardEvents.Parameters.didToggleProtectionsFixIssue] = didToggleProtectionsFixIssue.description - } - eventMapping.fire(.reportBrokenSiteSent, parameters: parameters) + eventMapping.fire(.reportBrokenSiteSent) delegate?.privacyDashboardController(self, didRequestSubmitBrokenSiteReportWithCategory: category, description: description) } @@ -409,14 +401,6 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { toggleReportingFlow?.userScriptDidSelectReportAction(shouldSendReport: shouldSendReport) } - func userScript(_ userScript: PrivacyDashboardUserScript, didSelectBreakageCategory category: String) { - delegate?.privacyDashboardController(self, didSelectBreakageCategory: category) - } - - func userScriptDidRequestShowAlertForMissingDescription(_ userScript: PrivacyDashboardUserScript) { - delegate?.privacyDashboardControllerDidRequestShowAlertForMissingDescription(self) - } - func userScriptDidRequestShowNativeFeedback(_ userScript: PrivacyDashboardUserScript) { delegate?.privacyDashboardControllerDidRequestShowGeneralFeedback(self) } diff --git a/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift b/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift index f0e5ff182..a696bff1c 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift @@ -33,18 +33,10 @@ public enum PrivacyDashboardEntryPoint: Equatable { /// The prompt report screen, which is triggered whenever the user taps report from the toast 'Site not working?" case prompt - /// The experimental after toggle prompt screen, presented in variant B. - /// After the user toggles off protection, this prompt asks if the action helped and allows the user to report their experience. - /// - Parameters: - /// - category: The category of the issue reported by the user. - /// - didToggleProtectionsFixIssue: A Boolean indicating whether toggling protections resolved the issue. - case afterTogglePrompt(category: String, didToggleProtectionsFixIssue: Bool) - var screen: Screen { switch self { case .dashboard: return .primaryScreen case .report: return .breakageForm - case .afterTogglePrompt: return .choiceBreakageForm case .prompt: return .promptBreakageForm case .toggleReport: return .toggleReport } @@ -56,8 +48,7 @@ public enum PrivacyDashboardEntryPoint: Equatable { (.dashboard, .dashboard), (.report, .report), (.toggleReport, .toggleReport), - (.prompt, .prompt), - (.afterTogglePrompt, .afterTogglePrompt): + (.prompt, .prompt): return true default: return false diff --git a/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift b/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift index 039c7cd89..44888ad1e 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardEvents.swift @@ -24,7 +24,6 @@ public enum PrivacyDashboardEvents { public static let source = "source" public static let category = "category" - public static let didToggleProtectionsFixIssue = "didToggleProtectionsFixIssue" } diff --git a/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift b/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift index 18d7bcc75..f062b7c8d 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift @@ -38,7 +38,6 @@ final class PrivacyDashboardURLBuilder { func build() -> URL { url.addingScreenParameter(from: configuration) - .addingCategoryParameterIfNeeded(from: configuration) .addingOpenerParameterIfNeeded(from: configuration) } @@ -68,13 +67,6 @@ private extension URL { return appendingParameter(name: Constant.screenKey, value: screen.rawValue) } - func addingCategoryParameterIfNeeded(from configuration: PrivacyDashboardURLBuilder.Configuration) -> URL { - if case .startScreen(let entryPoint) = configuration, case .afterTogglePrompt(let category, _) = entryPoint { - return appendingParameter(name: Constant.categoryKey, value: category) - } - return self - } - func addingOpenerParameterIfNeeded(from configuration: PrivacyDashboardURLBuilder.Configuration) -> URL { if case .startScreen(let entryPoint) = configuration, case .toggleReport = entryPoint { return appendingParameter(name: Constant.openerKey, value: Constant.menuScreenKey) diff --git a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift index 7367a2761..3df230fb3 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift @@ -41,8 +41,6 @@ protocol PrivacyDashboardUserScriptDelegate: AnyObject { func userScript(_ userScript: PrivacyDashboardUserScript, didSelectReportAction shouldSendReport: Bool) // Experiment flows - func userScript(_ userScript: PrivacyDashboardUserScript, didSelectBreakageCategory category: String) - func userScriptDidRequestShowAlertForMissingDescription(_ userScript: PrivacyDashboardUserScript) func userScriptDidRequestShowNativeFeedback(_ userScript: PrivacyDashboardUserScript) } @@ -106,7 +104,6 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { enum MessageNames: String, CaseIterable { - case privacyDashboardTelemetrySpan case privacyDashboardSetProtection case privacyDashboardSetSize case privacyDashboardClose @@ -119,7 +116,6 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { case privacyDashboardGetToggleReportOptions case privacyDashboardSendToggleReport case privacyDashboardRejectToggleReport - case privacyDashboardShowAlertForMissingDescription case privacyDashboardShowNativeFeedback } @@ -164,12 +160,8 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { handleSendToggleReport() case .privacyDashboardRejectToggleReport: handleDoNotSendToggleReport() - case .privacyDashboardShowAlertForMissingDescription: - handleShowAlertForMissingDescription() case .privacyDashboardShowNativeFeedback: handleShowNativeFeedback() - case .privacyDashboardTelemetrySpan: - handleTelemetrySpan(message: message) } } @@ -277,37 +269,10 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { delegate?.userScript(self, didSelectReportAction: false) } - private func handleSelectBreakageCategory(message: WKScriptMessage) { - guard let dict = message.body as? [String: Any], - let category = dict["category"] as? String - else { - assertionFailure("handleSelectBreakageCategory: expected { category: String }") - return - } - delegate?.userScript(self, didSelectBreakageCategory: category) - } - - private func handleShowAlertForMissingDescription() { - delegate?.userScriptDidRequestShowAlertForMissingDescription(self) - } - private func handleShowNativeFeedback() { delegate?.userScriptDidRequestShowNativeFeedback(self) } - private func handleTelemetrySpan(message: WKScriptMessage) { - guard let telemetrySpan: TelemetrySpan = DecodableHelper.decode(from: message.messageBody) else { - assertionFailure("privacyDashboardTelemetrySpan: expected TelemetrySpan") - return - } - - if telemetrySpan.attributes.name == "categorySelected" { - let category = telemetrySpan.attributes.value ?? "" - delegate?.userScript(self, didSelectBreakageCategory: category) - } - - } - // MARK: - Calls to script's JS API func setToggleReportOptions(forSite site: String, webView: WKWebView) { diff --git a/Tests/PrivacyDashboardTests/Mocks/PrivacyDashboardDelegateMock.swift b/Tests/PrivacyDashboardTests/Mocks/PrivacyDashboardDelegateMock.swift index e9378295c..d908e0d40 100644 --- a/Tests/PrivacyDashboardTests/Mocks/PrivacyDashboardDelegateMock.swift +++ b/Tests/PrivacyDashboardTests/Mocks/PrivacyDashboardDelegateMock.swift @@ -49,11 +49,9 @@ final class PrivacyDashboardDelegateMock: PrivacyDashboardControllerDelegate { func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didRequestOpenUrlInNewTab url: URL) {} func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didRequestOpenSettings target: PrivacyDashboardOpenSettingsTarget) {} - func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didSelectBreakageCategory category: String) {} func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String) {} - func privacyDashboardControllerDidRequestShowAlertForMissingDescription(_ privacyDashboardController: PrivacyDashboardController) {} func privacyDashboardControllerDidRequestShowGeneralFeedback(_ privacyDashboardController: PrivacyDashboardController) {} func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didSetHeight height: Int) {} func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, From 43dac7fdc50a026ffb28a8e2aee866db874c0578 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 13 Dec 2024 11:35:15 +0000 Subject: [PATCH 05/12] Opener setting --- Package.resolved | 2 +- .../PrivacyDashboard/PrivacyDashboardController.swift | 4 ++-- .../PrivacyDashboard/PrivacyDashboardEntryPoint.swift | 2 +- .../PrivacyDashboard/PrivacyDashboardURLBuilder.swift | 10 ++++++++-- .../PrivacyDashboard/PrivacyDashboardUserScript.swift | 1 - 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Package.resolved b/Package.resolved index 0b83f2ec1..14bbf5292 100644 --- a/Package.resolved +++ b/Package.resolved @@ -51,7 +51,7 @@ "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { "branch" : "pr-releases/pr-196", - "revision" : "fa89a728b92fdc623ddbd9b1c985b42bd3c6bfb4" + "revision" : "dd720379811b92f482d51c72ebf8957003b69184" } }, { diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index c9101305a..ae84130eb 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -141,8 +141,8 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { } private func loadStartScreen() { - let url = PrivacyDashboardURLBuilder(configuration: .startScreen(entryPoint: entryPoint, variant: variant)).build() - webView?.loadHTMLString(dashboardHtml, baseURL: url.deletingLastPathComponent()) + let url = PrivacyDashboardURLBuilder(configuration: .startScreen(entryPoint: entryPoint)).build() + webView?.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent().deletingLastPathComponent()) } public func updatePrivacyInfo(_ privacyInfo: PrivacyInfo?) { diff --git a/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift b/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift index a696bff1c..dd28591fd 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift @@ -37,7 +37,7 @@ public enum PrivacyDashboardEntryPoint: Equatable { switch self { case .dashboard: return .primaryScreen case .report: return .breakageForm - case .prompt: return .promptBreakageForm + case .prompt: return .breakageForm case .toggleReport: return .toggleReport } } diff --git a/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift b/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift index f062b7c8d..1f98524f1 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift @@ -68,9 +68,15 @@ private extension URL { } func addingOpenerParameterIfNeeded(from configuration: PrivacyDashboardURLBuilder.Configuration) -> URL { - if case .startScreen(let entryPoint) = configuration, case .toggleReport = entryPoint { - return appendingParameter(name: Constant.openerKey, value: Constant.menuScreenKey) + if case .startScreen(let entryPoint) = configuration { + switch entryPoint { + case .toggleReport, .report: + return appendingParameter(name: Constant.openerKey, value: Constant.menuScreenKey) + default: + break + } } + if case .segueToScreen(_, let entryPoint) = configuration, entryPoint == .dashboard { return appendingParameter(name: Constant.openerKey, value: Constant.dashboardScreenKey) } diff --git a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift index 3df230fb3..27d13ef56 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift @@ -63,7 +63,6 @@ public enum Screen: String, Decodable, CaseIterable { case choiceToggle case toggleReport - case promptBreakageForm } From 507d05df54dcf70546943217d80b0ddce783655a Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Thu, 9 Jan 2025 13:00:50 +0000 Subject: [PATCH 06/12] Branch change --- Package.resolved | 4 ++-- Package.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index 14bbf5292..6b8ca24a8 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/content-scope-scripts", "state" : { - "revision" : "7958ddab724c26326333cae13fe81478290607fa", - "version" : "7.6.0" + "revision" : "06d244c4e0951ef16217c46f23c4865c5f98dd5c", + "version" : "7.4.0" } }, { diff --git a/Package.swift b/Package.swift index c2c04a331..6762d4a17 100644 --- a/Package.swift +++ b/Package.swift @@ -55,8 +55,8 @@ let package = Package( .package(url: "https://github.com/duckduckgo/TrackerRadarKit", exact: "3.0.0"), .package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.4.0"), .package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"), - .package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "7.6.0"), - .package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "7.6.0"), + .package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "7.4.0"), + .package(url: "https://github.com/duckduckgo/privacy-dashboard", branch: "pr-releases/pr-196"), .package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"), .package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"), .package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1"), From 90faf5c007c3b4cb535be9df33cd0d67d53365ee Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Tue, 14 Jan 2025 13:10:07 +0000 Subject: [PATCH 07/12] Updated Privacy Dashboard to 8.0.0 --- Package.resolved | 4 ++-- Package.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Package.resolved b/Package.resolved index 6b8ca24a8..dd5332d76 100644 --- a/Package.resolved +++ b/Package.resolved @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { - "branch" : "pr-releases/pr-196", - "revision" : "dd720379811b92f482d51c72ebf8957003b69184" + "revision" : "3f58e008d4e9d1b56ab12dbb95bd891045cf2758", + "version" : "8.0.0" } }, { diff --git a/Package.swift b/Package.swift index 6762d4a17..ef999a893 100644 --- a/Package.swift +++ b/Package.swift @@ -56,7 +56,7 @@ let package = Package( .package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.4.0"), .package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"), .package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "7.4.0"), - .package(url: "https://github.com/duckduckgo/privacy-dashboard", branch: "pr-releases/pr-196"), + .package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "8.0.0"), .package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"), .package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"), .package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1"), From 9a5aeda59cabe4d948f9c230416c9da2220aa647 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Tue, 14 Jan 2025 14:01:00 +0000 Subject: [PATCH 08/12] Removed whitespace --- Sources/PrivacyDashboard/PrivacyDashboardController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index ae84130eb..e804fdd2d 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -111,7 +111,7 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { public func setup(for webView: WKWebView) { self.webView = webView webView.navigationDelegate = self - + if #available(iOS 16.4, macOS 13.3, *) { webView.isInspectable = true } else { From 2c0d6e060cec542147e4044f6169ea7a4f5510e6 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Tue, 14 Jan 2025 14:21:51 +0000 Subject: [PATCH 09/12] Updated tests --- .../PrivacyDashboardControllerTests.swift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Tests/PrivacyDashboardTests/PrivacyDashboardControllerTests.swift b/Tests/PrivacyDashboardTests/PrivacyDashboardControllerTests.swift index a3ee836fc..39ddc62d7 100644 --- a/Tests/PrivacyDashboardTests/PrivacyDashboardControllerTests.swift +++ b/Tests/PrivacyDashboardTests/PrivacyDashboardControllerTests.swift @@ -37,7 +37,6 @@ final class PrivacyDashboardControllerTests: XCTestCase { toggleReportingManagerMock = ToggleReportingManagerMock() privacyDashboardController = PrivacyDashboardController(privacyInfo: privacyInfo, entryPoint: entryPoint, - variant: .control, toggleReportingManager: toggleReportingManagerMock, eventMapping: EventMapping { _, _, _, _ in }) webView = WKWebView() @@ -51,16 +50,12 @@ final class PrivacyDashboardControllerTests: XCTestCase { let entryPoints: [PrivacyDashboardEntryPoint] = [ .dashboard, .report, - .afterTogglePrompt(category: "apple", didToggleProtectionsFixIssue: false), .toggleReport(completionHandler: { _ in }) ] for entryPoint in entryPoints { makePrivacyDashboardController(entryPoint: entryPoint) let currentURL = privacyDashboardController.webView!.url - XCTAssertEqual(currentURL?.getParameter(named: "screen"), entryPoint.screen(for: .control).rawValue) - if case .afterTogglePrompt = entryPoint { - XCTAssertEqual(currentURL?.getParameter(named: "category"), "apple") - } + XCTAssertEqual(currentURL?.getParameter(named: "screen"), "breakageForm") if case .toggleReport = entryPoint { XCTAssertEqual(currentURL?.getParameter(named: "opener"), "menu") } From 52d3ae781ac0c1a7473a99a1550b206fc4006245 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Tue, 14 Jan 2025 14:24:00 +0000 Subject: [PATCH 10/12] C-S-S version fix --- Package.resolved | 4 ++-- Package.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Package.resolved b/Package.resolved index dd5332d76..13dbd555d 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/content-scope-scripts", "state" : { - "revision" : "06d244c4e0951ef16217c46f23c4865c5f98dd5c", - "version" : "7.4.0" + "revision" : "0502ed7de4130bd8705daebaca9aeb20d3e62d15", + "version" : "7.5.0" } }, { diff --git a/Package.swift b/Package.swift index ef999a893..d4cd200d4 100644 --- a/Package.swift +++ b/Package.swift @@ -55,7 +55,7 @@ let package = Package( .package(url: "https://github.com/duckduckgo/TrackerRadarKit", exact: "3.0.0"), .package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.4.0"), .package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"), - .package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "7.4.0"), + .package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "7.5.0"), .package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "8.0.0"), .package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"), .package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"), From 13ccadd9ce82823898b0706a545e654ac69565e4 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Tue, 14 Jan 2025 14:39:38 +0000 Subject: [PATCH 11/12] Test fix --- .../PrivacyDashboardTests/PrivacyDashboardControllerTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/PrivacyDashboardTests/PrivacyDashboardControllerTests.swift b/Tests/PrivacyDashboardTests/PrivacyDashboardControllerTests.swift index 39ddc62d7..5f9d833b0 100644 --- a/Tests/PrivacyDashboardTests/PrivacyDashboardControllerTests.swift +++ b/Tests/PrivacyDashboardTests/PrivacyDashboardControllerTests.swift @@ -55,7 +55,7 @@ final class PrivacyDashboardControllerTests: XCTestCase { for entryPoint in entryPoints { makePrivacyDashboardController(entryPoint: entryPoint) let currentURL = privacyDashboardController.webView!.url - XCTAssertEqual(currentURL?.getParameter(named: "screen"), "breakageForm") + XCTAssertEqual(currentURL?.getParameter(named: "screen"), entryPoint.screen.rawValue) if case .toggleReport = entryPoint { XCTAssertEqual(currentURL?.getParameter(named: "opener"), "menu") } From ecd7c2d10e97f1cadc7914f37c40a9754e1aefa4 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 17 Jan 2025 17:56:29 +0000 Subject: [PATCH 12/12] Handling ReportBrokenSiteShown message (#1167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Required**: Task/Issue URL: https://app.asana.com/0/1206594217596623/1209173355503842/f iOS PR: https://github.com/duckduckgo/iOS/pull/3822 macOS PR: https://github.com/duckduckgo/macos-browser/pull/3744 What kind of version bump will this require?: Minor **Description**: Implements Privacy Dashboard message `ReportBrokenSiteShown` which will trigger a pixel on macOS and iOS This PR contains a fix for https://github.com/duckduckgo/BrowserServicesKit/pull/1160 which is why it is stacked on it. Please let me know if this is not the best way to have this code reviewed. **Steps to test this PR**: 1. Invoke the breakage form in the two possible ways: Open the Privacy Dashboard and click on "Report a problem with this site" Open the app menu ••• and click on "Report Broken Site” (iOS) 2. Confirm that the pixel `m_report-broken-site_shown` was fired 3. Submit a report 4. Confirm that the pixels `epbf` (iOS) / `epbf_macos_desktop` (macOS) and `m_report-broken-site_sent` were fired **OS Testing**: * [ ] iOS 14 * [ ] iOS 15 * [ ] iOS 16 * [ ] macOS 10.15 * [ ] macOS 11 * [ ] macOS 12 --- ###### Internal references: [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) --- Package.resolved | 4 ++-- Package.swift | 2 +- .../PrivacyDashboard/PrivacyDashboardController.swift | 9 +++++++-- .../PrivacyDashboard/PrivacyDashboardUserScript.swift | 8 ++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Package.resolved b/Package.resolved index 13dbd555d..0b2b63760 100644 --- a/Package.resolved +++ b/Package.resolved @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { - "revision" : "3f58e008d4e9d1b56ab12dbb95bd891045cf2758", - "version" : "8.0.0" + "branch" : "pr-releases/pr-302", + "revision" : "05d04de7505117b32949b2007e5a56ba2d39469b" } }, { diff --git a/Package.swift b/Package.swift index d4cd200d4..9c6a8e0bf 100644 --- a/Package.swift +++ b/Package.swift @@ -56,7 +56,7 @@ let package = Package( .package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.4.0"), .package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"), .package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "7.5.0"), - .package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "8.0.0"), + .package(url: "https://github.com/duckduckgo/privacy-dashboard", branch: "pr-releases/pr-302"), .package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"), .package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"), .package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1"), diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index e804fdd2d..5bc696c1e 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -368,10 +368,13 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { } func userScriptDidRequestShowReportBrokenSite(_ userScript: PrivacyDashboardUserScript) { + eventMapping.fire(.showReportBrokenSite) + } + + func userScriptDidRequestReportBrokenSiteShown(_ userScript: PrivacyDashboardUserScript) { eventMapping.fire(.reportBrokenSiteShown, parameters: [ PrivacyDashboardEvents.Parameters.source: source.rawValue ]) - eventMapping.fire(.showReportBrokenSite) } func userScript(_ userScript: PrivacyDashboardUserScript, setHeight height: Int) { @@ -379,7 +382,9 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate { } func userScript(_ userScript: PrivacyDashboardUserScript, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String) { - eventMapping.fire(.reportBrokenSiteSent) + eventMapping.fire(.reportBrokenSiteSent, parameters: [ + PrivacyDashboardEvents.Parameters.source: source.rawValue + ]) delegate?.privacyDashboardController(self, didRequestSubmitBrokenSiteReportWithCategory: category, description: description) } diff --git a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift index 27d13ef56..f00c94df6 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift @@ -31,6 +31,7 @@ protocol PrivacyDashboardUserScriptDelegate: AnyObject { func userScript(_ userScript: PrivacyDashboardUserScript, setHeight height: Int) func userScriptDidRequestClose(_ userScript: PrivacyDashboardUserScript) func userScriptDidRequestShowReportBrokenSite(_ userScript: PrivacyDashboardUserScript) + func userScriptDidRequestReportBrokenSiteShown(_ userScript: PrivacyDashboardUserScript) func userScript(_ userScript: PrivacyDashboardUserScript, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String) func userScript(_ userScript: PrivacyDashboardUserScript, didRequestOpenUrlInNewTab: URL) func userScript(_ userScript: PrivacyDashboardUserScript, didRequestOpenSettings: String) @@ -107,6 +108,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { case privacyDashboardSetSize case privacyDashboardClose case privacyDashboardShowReportBrokenSite + case privacyDashboardReportBrokenSiteShown case privacyDashboardSubmitBrokenSiteReport case privacyDashboardOpenUrlInNewTab case privacyDashboardOpenSettings @@ -143,6 +145,8 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { handleClose() case .privacyDashboardShowReportBrokenSite: handleShowReportBrokenSite() + case .privacyDashboardReportBrokenSiteShown: + handleReportBrokenSiteShown() case .privacyDashboardSubmitBrokenSiteReport: handleSubmitBrokenSiteReport(message: message) case .privacyDashboardOpenUrlInNewTab: @@ -196,6 +200,10 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript { delegate?.userScriptDidRequestShowReportBrokenSite(self) } + private func handleReportBrokenSiteShown() { + delegate?.userScriptDidRequestReportBrokenSiteShown(self) + } + private func handleSubmitBrokenSiteReport(message: WKScriptMessage) { guard let dict = message.body as? [String: Any], let category = dict["category"] as? String,