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

Commit

Permalink
Handling ReportBrokenSiteShown message (#1167)
Browse files Browse the repository at this point in the history
**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)
  • Loading branch information
mgurgel committed Jan 20, 2025
1 parent 842de83 commit 7d4548a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
9 changes: 7 additions & 2 deletions Sources/PrivacyDashboard/PrivacyDashboardController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,23 @@ 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) {
delegate?.privacyDashboardController(self, didSetHeight: height)
}

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)
}

Expand Down
8 changes: 8 additions & 0 deletions Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -107,6 +108,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
case privacyDashboardSetSize
case privacyDashboardClose
case privacyDashboardShowReportBrokenSite
case privacyDashboardReportBrokenSiteShown
case privacyDashboardSubmitBrokenSiteReport
case privacyDashboardOpenUrlInNewTab
case privacyDashboardOpenSettings
Expand Down Expand Up @@ -143,6 +145,8 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
handleClose()
case .privacyDashboardShowReportBrokenSite:
handleShowReportBrokenSite()
case .privacyDashboardReportBrokenSiteShown:
handleReportBrokenSiteShown()
case .privacyDashboardSubmitBrokenSiteReport:
handleSubmitBrokenSiteReport(message: message)
case .privacyDashboardOpenUrlInNewTab:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7d4548a

Please sign in to comment.