From 9a9f720ec64b2281cae4251e9b6c33bdfa2db2de Mon Sep 17 00:00:00 2001 From: Daniel Bernal Date: Wed, 9 Oct 2024 15:17:21 +0200 Subject: [PATCH] Fixes DuckPlayer Experiment issue (#3421) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task/Issue URL: https://app.asana.com/0/1207252092703676/1208450923559111/f **Description**: - Fix an issue with DP experiment that causes Control users to not see overlays --- DuckDuckGo/Debug.storyboard | 33 ++++++++++++------- DuckDuckGo/DuckPlayer/DuckPlayer.swift | 10 +++++- .../DuckPlayerLaunchExperiment.swift | 4 +-- DuckDuckGo/RootDebugViewController.swift | 4 +++ 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/DuckDuckGo/Debug.storyboard b/DuckDuckGo/Debug.storyboard index 313b40911f..ec8cb0aca3 100644 --- a/DuckDuckGo/Debug.storyboard +++ b/DuckDuckGo/Debug.storyboard @@ -1,9 +1,9 @@ - + - + @@ -360,7 +360,7 @@ - + @@ -390,7 +390,16 @@ - + + + + + + + + + + @@ -974,34 +983,34 @@ - + - + - + - + diff --git a/DuckDuckGo/DuckPlayer/DuckPlayer.swift b/DuckDuckGo/DuckPlayer/DuckPlayer.swift index e3630118c1..cde2b9d08b 100644 --- a/DuckDuckGo/DuckPlayer/DuckPlayer.swift +++ b/DuckDuckGo/DuckPlayer/DuckPlayer.swift @@ -184,7 +184,15 @@ final class DuckPlayer: DuckPlayerProtocol { } public func getUserValues(params: Any, message: WKScriptMessage) -> Encodable? { - encodeUserValues() + // If the user is in the 'control' group, sending 'nil' effectively disables + // Duckplayer in SERP, showing old overlays. + // Fixes: https://app.asana.com/0/1207252092703676/1208450923559111 + let duckPlayerExperiment = DuckPlayerLaunchExperiment() + if duckPlayerExperiment.isEnrolled && duckPlayerExperiment.isExperimentCohort { + return encodeUserValues() + } + return nil + } @MainActor diff --git a/DuckDuckGo/DuckPlayer/DuckPlayerLaunchExperiment.swift b/DuckDuckGo/DuckPlayer/DuckPlayerLaunchExperiment.swift index 8edd25ed56..be9821fe3e 100644 --- a/DuckDuckGo/DuckPlayer/DuckPlayerLaunchExperiment.swift +++ b/DuckDuckGo/DuckPlayer/DuckPlayerLaunchExperiment.swift @@ -227,9 +227,9 @@ final class DuckPlayerLaunchExperiment: DuckPlayerLaunchExperimentHandling { lastVideoIDReportedV2 = nil } - func override() { + func override(control: Bool = false) { enrollmentDateV2 = Date() - experimentCohortV2 = "experiment" + experimentCohortV2 = control ? "control" : "experiment" lastDayPixelFiredV2 = nil lastWeekPixelFiredV2 = nil lastVideoIDReportedV2 = nil diff --git a/DuckDuckGo/RootDebugViewController.swift b/DuckDuckGo/RootDebugViewController.swift index 287ef73822..23500ebf8c 100644 --- a/DuckDuckGo/RootDebugViewController.swift +++ b/DuckDuckGo/RootDebugViewController.swift @@ -49,6 +49,7 @@ class RootDebugViewController: UITableViewController { case resetSyncPromoPrompts = 677 case resetDuckPlayerExperiment = 678 case overrideDuckPlayerExperiment = 679 + case overrideDuckPlayerExperimentControl = 680 } @IBOutlet weak var shareButton: UIBarButtonItem! @@ -189,6 +190,9 @@ class RootDebugViewController: UITableViewController { case .overrideDuckPlayerExperiment: DuckPlayerLaunchExperiment().override() ActionMessageView.present(message: "Overriding experiment. You are now in the 'experiment' group. Restart the app to complete") + case .overrideDuckPlayerExperimentControl: + DuckPlayerLaunchExperiment().override(control: true) + ActionMessageView.present(message: "Overriding experiment. You are now in the 'control' group. Restart the app to complete") } } }