From fb586b4e150609cb37c6fd49cc620b067eedb2d8 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 7 Feb 2025 10:06:27 +0000 Subject: [PATCH 1/9] Duck Player custom error support --- DuckDuckGo/YoutubePlayer/DuckPlayer.swift | 8 +++++++- DuckDuckGo/YoutubePlayer/YoutubePlayerUserScript.swift | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift index e9c9896f1b..8a96d78608 100644 --- a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift +++ b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift @@ -246,7 +246,13 @@ final class DuckPlayer { return self.encodeUserValues() } } - + + public func handleYoutubeError(params: Any, message: UserScriptMessage) -> Encodable? { + print("Youtube Error \(message)"); + return nil; + } + + public func handleGetUserValues(params: Any, message: UserScriptMessage) -> Encodable? { encodeUserValues() } diff --git a/DuckDuckGo/YoutubePlayer/YoutubePlayerUserScript.swift b/DuckDuckGo/YoutubePlayer/YoutubePlayerUserScript.swift index 64ebf4c222..05248c2f8c 100644 --- a/DuckDuckGo/YoutubePlayer/YoutubePlayerUserScript.swift +++ b/DuckDuckGo/YoutubePlayer/YoutubePlayerUserScript.swift @@ -43,6 +43,7 @@ final class YoutubePlayerUserScript: NSObject, Subfeature { case setUserValues case getUserValues case initialSetup + case reportYouTubeError } func handler(forMethodNamed methodName: String) -> Subfeature.Handler? { @@ -56,6 +57,8 @@ final class YoutubePlayerUserScript: NSObject, Subfeature { return DuckPlayer.shared.handleSetUserValuesMessage(from: .duckPlayer) case .initialSetup: return DuckPlayer.shared.initialPlayerSetup(with: webView) + case .reportYouTubeError: + return DuckPlayer.shared.handleYoutubeError default: assertionFailure("YoutubePlayerUserScript: Failed to parse User Script message: \(methodName)") return nil From 662f3f4d9b5c9cebc7762892759331c263181515 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Wed, 12 Feb 2025 20:36:05 +0000 Subject: [PATCH 2/9] Pixel and privacy config for custom Duck Player error --- DuckDuckGo/Statistics/GeneralPixel.swift | 6 +++- DuckDuckGo/YoutubePlayer/DuckPlayer.swift | 44 +++++++++++++++++++---- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/DuckDuckGo/Statistics/GeneralPixel.swift b/DuckDuckGo/Statistics/GeneralPixel.swift index 77898e6344..90e15a2e7f 100644 --- a/DuckDuckGo/Statistics/GeneralPixel.swift +++ b/DuckDuckGo/Statistics/GeneralPixel.swift @@ -136,6 +136,7 @@ enum GeneralPixel: PixelKitEventV2 { case duckPlayerNewTabSettingsOff case duckPlayerContingencySettingsDisplayed case duckPlayerContingencyLearnMoreClicked + case duckPlayerYouTubeErrorImpression // Temporary Overlay Pixels case duckPlayerYouTubeOverlayNavigationBack @@ -685,6 +686,8 @@ enum GeneralPixel: PixelKitEventV2 { return "duckplayer_mac_contingency_settings-displayed" case .duckPlayerContingencyLearnMoreClicked: return "duckplayer_mac_contingency_learn-more-clicked" + case .duckPlayerYouTubeErrorImpression: + return "duckplayer_mac_youtube-error_impression" // Duck Player Temporary Overlay Pixels case .duckPlayerYouTubeOverlayNavigationBack: @@ -1341,7 +1344,8 @@ enum GeneralPixel: PixelKitEventV2 { .duckPlayerNewTabSettingsOff, .duckPlayerContingencySettingsDisplayed, .duckPlayerWeeklyUniqueView, - .duckPlayerContingencyLearnMoreClicked: + .duckPlayerContingencyLearnMoreClicked, + .duckPlayerYouTubeErrorImpression: return nil case .bookmarksSortButtonClicked(let origin), diff --git a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift index 8a96d78608..5abe95f170 100644 --- a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift +++ b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift @@ -59,6 +59,7 @@ struct InitialPlayerSettings: Codable { let pip: PIP let autoplay: Autoplay let focusMode: FocusMode + let customError: CustomError } struct PIP: Codable { @@ -88,6 +89,11 @@ struct InitialPlayerSettings: Codable { let state: State } + struct CustomError: Codable { + let state: State + let signInRequiredSelector: String + } + enum State: String, Codable { case enabled case disabled @@ -137,6 +143,11 @@ public struct UIUserValues: Codable { } } +// Custom Error privacy config settings +struct CustomErrorSettings: Codable { + let signInRequiredSelector: String +} + final class DuckPlayer { static let usesSimulatedRequests: Bool = { if #available(macOS 12.0, *) { @@ -178,6 +189,16 @@ final class DuckPlayer { isFeatureEnabled = privacyConfigurationManager.privacyConfig.isEnabled(featureKey: .duckPlayer) isPiPFeatureEnabled = privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(DuckPlayerSubfeature.pip) isAutoplayFeatureEnabled = privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(DuckPlayerSubfeature.autoplay) + isCustomErrorFeatureEnabled = + privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(DuckPlayerSubfeature.customError) + + // Question for Daniel: is the string return type for Subfeature settings just a stub or intentional? + if let customErrorSettingsJSON = privacyConfigurationManager.privacyConfig.settings(for: DuckPlayerSubfeature.customError), + let jsonData = customErrorSettingsJSON.data(using: .utf8), + let customErrorSettings: CustomErrorSettings = DecodableHelper.decode(jsonData: jsonData) { + customErrorSignInRequiredSelector = customErrorSettings.signInRequiredSelector + } + self.onboardingDecider = onboardingDecider mode = preferences.duckPlayerMode @@ -246,13 +267,21 @@ final class DuckPlayer { return self.encodeUserValues() } } - + public func handleYoutubeError(params: Any, message: UserScriptMessage) -> Encodable? { - print("Youtube Error \(message)"); - return nil; + var pixelParams: [String: String] = [:] + if let paramsDict = params as? [String: Any], + let errorParam = paramsDict["error"] as? String { + pixelParams["error"] = errorParam + } else { + pixelParams["error"] = "unknown" + } + + // TODO: Fire once daily impression + PixelKit.fire(GeneralPixel.duckPlayerYouTubeErrorImpression, withAdditionalParameters: pixelParams) + return nil } - - + public func handleGetUserValues(params: Any, message: UserScriptMessage) -> Encodable? { encodeUserValues() } @@ -300,7 +329,8 @@ final class DuckPlayer { let environment = InitialPlayerSettings.Environment.development let locale = InitialPlayerSettings.Locale.en let focusMode = InitialPlayerSettings.FocusMode(state: onboardingDecider.shouldOpenFirstVideoOnDuckPlayer ? .disabled : .enabled) - let playerSettings = InitialPlayerSettings.PlayerSettings(pip: pip, autoplay: autoplay, focusMode: focusMode) + let customError = InitialPlayerSettings.CustomError(state: isCustomErrorFeatureEnabled ? .enabled : .disabled, signInRequiredSelector: customErrorSignInRequiredSelector ?? "") + let playerSettings = InitialPlayerSettings.PlayerSettings(pip: pip, autoplay: autoplay, focusMode: focusMode, customError: customError) let userValues = encodeUserValues() /// Since the FE is requesting player-encoded values, we can assume that the first player video setup is complete from the onboarding point of view. @@ -345,6 +375,8 @@ final class DuckPlayer { private var isFeatureEnabledCancellable: AnyCancellable? private var isPiPFeatureEnabled: Bool private var isAutoplayFeatureEnabled: Bool + private var isCustomErrorFeatureEnabled: Bool + private var customErrorSignInRequiredSelector: String? private let onboardingDecider: DuckPlayerOnboardingDecider private var shouldOpenNextVideoOnYoutube: Bool = false From d7f55b610bcc3d69bcb44fb3a98de00bd0775395 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Wed, 12 Feb 2025 20:46:40 +0000 Subject: [PATCH 3/9] Temporary override --- DuckDuckGo/YoutubePlayer/DuckPlayer.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift index 5abe95f170..128bac0790 100644 --- a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift +++ b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift @@ -329,7 +329,11 @@ final class DuckPlayer { let environment = InitialPlayerSettings.Environment.development let locale = InitialPlayerSettings.Locale.en let focusMode = InitialPlayerSettings.FocusMode(state: onboardingDecider.shouldOpenFirstVideoOnDuckPlayer ? .disabled : .enabled) - let customError = InitialPlayerSettings.CustomError(state: isCustomErrorFeatureEnabled ? .enabled : .disabled, signInRequiredSelector: customErrorSignInRequiredSelector ?? "") + + // TODO: Remove temporary override to skip deploying a new config + // let customError = InitialPlayerSettings.CustomError(state: isCustomErrorFeatureEnabled ? .enabled : .disabled, signInRequiredSelector: customErrorSignInRequiredSelector ?? "") + let customError = InitialPlayerSettings.CustomError(state: .enabled, signInRequiredSelector: "[href*=\"//support.google.com/youtube/answer/3037019\"]") + let playerSettings = InitialPlayerSettings.PlayerSettings(pip: pip, autoplay: autoplay, focusMode: focusMode, customError: customError) let userValues = encodeUserValues() From 440b397b1218d59d6a2ce4c1875e8882671b5629 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Wed, 12 Feb 2025 20:46:49 +0000 Subject: [PATCH 4/9] Temporary dependencies --- DuckDuckGo-macOS.xcodeproj/project.pbxproj | 4 +- .../xcshareddata/swiftpm/Package.resolved | 221 ------------------ 2 files changed, 2 insertions(+), 223 deletions(-) delete mode 100644 DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/DuckDuckGo-macOS.xcodeproj/project.pbxproj b/DuckDuckGo-macOS.xcodeproj/project.pbxproj index d5532d5f70..1487800c62 100644 --- a/DuckDuckGo-macOS.xcodeproj/project.pbxproj +++ b/DuckDuckGo-macOS.xcodeproj/project.pbxproj @@ -15717,8 +15717,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { - kind = exactVersion; - version = 237.1.0; + branch = "mgurgel/duckplayer-custom-error"; + kind = branch; }; }; 9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index b99ee2ce38..0000000000 --- a/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,221 +0,0 @@ -{ - "pins" : [ - { - "identity" : "apple-toolbox", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/apple-toolbox.git", - "state" : { - "revision" : "0c13c5f056805f2d403618ccc3bfb833c303c68d", - "version" : "3.1.2" - } - }, - { - "identity" : "barebonesbrowser", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/BareBonesBrowser.git", - "state" : { - "revision" : "31e5bfedc3c2ca005640c4bf2b6959d69b0e18b9", - "version" : "0.1.0" - } - }, - { - "identity" : "bloom_cpp", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/bloom_cpp.git", - "state" : { - "revision" : "8076199456290b61b4544bf2f4caf296759906a0", - "version" : "3.0.0" - } - }, - { - "identity" : "browserserviceskit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/BrowserServicesKit", - "state" : { - "revision" : "92f57bfcf15258a360f6df8a48da756491683fe0", - "version" : "237.1.0" - } - }, - { - "identity" : "content-scope-scripts", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/content-scope-scripts", - "state" : { - "revision" : "874b27ad51d1784c934760c85493f78e609c4409", - "version" : "7.18.0" - } - }, - { - "identity" : "duckduckgo-autofill", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/duckduckgo-autofill.git", - "state" : { - "revision" : "676d42679296a175169e433f2332e55644151edd", - "version" : "16.2.0" - } - }, - { - "identity" : "grdb.swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/GRDB.swift.git", - "state" : { - "revision" : "5b2f6a81099d26ae0f9e38788f51490cd6a4b202", - "version" : "2.4.2" - } - }, - { - "identity" : "gzipswift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/1024jp/GzipSwift.git", - "state" : { - "revision" : "731037f6cc2be2ec01562f6597c1d0aa3fe6fd05", - "version" : "6.0.1" - } - }, - { - "identity" : "jwt-kit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/jwt-kit.git", - "state" : { - "revision" : "c2595b9ad7f512d7f334830b4df1fed6e917946a", - "version" : "4.13.4" - } - }, - { - "identity" : "lottie-spm", - "kind" : "remoteSourceControl", - "location" : "https://github.com/airbnb/lottie-spm.git", - "state" : { - "revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605", - "version" : "4.4.3" - } - }, - { - "identity" : "ohhttpstubs", - "kind" : "remoteSourceControl", - "location" : "https://github.com/AliSoftware/OHHTTPStubs.git", - "state" : { - "revision" : "12f19662426d0434d6c330c6974d53e2eb10ecd9", - "version" : "9.1.0" - } - }, - { - "identity" : "openssl-xcframework", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/OpenSSL-XCFramework", - "state" : { - "revision" : "71d303cbfa150e1fac99ffc7b4f67aad9c7a5002", - "version" : "3.1.5004" - } - }, - { - "identity" : "privacy-dashboard", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/privacy-dashboard", - "state" : { - "revision" : "099f7ed5faac946e4d80746703aaaf87fdfbee09", - "version" : "8.3.0" - } - }, - { - "identity" : "punycodeswift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/gumob/PunycodeSwift.git", - "state" : { - "revision" : "30a462bdb4398ea835a3585472229e0d74b36ba5", - "version" : "3.0.0" - } - }, - { - "identity" : "sparkle", - "kind" : "remoteSourceControl", - "location" : "https://github.com/sparkle-project/Sparkle.git", - "state" : { - "revision" : "b456fd404954a9e13f55aa0c88cd5a40b8399638", - "version" : "2.6.3" - } - }, - { - "identity" : "swift-argument-parser", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-argument-parser.git", - "state" : { - "revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b", - "version" : "1.4.0" - } - }, - { - "identity" : "swift-asn1", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-asn1.git", - "state" : { - "revision" : "ae33e5941bb88d88538d0a6b19ca0b01e6c76dcf", - "version" : "1.3.1" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "f2f3774fd116a305136b6866e5e7cb7dff39d8f2", - "version" : "3.10.1" - } - }, - { - "identity" : "swift-snapshot-testing", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-snapshot-testing", - "state" : { - "revision" : "5b0c434778f2c1a4c9b5ebdb8682b28e84dd69bd", - "version" : "1.15.4" - } - }, - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax", - "state" : { - "revision" : "64889f0c732f210a935a0ad7cda38f77f876262d", - "version" : "509.1.1" - } - }, - { - "identity" : "swifter", - "kind" : "remoteSourceControl", - "location" : "https://github.com/httpswift/swifter.git", - "state" : { - "revision" : "9483a5d459b45c3ffd059f7b55f9638e268632fd", - "version" : "1.5.0" - } - }, - { - "identity" : "sync_crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/sync_crypto", - "state" : { - "revision" : "cc726cebb67367466bc31ced4784e16d44ac68d1", - "version" : "0.4.0" - } - }, - { - "identity" : "trackerradarkit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/TrackerRadarKit.git", - "state" : { - "revision" : "5de0a610a7927b638a5fd463a53032c9934a2c3b", - "version" : "3.0.0" - } - }, - { - "identity" : "wireguard-apple", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/wireguard-apple", - "state" : { - "revision" : "13fd026384b1af11048451061cc1b21434990668", - "version" : "1.1.3" - } - } - ], - "version" : 2 -} From 1236215c2dd0d0ed273b4fc735b9ca30c95a2c88 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 14 Feb 2025 10:49:35 +0000 Subject: [PATCH 5/9] Pixel update --- DuckDuckGo/Statistics/GeneralPixel.swift | 36 +++++++++++++++++--- DuckDuckGo/YoutubePlayer/DuckPlayer.swift | 40 +++++++++++++---------- 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/DuckDuckGo/Statistics/GeneralPixel.swift b/DuckDuckGo/Statistics/GeneralPixel.swift index 90e15a2e7f..8a5b2489ae 100644 --- a/DuckDuckGo/Statistics/GeneralPixel.swift +++ b/DuckDuckGo/Statistics/GeneralPixel.swift @@ -136,7 +136,14 @@ enum GeneralPixel: PixelKitEventV2 { case duckPlayerNewTabSettingsOff case duckPlayerContingencySettingsDisplayed case duckPlayerContingencyLearnMoreClicked - case duckPlayerYouTubeErrorImpression + case duckPlayerYouTubeSignInErrorImpression + case duckPlayerYouTubeAgeRestrictedErrorImpression + case duckPlayerYouTubeNoEmbedErrorImpression + case duckPlayerYouTubeUnknownErrorImpression + case duckPlayerYouTubeSignInErrorDaily + case duckPlayerYouTubeAgeRestrictedErrorDaily + case duckPlayerYouTubeNoEmbedErrorDaily + case duckPlayerYouTubeUnknownErrorDaily // Temporary Overlay Pixels case duckPlayerYouTubeOverlayNavigationBack @@ -686,8 +693,22 @@ enum GeneralPixel: PixelKitEventV2 { return "duckplayer_mac_contingency_settings-displayed" case .duckPlayerContingencyLearnMoreClicked: return "duckplayer_mac_contingency_learn-more-clicked" - case .duckPlayerYouTubeErrorImpression: - return "duckplayer_mac_youtube-error_impression" + case .duckPlayerYouTubeSignInErrorImpression: + return "duckplayer_mac_youtube-signin-error_impression" + case .duckPlayerYouTubeAgeRestrictedErrorImpression: + return "duckplayer_mac_youtube-age-restricted-error_impression" + case .duckPlayerYouTubeNoEmbedErrorImpression: + return "duckplayer_mac_youtube-no-embed-error_impression" + case .duckPlayerYouTubeUnknownErrorImpression: + return "duckplayer_mac_youtube-unknown-error_impression" + case .duckPlayerYouTubeSignInErrorDaily: + return "duckplayer_mac_youtube-signin-error_daily-unique" + case .duckPlayerYouTubeAgeRestrictedErrorDaily: + return "duckplayer_mac_youtube-age-restricted-error_daily-unique" + case .duckPlayerYouTubeNoEmbedErrorDaily: + return "duckplayer_mac_youtube-no-embed-error_daily-unique" + case .duckPlayerYouTubeUnknownErrorDaily: + return "duckplayer_mac_youtube-unknown-error_daily-unique" // Duck Player Temporary Overlay Pixels case .duckPlayerYouTubeOverlayNavigationBack: @@ -1345,7 +1366,14 @@ enum GeneralPixel: PixelKitEventV2 { .duckPlayerContingencySettingsDisplayed, .duckPlayerWeeklyUniqueView, .duckPlayerContingencyLearnMoreClicked, - .duckPlayerYouTubeErrorImpression: + .duckPlayerYouTubeSignInErrorImpression, + .duckPlayerYouTubeAgeRestrictedErrorImpression, + .duckPlayerYouTubeNoEmbedErrorImpression, + .duckPlayerYouTubeUnknownErrorImpression, + .duckPlayerYouTubeSignInErrorDaily, + .duckPlayerYouTubeAgeRestrictedErrorDaily, + .duckPlayerYouTubeNoEmbedErrorDaily, + .duckPlayerYouTubeUnknownErrorDaily: return nil case .bookmarksSortButtonClicked(let origin), diff --git a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift index 128bac0790..3459f386f5 100644 --- a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift +++ b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift @@ -169,7 +169,7 @@ final class DuckPlayer { return false } } - + @Published var mode: DuckPlayerMode var overlayInteracted: Bool { @@ -192,7 +192,7 @@ final class DuckPlayer { isCustomErrorFeatureEnabled = privacyConfigurationManager.privacyConfig.isSubfeatureEnabled(DuckPlayerSubfeature.customError) - // Question for Daniel: is the string return type for Subfeature settings just a stub or intentional? + // TODO: Check if this logic can be moved into privacyConfig if let customErrorSettingsJSON = privacyConfigurationManager.privacyConfig.settings(for: DuckPlayerSubfeature.customError), let jsonData = customErrorSettingsJSON.data(using: .utf8), let customErrorSettings: CustomErrorSettings = DecodableHelper.decode(jsonData: jsonData) { @@ -269,16 +269,9 @@ final class DuckPlayer { } public func handleYoutubeError(params: Any, message: UserScriptMessage) -> Encodable? { - var pixelParams: [String: String] = [:] - if let paramsDict = params as? [String: Any], - let errorParam = paramsDict["error"] as? String { - pixelParams["error"] = errorParam - } else { - pixelParams["error"] = "unknown" - } - - // TODO: Fire once daily impression - PixelKit.fire(GeneralPixel.duckPlayerYouTubeErrorImpression, withAdditionalParameters: pixelParams) + let (volumePixel, dailyPixel) = getPixelsForYouTubeErrorParams(params) + PixelKit.fire(NonStandardEvent(dailyPixel), frequency: .daily) + PixelKit.fire(NonStandardEvent(volumePixel)) return nil } @@ -329,11 +322,7 @@ final class DuckPlayer { let environment = InitialPlayerSettings.Environment.development let locale = InitialPlayerSettings.Locale.en let focusMode = InitialPlayerSettings.FocusMode(state: onboardingDecider.shouldOpenFirstVideoOnDuckPlayer ? .disabled : .enabled) - - // TODO: Remove temporary override to skip deploying a new config - // let customError = InitialPlayerSettings.CustomError(state: isCustomErrorFeatureEnabled ? .enabled : .disabled, signInRequiredSelector: customErrorSignInRequiredSelector ?? "") - let customError = InitialPlayerSettings.CustomError(state: .enabled, signInRequiredSelector: "[href*=\"//support.google.com/youtube/answer/3037019\"]") - + let customError = InitialPlayerSettings.CustomError(state: isCustomErrorFeatureEnabled ? .enabled : .disabled, signInRequiredSelector: customErrorSignInRequiredSelector ?? "") let playerSettings = InitialPlayerSettings.PlayerSettings(pip: pip, autoplay: autoplay, focusMode: focusMode, customError: customError) let userValues = encodeUserValues() @@ -395,6 +384,23 @@ final class DuckPlayer { modeCancellable = nil } } + + private func getPixelsForYouTubeErrorParams(_ params: Any) -> (GeneralPixel, GeneralPixel) { + if let paramsDict = params as? [String: Any], + let errorParam = paramsDict["error"] as? String{ + switch errorParam { + case "sign-in-required": + return (GeneralPixel.duckPlayerYouTubeSignInErrorImpression, GeneralPixel.duckPlayerYouTubeSignInErrorDaily) + case "age-restricted": + return (GeneralPixel.duckPlayerYouTubeAgeRestrictedErrorImpression, GeneralPixel.duckPlayerYouTubeAgeRestrictedErrorDaily) + case "no-embed": + return (GeneralPixel.duckPlayerYouTubeNoEmbedErrorImpression, GeneralPixel.duckPlayerYouTubeNoEmbedErrorDaily) + default: + return (GeneralPixel.duckPlayerYouTubeUnknownErrorImpression, GeneralPixel.duckPlayerYouTubeUnknownErrorDaily) + } + } + return (GeneralPixel.duckPlayerYouTubeUnknownErrorImpression, GeneralPixel.duckPlayerYouTubeUnknownErrorDaily) + } } // MARK: - Privacy Feed From d8c4ff25e223cd0153964a104986624c8f868c0e Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 14 Feb 2025 11:01:40 +0000 Subject: [PATCH 6/9] Package bumps --- .../xcshareddata/swiftpm/Package.resolved | 221 ++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000000..776354c467 --- /dev/null +++ b/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,221 @@ +{ + "pins" : [ + { + "identity" : "apple-toolbox", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/apple-toolbox.git", + "state" : { + "revision" : "0c13c5f056805f2d403618ccc3bfb833c303c68d", + "version" : "3.1.2" + } + }, + { + "identity" : "barebonesbrowser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/BareBonesBrowser.git", + "state" : { + "revision" : "31e5bfedc3c2ca005640c4bf2b6959d69b0e18b9", + "version" : "0.1.0" + } + }, + { + "identity" : "bloom_cpp", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/bloom_cpp.git", + "state" : { + "revision" : "8076199456290b61b4544bf2f4caf296759906a0", + "version" : "3.0.0" + } + }, + { + "identity" : "browserserviceskit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/BrowserServicesKit", + "state" : { + "branch" : "mgurgel/duckplayer-custom-error", + "revision" : "130692f3d84c9defa811b205603f9a7c5c3654d9" + } + }, + { + "identity" : "content-scope-scripts", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/content-scope-scripts", + "state" : { + "branch" : "pr-releases/pr-1421", + "revision" : "371b1a444ac9ebcf553f708f9c759f1f5777fcdc" + } + }, + { + "identity" : "duckduckgo-autofill", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/duckduckgo-autofill.git", + "state" : { + "revision" : "3a9606fd26e9a54bf369cc241e6fa3b2571eb13a", + "version" : "16.2.1" + } + }, + { + "identity" : "grdb.swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/GRDB.swift.git", + "state" : { + "revision" : "5b2f6a81099d26ae0f9e38788f51490cd6a4b202", + "version" : "2.4.2" + } + }, + { + "identity" : "gzipswift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/1024jp/GzipSwift.git", + "state" : { + "revision" : "731037f6cc2be2ec01562f6597c1d0aa3fe6fd05", + "version" : "6.0.1" + } + }, + { + "identity" : "jwt-kit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/vapor/jwt-kit.git", + "state" : { + "revision" : "c2595b9ad7f512d7f334830b4df1fed6e917946a", + "version" : "4.13.4" + } + }, + { + "identity" : "lottie-spm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/airbnb/lottie-spm.git", + "state" : { + "revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605", + "version" : "4.4.3" + } + }, + { + "identity" : "ohhttpstubs", + "kind" : "remoteSourceControl", + "location" : "https://github.com/AliSoftware/OHHTTPStubs.git", + "state" : { + "revision" : "12f19662426d0434d6c330c6974d53e2eb10ecd9", + "version" : "9.1.0" + } + }, + { + "identity" : "openssl-xcframework", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/OpenSSL-XCFramework", + "state" : { + "revision" : "71d303cbfa150e1fac99ffc7b4f67aad9c7a5002", + "version" : "3.1.5004" + } + }, + { + "identity" : "privacy-dashboard", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/privacy-dashboard", + "state" : { + "revision" : "c05d7ce7debe45593bfd9759d6bcae0cd740c52f", + "version" : "8.4.0" + } + }, + { + "identity" : "punycodeswift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/gumob/PunycodeSwift.git", + "state" : { + "revision" : "30a462bdb4398ea835a3585472229e0d74b36ba5", + "version" : "3.0.0" + } + }, + { + "identity" : "sparkle", + "kind" : "remoteSourceControl", + "location" : "https://github.com/sparkle-project/Sparkle.git", + "state" : { + "revision" : "b456fd404954a9e13f55aa0c88cd5a40b8399638", + "version" : "2.6.3" + } + }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser.git", + "state" : { + "revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b", + "version" : "1.4.0" + } + }, + { + "identity" : "swift-asn1", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-asn1.git", + "state" : { + "revision" : "ae33e5941bb88d88538d0a6b19ca0b01e6c76dcf", + "version" : "1.3.1" + } + }, + { + "identity" : "swift-crypto", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-crypto.git", + "state" : { + "revision" : "f2f3774fd116a305136b6866e5e7cb7dff39d8f2", + "version" : "3.10.1" + } + }, + { + "identity" : "swift-snapshot-testing", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-snapshot-testing", + "state" : { + "revision" : "5b0c434778f2c1a4c9b5ebdb8682b28e84dd69bd", + "version" : "1.15.4" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-syntax", + "state" : { + "revision" : "64889f0c732f210a935a0ad7cda38f77f876262d", + "version" : "509.1.1" + } + }, + { + "identity" : "swifter", + "kind" : "remoteSourceControl", + "location" : "https://github.com/httpswift/swifter.git", + "state" : { + "revision" : "9483a5d459b45c3ffd059f7b55f9638e268632fd", + "version" : "1.5.0" + } + }, + { + "identity" : "sync_crypto", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/sync_crypto", + "state" : { + "revision" : "cc726cebb67367466bc31ced4784e16d44ac68d1", + "version" : "0.4.0" + } + }, + { + "identity" : "trackerradarkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/TrackerRadarKit.git", + "state" : { + "revision" : "5de0a610a7927b638a5fd463a53032c9934a2c3b", + "version" : "3.0.0" + } + }, + { + "identity" : "wireguard-apple", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/wireguard-apple", + "state" : { + "revision" : "13fd026384b1af11048451061cc1b21434990668", + "version" : "1.1.3" + } + } + ], + "version" : 2 +} From 125fce51d2d234e40a695cd4c0dc67d7defb458a Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 14 Feb 2025 11:04:54 +0000 Subject: [PATCH 7/9] Lint --- DuckDuckGo/YoutubePlayer/DuckPlayer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift index 3459f386f5..7c90102ee9 100644 --- a/DuckDuckGo/YoutubePlayer/DuckPlayer.swift +++ b/DuckDuckGo/YoutubePlayer/DuckPlayer.swift @@ -169,7 +169,7 @@ final class DuckPlayer { return false } } - + @Published var mode: DuckPlayerMode var overlayInteracted: Bool { From ac1ea63f91e8844ddb109b840552dbcdacb38080 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 14 Feb 2025 11:07:11 +0000 Subject: [PATCH 8/9] Dependency cleanup --- .../xcshareddata/swiftpm/Package.resolved | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 776354c467..5d3bc15424 100644 --- a/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -46,13 +46,13 @@ } }, { - "identity" : "duckduckgo-autofill", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/duckduckgo-autofill.git", - "state" : { - "revision" : "3a9606fd26e9a54bf369cc241e6fa3b2571eb13a", - "version" : "16.2.1" - } + "identity" : "duckduckgo-autofill", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/duckduckgo-autofill.git", + "state" : { + "revision" : "676d42679296a175169e433f2332e55644151edd", + "version" : "16.2.0" + } }, { "identity" : "grdb.swift", @@ -113,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { - "revision" : "c05d7ce7debe45593bfd9759d6bcae0cd740c52f", - "version" : "8.4.0" + "revision" : "099f7ed5faac946e4d80746703aaaf87fdfbee09", + "version" : "8.3.0" } }, { From f363bffe59e297f2492c654d5dd59590cf1eed6f Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 14 Feb 2025 11:09:11 +0000 Subject: [PATCH 9/9] Dependency cleanup --- .../xcshareddata/swiftpm/Package.resolved | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5d3bc15424..45e7442c56 100644 --- a/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo-macOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -46,13 +46,13 @@ } }, { - "identity" : "duckduckgo-autofill", - "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/duckduckgo-autofill.git", - "state" : { - "revision" : "676d42679296a175169e433f2332e55644151edd", - "version" : "16.2.0" - } + "identity" : "duckduckgo-autofill", + "kind" : "remoteSourceControl", + "location" : "https://github.com/duckduckgo/duckduckgo-autofill.git", + "state" : { + "revision" : "676d42679296a175169e433f2332e55644151edd", + "version" : "16.2.0" + } }, { "identity" : "grdb.swift", @@ -113,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/privacy-dashboard", "state" : { - "revision" : "099f7ed5faac946e4d80746703aaaf87fdfbee09", - "version" : "8.3.0" + "revision" : "099f7ed5faac946e4d80746703aaaf87fdfbee09", + "version" : "8.3.0" } }, {