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

Privacy Dashboard 8.0.0: Improved breakage form #3729

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15385,8 +15385,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 225.0.0;
branch = "mgurgel/improved-breakage-form-pixel";
kind = branch;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "20e6eaf0b1e423d9a270e2d460cae284c08f73d8",
"version" : "225.0.0"
"branch" : "mgurgel/improved-breakage-form-pixel",
"revision" : "f85a4199ba4251921ecff6d110527c8d5c44e329"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "7958ddab724c26326333cae13fe81478290607fa",
"version" : "7.6.0"
"revision" : "0502ed7de4130bd8705daebaca9aeb20d3e62d15",
"version" : "7.5.0"
}
},
{
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"revision" : "bea4d750913ef82c10cd06e791686501c8e648e4",
"version" : "7.6.0"
"branch" : "pr-releases/pr-302",
"revision" : "05d04de7505117b32949b2007e5a56ba2d39469b"
}
},
{
Expand Down Expand Up @@ -167,8 +167,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/sync_crypto",
"state" : {
"revision" : "cc726cebb67367466bc31ced4784e16d44ac68d1",
"version" : "0.4.0"
"revision" : "0c8bf3c0e75591bc366407b9d7a73a9fcfc7736f",
"version" : "0.3.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ extension MainViewController: FindInPageDelegate {
extension AppDelegate: PrivacyDashboardViewControllerSizeDelegate {

func privacyDashboardViewControllerDidChange(size: NSSize) {
privacyDashboardWindow?.setFrame(NSRect(origin: .zero, size: size), display: true, animate: true)
privacyDashboardWindow?.setFrame(NSRect(origin: .zero, size: size), display: true, animate: false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class PrivacyDashboardViewController: NSViewController {

struct Constants {
static let initialContentHeight: CGFloat = 489.0
static let reportBrokenSiteInitialContentHeight = 587.0 + 28.0
static let reportBrokenSiteInitialContentHeight = 406.0 + 28.0
static let initialContentWidth: CGFloat = 360.0
}

Expand Down Expand Up @@ -62,8 +62,6 @@ final class PrivacyDashboardViewController: NSViewController {
}, keyValueStoring: UserDefaults.standard)
}()

private let eventMapping = EventMapping<PrivacyDashboardEvents> { _, _, _, _ in }

private let permissionHandler = PrivacyDashboardPermissionHandler()
private var preferredMaxHeight: CGFloat = Constants.initialContentHeight
func setPreferredMaxHeight(_ height: CGFloat) {
Expand All @@ -73,6 +71,20 @@ final class PrivacyDashboardViewController: NSViewController {
var sizeDelegate: PrivacyDashboardViewControllerSizeDelegate?
private weak var tabViewModel: TabViewModel?

private let privacyDashboardEvents = EventMapping<PrivacyDashboardEvents> { event, _, parameters, _ in
let domainEvent: NonStandardPixel
switch event {
case .showReportBrokenSite: domainEvent = .brokenSiteReportShown
case .reportBrokenSiteShown: domainEvent = .brokenSiteReportShown
case .reportBrokenSiteSent: domainEvent = .brokenSiteReportSent
}
if let parameters {
PixelKit.fire(NonStandardEvent(domainEvent), withAdditionalParameters: parameters)
} else {
PixelKit.fire(NonStandardEvent(domainEvent))
}
}

init(privacyInfo: PrivacyInfo? = nil,
entryPoint: PrivacyDashboardEntryPoint = .dashboard,
privacyConfigurationManager: PrivacyConfigurationManaging = ContentBlocking.shared.privacyConfigurationManager) {
Expand All @@ -81,9 +93,8 @@ final class PrivacyDashboardViewController: NSViewController {
let toggleReportingManager = ToggleReportingManager(feature: toggleReportingFeature)
self.privacyDashboardController = PrivacyDashboardController(privacyInfo: privacyInfo,
entryPoint: entryPoint,
variant: .control,
toggleReportingManager: toggleReportingManager,
eventMapping: eventMapping)
eventMapping: privacyDashboardEvents)
super.init(nibName: nil, bundle: nil)
}

Expand All @@ -103,7 +114,7 @@ final class PrivacyDashboardViewController: NSViewController {
}

override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 360, height: 489))
view = ColorView(frame: NSRect(x: 0, y: 0, width: 360, height: 489), backgroundColor: NSColor(named: "PopoverBackgroundColor"))
initWebView()
}

Expand All @@ -128,6 +139,7 @@ final class PrivacyDashboardViewController: NSViewController {
configuration.preferences.setValue(true, forKey: "developerExtrasEnabled")
#endif
let webView = PrivacyDashboardWebView(frame: .zero, configuration: configuration)
webView.setValue(false, forKey: "drawsBackground")
self.webView = webView
view.addAndLayout(webView)

Expand Down Expand Up @@ -187,15 +199,6 @@ final class PrivacyDashboardViewController: NSViewController {

extension PrivacyDashboardViewController: PrivacyDashboardControllerDelegate {

func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController,
didSelectBreakageCategory category: String) {
// Not used in macOS
}

func privacyDashboardControllerDidRequestShowReportBrokenSite(_ privacyDashboardController: PrivacyDashboardController) {
// Not used in macOS: PixelKit.fire(GeneralPixel.privacyDashboardReportBrokenSite)
}

func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController,
didChangeProtectionSwitch protectionState: ProtectionState,
didSendReport: Bool) {
Expand Down Expand Up @@ -246,12 +249,9 @@ extension PrivacyDashboardViewController: PrivacyDashboardControllerDelegate {
dismiss()
}

func privacyDashboardControllerDidRequestShowAlertForMissingDescription(_ privacyDashboardController: PrivacyDashboardController) {
// Not used in macOS
}

func privacyDashboardControllerDidRequestShowGeneralFeedback(_ privacyDashboardController: PrivacyDashboardController) {
// Not used in macOS
dismiss()
FeedbackPresenter.presentFeedbackForm()
}

func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController,
Expand Down
6 changes: 6 additions & 0 deletions DuckDuckGo/Statistics/NonStandardPixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import Configuration
enum NonStandardPixel: PixelKitEventV2 {

case brokenSiteReport
case brokenSiteReportShown
case brokenSiteReportSent
case privacyDashboardReportBrokenSite
case emailEnabled
case emailDisabled
case emailUserPressedUseAddress
Expand All @@ -35,6 +38,9 @@ enum NonStandardPixel: PixelKitEventV2 {
var name: String {
switch self {
case .brokenSiteReport: return "epbf_macos_desktop"
case .brokenSiteReportSent: return "m_report-broken-site_sent"
case .brokenSiteReportShown: return "m_report-broken-site_shown"
case .privacyDashboardReportBrokenSite: return "mp_rb"
case .emailEnabled: return "email_enabled_macos_desktop"
case .emailDisabled: return "email_disabled_macos_desktop"
case .emailUserPressedUseAddress: return "email_filled_main_macos_desktop"
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "225.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", branch: "mgurgel/improved-breakage-form-pixel"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../AppKitExtensions"),
.package(path: "../XPCHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/FeatureFlags/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
targets: ["FeatureFlags"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "225.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", branch: "mgurgel/improved-breakage-form-pixel"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let package = Package(
.library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "225.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", branch: "mgurgel/improved-breakage-form-pixel"),
.package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"),
.package(path: "../AppLauncher"),
.package(path: "../UDSHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NewTabPage/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
targets: ["NewTabPage"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "225.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", branch: "mgurgel/improved-breakage-form-pixel"),
.package(path: "../WebKitExtensions"),
.package(path: "../Utilities"),
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SubscriptionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
targets: ["SubscriptionUI"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "225.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", branch: "mgurgel/improved-breakage-form-pixel"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../FeatureFlags")
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/WebKitExtensions/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "225.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", branch: "mgurgel/improved-breakage-form-pixel"),
.package(path: "../AppKitExtensions")
],
targets: [
Expand Down
16 changes: 16 additions & 0 deletions UnitTests/WebsiteBreakageReport/WebsiteBreakageReportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ class WebsiteBreakageReportTests: XCTestCase {
line: #line)
}

func testReportBrokenSiteShownPixel() {
fire(NonStandardEvent(NonStandardPixel.brokenSiteReportShown),
frequency: .standard,
and: .expect(pixelName: "m_report-broken-site_shown"),
file: #filePath,
line: #line)
}

func testReportBrokenSiteSentPixel() {
fire(NonStandardEvent(NonStandardPixel.brokenSiteReportSent),
frequency: .standard,
and: .expect(pixelName: "m_report-broken-site_sent"),
file: #filePath,
line: #line)
}

func testCommonSetOfFields() throws {
let breakage = BrokenSiteReport(
siteUrl: URL(string: "https://example.test/")!,
Expand Down
Loading