From 4bd587ecf6d255b03d2dcee77520f585b126e319 Mon Sep 17 00:00:00 2001 From: Shilpa Modi Date: Mon, 9 Dec 2024 13:43:23 -0800 Subject: [PATCH] Adding pixel info for content blocking compilation performance tracking (#3634) Task/Issue URL: https://app.asana.com/0/1208613456171888/1208801514911205/f Tech Design URL: https://app.asana.com/0/481882893211075/1208730499188670/f CC: **Description**: **Optional E2E tests**: - [ ] Run PIR E2E tests Check this to run the Personal Information Removal end to end tests. If updating CCF, or any PIR related code, tick this. **Steps to test this PR**: 1. **Definition of Done**: * [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)? --- ###### Internal references: [Pull Request Review Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f) [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) [Pull Request Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f) --------- Co-authored-by: Bartek Waresiak --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 6 +-- .../ContentBlocker/ContentBlocking.swift | 9 ++-- DuckDuckGo/Statistics/GeneralPixel.swift | 50 ++++++++++++++++++- .../DataBrokerProtection/Package.swift | 2 +- LocalPackages/FeatureFlags/Package.swift | 2 +- .../NetworkProtectionMac/Package.swift | 2 +- LocalPackages/NewTabPage/Package.swift | 2 +- LocalPackages/SubscriptionUI/Package.swift | 2 +- LocalPackages/WebKitExtensions/Package.swift | 2 +- 10 files changed, 64 insertions(+), 15 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 78b0fc71b0..54859ef52c 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -15225,7 +15225,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 219.1.0; + version = 220.0.0; }; }; 9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 13e8327423..ca5824b07e 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "revision" : "6c335fb4355e7128dd9fb9fd25ac3de8942846ad", - "version" : "219.1.0" + "revision" : "55e7de13a99793329993367169c9b6bafbd07bac", + "version" : "220.0.0" } }, { @@ -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" diff --git a/DuckDuckGo/ContentBlocker/ContentBlocking.swift b/DuckDuckGo/ContentBlocker/ContentBlocking.swift index 9505a8ecb7..7c80745c9a 100644 --- a/DuckDuckGo/ContentBlocker/ContentBlocking.swift +++ b/DuckDuckGo/ContentBlocker/ContentBlocking.swift @@ -148,10 +148,11 @@ final class AppContentBlocking { case .contentBlockingLRCMissing: domainEvent = .contentBlockingLRCMissing - case .contentBlockingCompilationTime: - // Temporarily avoid firing this pixel. This can be re-enabled if it's determined to be necessary later. - // domainEvent = .contentBlockingCompilationTime - return + + case .contentBlockingCompilationTaskPerformance(let iterationCount, let timeBucketAggregation): + let timeBucket = GeneralPixel.CompileTimeBucketAggregation(number: timeBucketAggregation) + domainEvent = .contentBlockingCompilationTaskPerformance(iterationCount: iterationCount, + timeBucketAggregation: timeBucket) } PixelKit.fire(DebugEvent(domainEvent, error: error), withAdditionalParameters: parameters) { _, error in diff --git a/DuckDuckGo/Statistics/GeneralPixel.swift b/DuckDuckGo/Statistics/GeneralPixel.swift index 747196a5e8..9310710727 100644 --- a/DuckDuckGo/Statistics/GeneralPixel.swift +++ b/DuckDuckGo/Statistics/GeneralPixel.swift @@ -318,6 +318,7 @@ enum GeneralPixel: PixelKitEventV2 { case contentBlockingFetchLRCSucceeded case contentBlockingNoMatchInLRC case contentBlockingLRCMissing + case contentBlockingCompilationTaskPerformance(iterationCount: Int, timeBucketAggregation: CompileTimeBucketAggregation) case secureVaultInitError(error: Error) case secureVaultError(error: Error) @@ -675,7 +676,7 @@ enum GeneralPixel: PixelKitEventV2 { case .duckPlayerContingencyLearnMoreClicked: return "duckplayer_mac_contingency_learn-more-clicked" - // Duck Player Temporary Overlay Pixels + // Duck Player Temporary Overlay Pixels case .duckPlayerYouTubeOverlayNavigationBack: return "duckplayer_youtube_overlay_navigation_back" case .duckPlayerYouTubeOverlayNavigationRefresh: @@ -946,6 +947,9 @@ enum GeneralPixel: PixelKitEventV2 { case .contentBlockingLRCMissing: return "content_blocking_lrc_missing" + case .contentBlockingCompilationTaskPerformance(let iterationCount, let timeBucketAggregation): + return "content_blocking_compilation_loops_\(iterationCount)_time_\(timeBucketAggregation)" + case .secureVaultInitError: return "secure_vault_init_error" case .secureVaultError: @@ -1446,4 +1450,48 @@ enum GeneralPixel: PixelKitEventV2 { enum AutofillParameterKeys { static var backfilled = "backfilled" } + + public enum CompileTimeBucketAggregation: String, CustomStringConvertible { + + public var description: String { rawValue } + + case lessThan1 = "1" + case lessThan2 = "2" + case lessThan3 = "3" + case lessThan4 = "4" + case lessThan5 = "5" + case lessThan6 = "6" + case lessThan7 = "7" + case lessThan8 = "8" + case lessThan9 = "9" + case lessThan10 = "10" + case more + + public init(number: Double) { + switch number { + case ...1: + self = .lessThan1 + case ...2: + self = .lessThan2 + case ...3: + self = .lessThan3 + case ...4: + self = .lessThan4 + case ...5: + self = .lessThan5 + case ...6: + self = .lessThan6 + case ...7: + self = .lessThan7 + case ...8: + self = .lessThan8 + case ...9: + self = .lessThan9 + case ...10: + self = .lessThan10 + default: + self = .more + } + } + } } diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index 289416f5a6..223495bf5f 100644 --- a/LocalPackages/DataBrokerProtection/Package.swift +++ b/LocalPackages/DataBrokerProtection/Package.swift @@ -29,7 +29,7 @@ let package = Package( targets: ["DataBrokerProtection"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "219.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "220.0.0"), .package(path: "../SwiftUIExtensions"), .package(path: "../AppKitExtensions"), .package(path: "../XPCHelper"), diff --git a/LocalPackages/FeatureFlags/Package.swift b/LocalPackages/FeatureFlags/Package.swift index 641c96a88e..6ed823eded 100644 --- a/LocalPackages/FeatureFlags/Package.swift +++ b/LocalPackages/FeatureFlags/Package.swift @@ -32,7 +32,7 @@ let package = Package( targets: ["FeatureFlags"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "219.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "220.0.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index 25d1c8c07a..492a33a9d9 100644 --- a/LocalPackages/NetworkProtectionMac/Package.swift +++ b/LocalPackages/NetworkProtectionMac/Package.swift @@ -32,7 +32,7 @@ let package = Package( .library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "219.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "220.0.0"), .package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"), .package(path: "../AppLauncher"), .package(path: "../UDSHelper"), diff --git a/LocalPackages/NewTabPage/Package.swift b/LocalPackages/NewTabPage/Package.swift index 6027653a24..fbba5fdac5 100644 --- a/LocalPackages/NewTabPage/Package.swift +++ b/LocalPackages/NewTabPage/Package.swift @@ -32,7 +32,7 @@ let package = Package( targets: ["NewTabPage"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "219.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "220.0.0"), .package(path: "../WebKitExtensions"), .package(path: "../Utilities"), ], diff --git a/LocalPackages/SubscriptionUI/Package.swift b/LocalPackages/SubscriptionUI/Package.swift index 1d7e305674..54fd97c285 100644 --- a/LocalPackages/SubscriptionUI/Package.swift +++ b/LocalPackages/SubscriptionUI/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["SubscriptionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "219.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "220.0.0"), .package(path: "../SwiftUIExtensions"), .package(path: "../FeatureFlags") ], diff --git a/LocalPackages/WebKitExtensions/Package.swift b/LocalPackages/WebKitExtensions/Package.swift index 75e695f858..86744b6565 100644 --- a/LocalPackages/WebKitExtensions/Package.swift +++ b/LocalPackages/WebKitExtensions/Package.swift @@ -32,7 +32,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "219.1.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "220.0.0"), .package(path: "../AppKitExtensions") ], targets: [