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

Second CPM experiment #3397

Merged
merged 10 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
4 changes: 2 additions & 2 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14287,8 +14287,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 199.2.0;
branch = "new-cpm-experiment";
kind = branch;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "e0c0c85c18372f73fb97c5cf070f1de70c906a1f",
"version" : "199.1.0"
"branch" : "new-cpm-experiment",
"revision" : "60b5c80d341c60195dfc6f1676dbd6ea9d42d8f9"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/AutoconsentUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ extension AutoconsentUserScript {
}
let remoteConfig = self.config.settings(for: .autoconsent)
let disabledCMPs = remoteConfig["disabledCMPs"] as? [String] ?? []
let isFilterListExperimentEnabled = config.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment)
let isFilterListExperimentEnabled = config.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment2)
let enableFilterList = isFilterListExperimentEnabled && AutoconsentFilterlistExperiment.cohort == AutoconsentFilterlistExperiment.test

replyHandler([
Expand Down
80 changes: 40 additions & 40 deletions DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ extension URL {
return nil
}

let privacyConfigurationManager = ContentBlocking.shared.privacyConfigurationManager
let isFilterListExperimentEnabled = privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment2)
var url = Self.duckDuckGo.appendingParameter(name: DuckDuckGoParameters.search.rawValue, value: trimmedQuery)
if isFilterListExperimentEnabled {
url = url.appendingParameter(name: "cpme", value: AutoconsentFilterlistExperiment.cohort == AutoconsentFilterlistExperiment.test ? "1" : "0")
}

// Add experimental atb parameter to SERP queries for internal users to display Privacy Reminder
// https://app.asana.com/0/1199230911884351/1205979030848528/f
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Menus/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ final class MainMenu: NSMenu {
NSMenuItem(title: "Reset Email Protection InContext Signup Prompt", action: #selector(MainViewController.resetEmailProtectionInContextPrompt))
NSMenuItem(title: "Reset Pixels Storage", action: #selector(MainViewController.resetDailyPixels))
NSMenuItem(title: "Reset Remote Messages", action: #selector(AppDelegate.resetRemoteMessages))
NSMenuItem(title: "Reset CPM Experiment Cohort (needs restart)", action: #selector(AppDelegate.resetCpmCohort))
NSMenuItem(title: "Reset CPM Experiment Cohort", action: #selector(AppDelegate.resetCpmCohort))
NSMenuItem(title: "Reset Duck Player Preferences", action: #selector(MainViewController.resetDuckPlayerPreferences))
NSMenuItem(title: "Reset Onboarding", action: #selector(MainViewController.resetOnboarding(_:)))
NSMenuItem(title: "Reset Contextual Onboarding", action: #selector(MainViewController.resetContextualOnboarding(_:)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class PrivacyDashboardViewController: NSViewController {
let privacyConfigurationManager = ContentBlocking.shared.privacyConfigurationManager
var updatedParameters = parameters
// do not enroll users who have CPM disabled
if CookiePopupProtectionPreferences.shared.isAutoconsentEnabled && privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment) {
if CookiePopupProtectionPreferences.shared.isAutoconsentEnabled && privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment2) {
updatedParameters["cpmExperiment"] = AutoconsentFilterlistExperiment.cohort == AutoconsentFilterlistExperiment.test ? "1" : "0"
}
PixelKit.fire(NonStandardEvent(NonStandardPixel.brokenSiteReport),
Expand Down
25 changes: 8 additions & 17 deletions DuckDuckGo/Tab/TabExtensions/AdClickAttributionTabExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protocol AdClickLogicProtocol: AnyObject {

func applyInheritedAttribution(state: AdClickAttributionLogic.State?)
func onRulesChanged(latestRules: [ContentBlockerRulesManager.Rules])
func onRequestDetected(request: DetectedRequest, cpmExperimentOn: Bool?)
func onRequestDetected(request: DetectedRequest)

func onBackForwardNavigation(mainFrameURL: URL?)
func onProvisionalNavigation() async
Expand All @@ -79,12 +79,11 @@ extension ContentBlockerRulesUserScript: ContentBlockerScriptProtocol {}

final class AdClickAttributionTabExtension: TabExtension {

private static func makeAdClickAttributionDetection(with dependencies: any AdClickAttributionDependencies, delegate: AdClickAttributionLogic, cpmExperimentOn: Bool?) -> AdClickAttributionDetection {
private static func makeAdClickAttributionDetection(with dependencies: any AdClickAttributionDependencies, delegate: AdClickAttributionLogic) -> AdClickAttributionDetection {
let detection = AdClickAttributionDetection(feature: dependencies.adClickAttribution,
tld: dependencies.tld,
eventReporting: dependencies.attributionEvents,
errorReporting: dependencies.attributionDebugEvents,
cpmExperimentOn: cpmExperimentOn)
errorReporting: dependencies.attributionDebugEvents)
detection.delegate = delegate
return detection

Expand All @@ -98,9 +97,9 @@ final class AdClickAttributionTabExtension: TabExtension {
errorReporting: dependencies.attributionDebugEvents)
}

private static func makeAdClickAttribution(with dependencies: any AdClickAttributionDependencies, cpmExperimentOn: Bool?) -> (AdClickLogicProtocol, AdClickAttributionDetecting) {
private static func makeAdClickAttribution(with dependencies: any AdClickAttributionDependencies) -> (AdClickLogicProtocol, AdClickAttributionDetecting) {
let logic = makeAdClickAttributionLogic(with: dependencies)
let detection = makeAdClickAttributionDetection(with: dependencies, delegate: logic, cpmExperimentOn: cpmExperimentOn)
let detection = makeAdClickAttributionDetection(with: dependencies, delegate: logic)
return (logic, detection)
}

Expand All @@ -120,26 +119,18 @@ final class AdClickAttributionTabExtension: TabExtension {
}

private var cancellables = Set<AnyCancellable>()
private let cpmExperimentOn: Bool?

init(inheritedAttribution: AdClickAttributionLogic.State?,
userContentControllerFuture: some Publisher<some UserContentControllerProtocol, Never>,
contentBlockerRulesScriptPublisher: some Publisher<(any ContentBlockerScriptProtocol)?, Never>,
trackerInfoPublisher: some Publisher<DetectedRequest, Never>,
dependencies: some AdClickAttributionDependencies,
dateTimeProvider: @escaping () -> Date = Date.init,
logicsProvider: (AdClickAttributionDependencies, Bool?) -> (AdClickLogicProtocol, AdClickAttributionDetecting) = AdClickAttributionTabExtension.makeAdClickAttribution) {
logicsProvider: (AdClickAttributionDependencies) -> (AdClickLogicProtocol, AdClickAttributionDetecting) = AdClickAttributionTabExtension.makeAdClickAttribution) {

self.dependencies = dependencies
self.dateTimeProvider = dateTimeProvider

// do not enroll users who have CPM disabled
if !CookiePopupProtectionPreferences.shared.isAutoconsentEnabled || !dependencies.privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(AutoconsentSubfeature.filterlistExperiment) {
self.cpmExperimentOn = nil
} else {
self.cpmExperimentOn = AutoconsentFilterlistExperiment.cohort == AutoconsentFilterlistExperiment.test
}
(self.logic, self.detection) = logicsProvider(dependencies, self.cpmExperimentOn)
(self.logic, self.detection) = logicsProvider(dependencies)
self.logic.delegate = self

// delay firing up until UserContentController is published
Expand Down Expand Up @@ -172,7 +163,7 @@ final class AdClickAttributionTabExtension: TabExtension {

trackerInfoPublisher
.sink { [weak self] tracker in
self?.logic.onRequestDetected(request: tracker, cpmExperimentOn: self?.cpmExperimentOn)
self?.logic.onRequestDetected(request: tracker)
}
.store(in: &cancellables)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AdClickAttributionTabExtensionTests: XCTestCase {
contentBlockerRulesScriptPublisher: self.contentBlockerRulesScriptSubj,
trackerInfoPublisher: self.trackerInfoPublisher,
dependencies: dependencies.privacyFeatures.contentBlocking,
dateTimeProvider: { self.now }) { _, _ in
dateTimeProvider: { self.now }) { _ in
(logic: self.logic, detection: self.detection)
}
}
Expand Down Expand Up @@ -671,7 +671,7 @@ class MockAdClickLogic: AdClickLogicProtocol {
}

var onRequestDetected: ((DetectedRequest) -> Void)!
func onRequestDetected(request: DetectedRequest, cpmExperimentOn: Bool? = nil) {
func onRequestDetected(request: DetectedRequest) {
onRequestDetected(request)
}

Expand Down
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {
"@duckduckgo/autoconsent": "^10.13.0"
"@duckduckgo/autoconsent": "^10.16.0"
}
}
Loading