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

Cleanup after rolling out autoconsent enabled by default #2537

Merged
merged 10 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Core/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public enum FeatureFlag: String {
case networkProtectionWaitlistActive
case subscription
case swipeTabs
case autoconsentOnByDefault
case history
}

Expand Down Expand Up @@ -67,8 +66,6 @@ extension FeatureFlag: FeatureFlagSourceProviding {
return .remoteReleasable(.subfeature(AutofillSubfeature.onByDefault))
case .incontextSignup:
return .remoteReleasable(.feature(.incontextSignup))
case .autoconsentOnByDefault:
return .remoteReleasable(.subfeature(AutoconsentSubfeature.onByDefault))
case .history:
return .remoteReleasable(.feature(.history))
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10045,7 +10045,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 117.0.0;
version = 118.0.0;
};
};
B6F997C22B8F374300476735 /* XCRemoteSwiftPackageReference "apple-toolbox" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "dbe75fa0ee9e3b740d520d5be7967e2c5239dfb5",
"version" : "117.0.0"
"revision" : "2181cdcd27be961f10d988fbb202431a6ec6d56d",
"version" : "118.0.0"
}
},
{
Expand Down
26 changes: 2 additions & 24 deletions DuckDuckGo/AppUserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import Bookmarks
import Core
import WidgetKit

// swiftlint:disable file_length
public class AppUserDefaults: AppSettings {

public struct Notifications {
Expand Down Expand Up @@ -291,29 +290,8 @@ public class AppUserDefaults: AppSettings {
}
}

var autoconsentEnabled: Bool {
get {
// Use settings value if present
if let isEnabled = autoconsentEnabledSetting {
return isEnabled
}

// Use onByDefault rollout otherwise
return featureFlagger.isFeatureOn(.autoconsentOnByDefault)
}

set {
autoconsentEnabledSetting = newValue
}
}

// Only for testing and `DebugViewController` purposes
func clearAutoconsentUserSetting() {
autoconsentEnabledSetting = nil
}

@UserDefaultsWrapper(key: .autoconsentEnabled, defaultValue: false)
private var autoconsentEnabledSetting: Bool?
@UserDefaultsWrapper(key: .autoconsentEnabled, defaultValue: true)
var autoconsentEnabled: Bool

var inspectableWebViewEnabled: Bool {
get {
Expand Down
25 changes: 8 additions & 17 deletions DuckDuckGo/Debug.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,8 @@
<segue destination="0MU-T6-Wln" kind="show" id="xqR-NF-fao"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" tag="665" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="iau-ES-Bnx">
<rect key="frame" x="0.0" y="529.5" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="iau-ES-Bnx" id="DHw-no-bUr">
<rect key="frame" x="0.0" y="0.0" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<listContentConfiguration key="contentConfiguration" text="Reset Autoconsent Settings"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" tag="668" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="checkmark" indentationWidth="10" id="f8n-C1-CnF">
<rect key="frame" x="0.0" y="574" width="414" height="44.5"/>
<rect key="frame" x="0.0" y="529.5" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="f8n-C1-CnF" id="Gna-nE-FtW">
<rect key="frame" x="0.0" y="0.0" width="370" height="44.5"/>
Expand All @@ -252,7 +243,7 @@
<listContentConfiguration key="contentConfiguration" text="Enable Inspectable WebViews" secondaryText=""/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" tag="669" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="checkmark" indentationWidth="10" id="AgK-xW-xB6">
<rect key="frame" x="0.0" y="618.5" width="414" height="44.5"/>
<rect key="frame" x="0.0" y="574" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="AgK-xW-xB6" id="onY-PV-AQp">
<rect key="frame" x="0.0" y="0.0" width="370" height="44.5"/>
Expand All @@ -261,7 +252,7 @@
<listContentConfiguration key="contentConfiguration" text="Internal User State" secondaryText=""/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" tag="666" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="Lqc-aq-UoJ">
<rect key="frame" x="0.0" y="663" width="414" height="44.5"/>
<rect key="frame" x="0.0" y="618.5" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Lqc-aq-UoJ" id="SOZ-8q-BYe">
<rect key="frame" x="0.0" y="0.0" width="414" height="44.5"/>
Expand All @@ -270,7 +261,7 @@
<listContentConfiguration key="contentConfiguration" text="Crash (fatal error)"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" tag="667" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="roW-Eb-6hF">
<rect key="frame" x="0.0" y="707.5" width="414" height="44.5"/>
<rect key="frame" x="0.0" y="663" width="414" height="44.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="roW-Eb-6hF" id="1IO-6X-jOv">
<rect key="frame" x="0.0" y="0.0" width="414" height="44.5"/>
Expand Down Expand Up @@ -846,17 +837,17 @@
<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="76.5"/>
<rect key="frame" x="0.0" y="50" width="414" height="77"/>
<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="76.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="77"/>
<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="54.5"/>
<rect key="frame" x="20" y="11" width="374" height="55"/>
<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="54.5"/>
<rect key="frame" x="0.0" y="0.0" width="44" height="55"/>
<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="18"/>
Expand Down
7 changes: 0 additions & 7 deletions DuckDuckGo/RootDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import DDGSync
class RootDebugViewController: UITableViewController {

enum Row: Int {
case resetAutoconsentPrompt = 665
case crashFatalError = 666
case crashMemory = 667
case toggleInspectableWebViews = 668
Expand Down Expand Up @@ -107,12 +106,6 @@ class RootDebugViewController: UITableViewController {
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

if tableView.cellForRow(at: indexPath)?.tag == Row.resetAutoconsentPrompt.rawValue {
AppUserDefaults().clearAutoconsentUserSetting()
tableView.deselectRow(at: indexPath, animated: true)
}

if tableView.cellForRow(at: indexPath)?.tag == Row.crashFatalError.rawValue {
fatalError(#function)
}
Expand Down
24 changes: 1 addition & 23 deletions DuckDuckGoTests/AppUserDefaultsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,8 @@ class AppUserDefaultsTests: XCTestCase {
XCTAssertEqual(appUserDefaults.autofillCredentialsEnabled, false)
}

func testDefaultAutoconsentStateIsFalse_WhenNotInRollout() {
func testDefaultAutoconsentStateIsTrue() {
let appUserDefaults = AppUserDefaults(groupName: testGroupName)
appUserDefaults.featureFlagger = createFeatureFlagger(withSubfeatureEnabled: false)
XCTAssertFalse(appUserDefaults.autoconsentEnabled)
}

func testDefaultAutoconsentStateIsTrue_WhenInRollout() {
let appUserDefaults = AppUserDefaults(groupName: testGroupName)
appUserDefaults.featureFlagger = createFeatureFlagger(withSubfeatureEnabled: true)
XCTAssertTrue(appUserDefaults.autoconsentEnabled)
}

func testAutoconsentReadsUserStoredValue_RegardlessOfRolloutState() {
let appUserDefaults = AppUserDefaults(groupName: testGroupName)

// When setting disabled by user and rollout enabled
appUserDefaults.autoconsentEnabled = false
appUserDefaults.featureFlagger = createFeatureFlagger(withSubfeatureEnabled: true)

XCTAssertFalse(appUserDefaults.autoconsentEnabled)

// When setting enabled by user and rollout disabled
appUserDefaults.autoconsentEnabled = true
appUserDefaults.featureFlagger = createFeatureFlagger(withSubfeatureEnabled: false)

XCTAssertTrue(appUserDefaults.autoconsentEnabled)
}
Expand Down
Loading