Skip to content

Commit

Permalink
Second macOS CPM experiment (#1017)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations.
-->

Please review the release process for BrowserServicesKit
[here](https://app.asana.com/0/1200194497630846/1200837094583426).

**Required**:

Task/Issue URL:
https://app.asana.com/0/1205142657210376/1208488711477099/f
iOS PR: 
macOS PR: duckduckgo/macos-browser#3397
What kind of version bump will this require?: Major/Minor/Patch

**Optional**:

Tech Design URL:
https://app.asana.com/0/1205142657210376/1208527766092596/f
CC: @ayoy

**Description**:

<!--
Tagging instructions
If this PR isn't ready to be merged for whatever reason it should be
marked with the `DO NOT MERGE` label (particularly if it's a draft)
If it's pending Product Review/PFR, please add the `Pending Product
Review` label.

If at any point it isn't actively being worked on/ready for
review/otherwise moving forward (besides the above PR/PFR exception)
strongly consider closing it (or not opening it in the first place). If
you decide not to close it, make sure it's labelled to make it clear the
PRs state and comment with more information.
-->

This PR cleans up the previous experiment (#937), and creates a new
subfeature for the new experiment. The experiment logic will be in the
macOS PR.

**Steps to test this PR**:
1.
1.

<!--
Before submitting a PR, please ensure you have tested the combinations
you expect the reviewer to test, then delete configurations you *know*
do not need explicit testing.

Using a simulator where a physical device is unavailable is acceptable.
-->

**OS Testing**:

* [ ] iOS 14
* [ ] iOS 15
* [ ] iOS 16
* [ ] macOS 10.15
* [ ] macOS 11
* [ ] macOS 12

---
###### Internal references:
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
  • Loading branch information
muodov authored Oct 18, 2024
1 parent 4e9ce77 commit f1a033c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,17 @@ public class AdClickAttributionDetection {
private let tld: TLD
private let eventReporting: EventMapping<AdClickAttributionEvents>?
private let errorReporting: EventMapping<AdClickAttributionDebugEvents>?
private let cpmExperimentOn: Bool?

public weak var delegate: AdClickAttributionDetectionDelegate?

public init(feature: AdClickAttributing,
tld: TLD,
eventReporting: EventMapping<AdClickAttributionEvents>? = nil,
errorReporting: EventMapping<AdClickAttributionDebugEvents>? = nil,
cpmExperimentOn: Bool? = nil) {
errorReporting: EventMapping<AdClickAttributionDebugEvents>? = nil) {
self.attributionFeature = feature
self.tld = tld
self.eventReporting = eventReporting
self.errorReporting = errorReporting
self.cpmExperimentOn = cpmExperimentOn
}

// MARK: - Public API
Expand Down Expand Up @@ -146,12 +143,9 @@ public class AdClickAttributionDetection {
domainDetection = "none"
}

var parameters = [AdClickAttributionEvents.Parameters.domainDetection: domainDetection,
let parameters = [AdClickAttributionEvents.Parameters.domainDetection: domainDetection,
AdClickAttributionEvents.Parameters.domainDetectionEnabled: attributionFeature.isDomainDetectionEnabled ? "1" : "0",
AdClickAttributionEvents.Parameters.heuristicDetectionEnabled: attributionFeature.isHeuristicDetectionEnabled ? "1" : "0"]
if let cpmExperimentOn {
parameters[AdClickAttributionEvents.Parameters.cpmExperiment] = cpmExperimentOn ? "1" : "0"
}
eventReporting?.fire(.adAttributionDetected, parameters: parameters)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public enum AdClickAttributionEvents {
public static let heuristicDetectionEnabled = "heuristicDetectionEnabled"
public static let domainDetectionEnabled = "domainDetectionEnabled"
public static let count = "count"
public static let cpmExperiment = "cpmExperiment"
}

case adAttributionDetected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,11 @@ public class AdClickAttributionLogic {
}
}

public func onRequestDetected(request: DetectedRequest, cpmExperimentOn: Bool? = nil) {
public func onRequestDetected(request: DetectedRequest) {
guard registerFirstActivity,
BlockingState.allowed(reason: .adClickAttribution) == request.state else { return }

var parameters: [String: String] = [:]
if let cpmExperimentOn {
parameters[AdClickAttributionEvents.Parameters.cpmExperiment] = cpmExperimentOn ? "1" : "0"
}
eventReporting?.fire(.adAttributionActive, parameters: parameters)
eventReporting?.fire(.adAttributionActive)
registerFirstActivity = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public enum AutoconsentSubfeature: String, PrivacySubfeature {
}

case onByDefault
case filterlistExperiment
case filterlistExperiment2
}

public enum PrivacyProSubfeature: String, Equatable, PrivacySubfeature {
Expand Down

0 comments on commit f1a033c

Please sign in to comment.