Skip to content

Commit

Permalink
Remove experiment code
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklyp authored and mgurgel committed Jan 9, 2025
1 parent 6379f0d commit ee18970
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 79 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" : "2e2baf7d31c7d8e158a58bc1cb79498c1c727fd2",
"version" : "7.5.0"
"branch" : "pr-releases/pr-196",
"revision" : "16a157e094006b309a7dee7d5af3fb7d3593c3af"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public enum PrivacyFeature: String {
case performanceMetrics
case privacyPro
case sslCertificates
case brokenSiteReportExperiment
case toggleReports
case maliciousSiteProtection
case brokenSitePrompt
Expand Down
7 changes: 1 addition & 6 deletions Sources/PrivacyDashboard/PrivacyDashboardController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<PrivacyDashboardEvents>

weak var webView: WKWebView?
Expand All @@ -103,12 +102,10 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject {

public init(privacyInfo: PrivacyInfo?,
entryPoint: PrivacyDashboardEntryPoint,
variant: PrivacyDashboardVariant,
toggleReportingManager: ToggleReportingManaging,
eventMapping: EventMapping<PrivacyDashboardEvents>) {
self.privacyInfo = privacyInfo
self.entryPoint = entryPoint
self.variant = variant
self.eventMapping = eventMapping
self.toggleReportingManager = toggleReportingManager
script = PrivacyDashboardUserScript()
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 7 additions & 12 deletions Sources/PrivacyDashboard/PrivacyDashboardEntryPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
1 change: 0 additions & 1 deletion Sources/PrivacyDashboard/PrivacyDashboardEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
31 changes: 5 additions & 26 deletions Sources/PrivacyDashboard/PrivacyDashboardURLBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
Expand All @@ -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"

Expand All @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 0 additions & 24 deletions Sources/PrivacyDashboard/PrivacyDashboardVariant.swift

This file was deleted.

0 comments on commit ee18970

Please sign in to comment.