Skip to content

Commit

Permalink
Fixes DuckPlayer Experiment issue (#3421)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations. Feel free to change it, although assigning a GitHub
reviewer and the items in bold are required.

⚠️ If you're an external contributor, please file an issue first before
working on a PR, as we can't guarantee that we will accept your changes
if they haven't been discussed ahead of time. Thanks!
-->

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
  • Loading branch information
afterxleep authored Oct 9, 2024
1 parent 974fca1 commit 9a9f720
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
33 changes: 21 additions & 12 deletions DuckDuckGo/Debug.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="fgi-g1-scz">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="fgi-g1-scz">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
Expand Down Expand Up @@ -360,7 +360,7 @@
<rect key="frame" x="0.0" y="1108" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="wKg-4u-kJ4" id="8Jc-Co-wqO">
<rect key="frame" x="0.0" y="0.0" width="395.5" height="44.5"/>
<rect key="frame" x="0.0" y="0.0" width="383.5" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<listContentConfiguration key="contentConfiguration" text="New Onboarding"/>
Expand Down Expand Up @@ -390,7 +390,16 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<listContentConfiguration key="contentConfiguration" text="Override DuckPlayer Experiment"/>
<listContentConfiguration key="contentConfiguration" text="Override DuckPlayer Experiment (Experiment)"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" tag="680" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="fW5-D1-guK">
<rect key="frame" x="0.0" y="1286" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="fW5-D1-guK" id="HTT-aN-Wcy">
<rect key="frame" x="0.0" y="0.0" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<listContentConfiguration key="contentConfiguration" text="Override DuckPlayer Experiment (Control)"/>
</tableViewCell>
</cells>
</tableViewSection>
Expand Down Expand Up @@ -974,42 +983,42 @@
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ConfigurationURLTableViewCell" id="i6Y-Di-PX3" customClass="ConfigurationURLTableViewCell" customModule="DuckDuckGo" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="414" height="92"/>
<rect key="frame" x="0.0" y="50" width="414" height="94"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="i6Y-Di-PX3" id="qn4-gq-5fa">
<rect key="frame" x="0.0" y="0.0" width="414" height="92"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="94"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="pKD-Xm-Eu1">
<rect key="frame" x="20" y="11" width="374" height="70"/>
<rect key="frame" x="20" y="11" width="374" height="72"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="j3A-OZ-DWy">
<rect key="frame" x="0.0" y="0.0" width="44" height="70"/>
<rect key="frame" x="0.0" y="0.0" width="44" height="72"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="gKw-J7-XIW">
<rect key="frame" x="0.0" y="0.0" width="44" height="23"/>
<rect key="frame" x="0.0" y="0.0" width="44" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="UrI-B0-rWf">
<rect key="frame" x="0.0" y="23" width="44" height="23.5"/>
<rect key="frame" x="0.0" y="24" width="44" height="23.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" name="accent"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6RK-ug-mZa">
<rect key="frame" x="0.0" y="47" width="44" height="23"/>
<rect key="frame" x="0.0" y="48" width="44" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Nkj-yK-cgm">
<rect key="frame" x="350" y="0.0" width="24" height="70"/>
<rect key="frame" x="350" y="0.0" width="24" height="72"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="Reload-24"/>
</button>
Expand Down
10 changes: 9 additions & 1 deletion DuckDuckGo/DuckPlayer/DuckPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/DuckPlayer/DuckPlayerLaunchExperiment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/RootDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class RootDebugViewController: UITableViewController {
case resetSyncPromoPrompts = 677
case resetDuckPlayerExperiment = 678
case overrideDuckPlayerExperiment = 679
case overrideDuckPlayerExperimentControl = 680
}

@IBOutlet weak var shareButton: UIBarButtonItem!
Expand Down Expand Up @@ -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")
}
}
}
Expand Down

0 comments on commit 9a9f720

Please sign in to comment.