Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit ecd7c2d

Browse files
authored
Handling ReportBrokenSiteShown message (#1167)
**Required**: Task/Issue URL: https://app.asana.com/0/1206594217596623/1209173355503842/f iOS PR: duckduckgo/iOS#3822 macOS PR: duckduckgo/macos-browser#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 #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 <!-- Before submitting a PR, please ensure you have tested the combinations you expect the reviewer to test, then delete configurations you *know* do not need explicit testing. Using a simulator where a physical device is unavailable is acceptable. --> **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)
1 parent 13ccadd commit ecd7c2d

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let package = Package(
5656
.package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.4.0"),
5757
.package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"),
5858
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "7.5.0"),
59-
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "8.0.0"),
59+
.package(url: "https://github.com/duckduckgo/privacy-dashboard", branch: "pr-releases/pr-302"),
6060
.package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"),
6161
.package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"),
6262
.package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1"),

Sources/PrivacyDashboard/PrivacyDashboardController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,23 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate {
368368
}
369369

370370
func userScriptDidRequestShowReportBrokenSite(_ userScript: PrivacyDashboardUserScript) {
371+
eventMapping.fire(.showReportBrokenSite)
372+
}
373+
374+
func userScriptDidRequestReportBrokenSiteShown(_ userScript: PrivacyDashboardUserScript) {
371375
eventMapping.fire(.reportBrokenSiteShown, parameters: [
372376
PrivacyDashboardEvents.Parameters.source: source.rawValue
373377
])
374-
eventMapping.fire(.showReportBrokenSite)
375378
}
376379

377380
func userScript(_ userScript: PrivacyDashboardUserScript, setHeight height: Int) {
378381
delegate?.privacyDashboardController(self, didSetHeight: height)
379382
}
380383

381384
func userScript(_ userScript: PrivacyDashboardUserScript, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String) {
382-
eventMapping.fire(.reportBrokenSiteSent)
385+
eventMapping.fire(.reportBrokenSiteSent, parameters: [
386+
PrivacyDashboardEvents.Parameters.source: source.rawValue
387+
])
383388
delegate?.privacyDashboardController(self, didRequestSubmitBrokenSiteReportWithCategory: category, description: description)
384389
}
385390

Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ protocol PrivacyDashboardUserScriptDelegate: AnyObject {
3131
func userScript(_ userScript: PrivacyDashboardUserScript, setHeight height: Int)
3232
func userScriptDidRequestClose(_ userScript: PrivacyDashboardUserScript)
3333
func userScriptDidRequestShowReportBrokenSite(_ userScript: PrivacyDashboardUserScript)
34+
func userScriptDidRequestReportBrokenSiteShown(_ userScript: PrivacyDashboardUserScript)
3435
func userScript(_ userScript: PrivacyDashboardUserScript, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String)
3536
func userScript(_ userScript: PrivacyDashboardUserScript, didRequestOpenUrlInNewTab: URL)
3637
func userScript(_ userScript: PrivacyDashboardUserScript, didRequestOpenSettings: String)
@@ -107,6 +108,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
107108
case privacyDashboardSetSize
108109
case privacyDashboardClose
109110
case privacyDashboardShowReportBrokenSite
111+
case privacyDashboardReportBrokenSiteShown
110112
case privacyDashboardSubmitBrokenSiteReport
111113
case privacyDashboardOpenUrlInNewTab
112114
case privacyDashboardOpenSettings
@@ -143,6 +145,8 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
143145
handleClose()
144146
case .privacyDashboardShowReportBrokenSite:
145147
handleShowReportBrokenSite()
148+
case .privacyDashboardReportBrokenSiteShown:
149+
handleReportBrokenSiteShown()
146150
case .privacyDashboardSubmitBrokenSiteReport:
147151
handleSubmitBrokenSiteReport(message: message)
148152
case .privacyDashboardOpenUrlInNewTab:
@@ -196,6 +200,10 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
196200
delegate?.userScriptDidRequestShowReportBrokenSite(self)
197201
}
198202

203+
private func handleReportBrokenSiteShown() {
204+
delegate?.userScriptDidRequestReportBrokenSiteShown(self)
205+
}
206+
199207
private func handleSubmitBrokenSiteReport(message: WKScriptMessage) {
200208
guard let dict = message.body as? [String: Any],
201209
let category = dict["category"] as? String,

0 commit comments

Comments
 (0)