Skip to content

Commit

Permalink
Update Attribution logic and debug logs (#3514)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/856498667320406/1206957650592842/f
Tech Design URL:
CC:

**Description**:

Update the logic to reduce number of debug signals related to valid use
cases.
  • Loading branch information
bwaresiak authored Nov 7, 2024
1 parent 6b2e4f8 commit 207c8ba
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14972,7 +14972,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 206.0.0;
version = 207.0.0;
};
};
9D84E4002CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "OHHTTPStubs" */ = {
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" : "d00f87a30e35fe8f86df30973c3b5370688e3aaa",
"version" : "206.0.0"
"revision" : "6319be3a8a52024c62cec4320e94536b51f427ee",
"version" : "207.0.0"
}
},
{
Expand Down Expand Up @@ -75,7 +75,7 @@
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm",
"location" : "https://github.com/airbnb/lottie-spm.git",
"state" : {
"revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605",
"version" : "4.4.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Navigation
import PrivacyDashboard
import TrackerRadarKit
import WebKit
import os.log

protocol AdClickAttributionDependencies {

Expand Down Expand Up @@ -61,6 +62,8 @@ protocol AdClickLogicProtocol: AnyObject {
var state: AdClickAttributionLogic.State { get }
var delegate: AdClickAttributionLogicDelegate? { get set }

var debugID: String { get }

func applyInheritedAttribution(state: AdClickAttributionLogic.State?)
func onRulesChanged(latestRules: [ContentBlockerRulesManager.Rules])
func onRequestDetected(request: DetectedRequest)
Expand Down Expand Up @@ -131,6 +134,8 @@ final class AdClickAttributionTabExtension: TabExtension {
self.dependencies = dependencies
self.dateTimeProvider = dateTimeProvider
(self.logic, self.detection) = logicsProvider(dependencies)

Logger.contentBlocking.debug("<\(self.logic.debugID)> AttributionLogic created in Tab Extension")
self.logic.delegate = self

// delay firing up until UserContentController is published
Expand All @@ -144,6 +149,8 @@ final class AdClickAttributionTabExtension: TabExtension {

private func delayedInitialization(with userContentController: UserContentControllerProtocol, inheritedAttribution: AdClickAttributionLogic.State?, contentBlockerRulesScriptPublisher: some Publisher<(any ContentBlockerScriptProtocol)?, Never>, trackerInfoPublisher: some Publisher<DetectedRequest, Never>) {

Logger.contentBlocking.debug("<\(self.logic.debugID)> Performing delayed initialization")

cancellables.removeAll()
self.userContentController = userContentController

Expand Down Expand Up @@ -180,6 +187,8 @@ extension AdClickAttributionTabExtension: AdClickAttributionLogicDelegate {
return
}

Logger.contentBlocking.debug("<\(self.logic.debugID)> Attribution requesting Rule application for \(vendor ?? "<none>")")

let attributedTempListName = AdClickAttributionRulesProvider.Constants.attributedTempRuleListName

guard dependencies.privacyConfigurationManager.privacyConfig.isEnabled(featureKey: .contentBlocking) else {
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "206.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "207.0.0"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../AppKitExtensions"),
.package(path: "../XPCHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
.library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "206.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "207.0.0"),
.package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"),
.package(path: "../AppLauncher"),
.package(path: "../UDSHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SubscriptionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["SubscriptionUI"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "206.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "207.0.0"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ class MockAdClickLogic: AdClickLogicProtocol {
self.delegate!.attributionLogic(castedLogic, didRequestRuleApplication: .init(name: "rulesList", rulesList: ruleList, trackerData: .mock, encodedTrackerData: "etd", etag: "etag", identifier: .mock), forVendor: "vnd")
}

var debugID = "test"

var onRulesChanged: (([ContentBlockerRulesManager.Rules]) -> Void)?
func onRulesChanged(latestRules: [ContentBlockerRulesManager.Rules]) {
onRulesChanged?(latestRules)
Expand Down Expand Up @@ -802,8 +804,8 @@ extension AdClickAttributionLogic.State: Equatable {
case .noAttribution: if case .noAttribution = rhs { return true }
case .activeAttribution(vendor: let vendor, session: let session, rules: let rules):
if case .activeAttribution(vendor: vendor, session: session, rules: rules) = rhs { return true }
case .preparingAttribution(vendor: let vendor, session: let session, completionBlocks: _):
if case .preparingAttribution(vendor: vendor, session: session, completionBlocks: _) = rhs { return true }
case .preparingAttribution(vendor: let vendor, session: let session, let id, completionBlocks: _):
if case .preparingAttribution(vendor: vendor, session: session, requestID: id, completionBlocks: _) = rhs { return true }
}
return false
}
Expand Down

0 comments on commit 207c8ba

Please sign in to comment.