From 5e0175a4cdec71e99828b5441e555c2030605d7c Mon Sep 17 00:00:00 2001 From: amddg44 Date: Wed, 19 Jun 2024 21:05:07 +0200 Subject: [PATCH] Additional Autofill KPI pixels (#2856) Task/Issue URL: https://app.asana.com/0/0/1207512213117508/f Tech Design URL: Additional Task URL: https://app.asana.com/0/0/1207512213117504/f Description: Updates enabled user pixel firing rules and adds new autofill toggle pixel for search DAUs. --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 +- DuckDuckGo/Application/AppDelegate.swift | 45 ++++++++++++------- DuckDuckGo/Menus/MainMenuActions.swift | 5 ++- DuckDuckGo/Statistics/GeneralPixel.swift | 6 +++ .../DataBrokerProtection/Package.swift | 2 +- .../NetworkProtectionMac/Package.swift | 2 +- LocalPackages/SubscriptionUI/Package.swift | 2 +- 8 files changed, 44 insertions(+), 24 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 757f77878d..d30b520011 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -13022,7 +13022,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 158.0.0; + version = 158.1.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 ea20b287f5..47b318aeb9 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" : "61df946265d05c401b472d76f837a13552722367", - "version" : "158.0.0" + "revision" : "201a932642275eeccc213940a1e85c6c19a6f3d0", + "version" : "158.1.0" } }, { diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index 6d6109ae9a..5d5d2fbe6c 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -650,23 +650,34 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private func setUpAutofillPixelReporter() { autofillPixelReporter = AutofillPixelReporter( - userDefaults: .standard, - eventMapping: EventMapping {event, _, params, _ in - switch event { - case .autofillActiveUser: - PixelKit.fire(GeneralPixel.autofillActiveUser) - case .autofillEnabledUser: - PixelKit.fire(GeneralPixel.autofillEnabledUser) - case .autofillOnboardedUser: - PixelKit.fire(GeneralPixel.autofillOnboardedUser) - case .autofillLoginsStacked: - PixelKit.fire(GeneralPixel.autofillLoginsStacked, withAdditionalParameters: params) - case .autofillCreditCardsStacked: - PixelKit.fire(GeneralPixel.autofillCreditCardsStacked, withAdditionalParameters: params) - } - }, - passwordManager: PasswordManagerCoordinator.shared, - installDate: AppDelegate.firstLaunchDate) + userDefaults: .standard, + autofillEnabled: AutofillPreferences().askToSaveUsernamesAndPasswords, + eventMapping: EventMapping {event, _, params, _ in + switch event { + case .autofillActiveUser: + PixelKit.fire(GeneralPixel.autofillActiveUser) + case .autofillEnabledUser: + PixelKit.fire(GeneralPixel.autofillEnabledUser) + case .autofillOnboardedUser: + PixelKit.fire(GeneralPixel.autofillOnboardedUser) + case .autofillToggledOn: + PixelKit.fire(GeneralPixel.autofillToggledOn, withAdditionalParameters: params) + case .autofillToggledOff: + PixelKit.fire(GeneralPixel.autofillToggledOff, withAdditionalParameters: params) + case .autofillLoginsStacked: + PixelKit.fire(GeneralPixel.autofillLoginsStacked, withAdditionalParameters: params) + case .autofillCreditCardsStacked: + PixelKit.fire(GeneralPixel.autofillCreditCardsStacked, withAdditionalParameters: params) + } + }, + passwordManager: PasswordManagerCoordinator.shared, + installDate: AppDelegate.firstLaunchDate) + + _ = NotificationCenter.default.addObserver(forName: .autofillUserSettingsDidChange, + object: nil, + queue: nil) { [weak self] _ in + self?.autofillPixelReporter?.updateAutofillEnabledStatus(AutofillPreferences().askToSaveUsernamesAndPasswords) + } } } diff --git a/DuckDuckGo/Menus/MainMenuActions.swift b/DuckDuckGo/Menus/MainMenuActions.swift index 25fcc148fc..abe2239361 100644 --- a/DuckDuckGo/Menus/MainMenuActions.swift +++ b/DuckDuckGo/Menus/MainMenuActions.swift @@ -744,7 +744,10 @@ extension MainViewController { } UserDefaults.standard.set(false, forKey: UserDefaultsWrapper.Key.homePageContinueSetUpImport.rawValue) - let autofillPixelReporter = AutofillPixelReporter(userDefaults: .standard, eventMapping: EventMapping { _, _, _, _ in }, installDate: nil) + let autofillPixelReporter = AutofillPixelReporter(userDefaults: .standard, + autofillEnabled: AutofillPreferences().askToSaveUsernamesAndPasswords, + eventMapping: EventMapping { _, _, _, _ in }, + installDate: nil) autofillPixelReporter.resetStoreDefaults() } diff --git a/DuckDuckGo/Statistics/GeneralPixel.swift b/DuckDuckGo/Statistics/GeneralPixel.swift index 7130685a7a..67900b1c9a 100644 --- a/DuckDuckGo/Statistics/GeneralPixel.swift +++ b/DuckDuckGo/Statistics/GeneralPixel.swift @@ -64,6 +64,8 @@ enum GeneralPixel: PixelKitEventV2 { case autofillActiveUser case autofillEnabledUser case autofillOnboardedUser + case autofillToggledOn + case autofillToggledOff case autofillLoginsStacked case autofillCreditCardsStacked @@ -423,6 +425,10 @@ enum GeneralPixel: PixelKitEventV2 { return "m_mac_autofill_enableduser" case .autofillOnboardedUser: return "m_mac_autofill_onboardeduser" + case .autofillToggledOn: + return "m_mac_autofill_toggled_on" + case .autofillToggledOff: + return "m_mac_autofill_toggled_off" case .autofillLoginsStacked: return "m_mac_autofill_logins_stacked" case .autofillCreditCardsStacked: diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index 4f943e2af5..66fd360dca 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: "158.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "158.1.0"), .package(path: "../SwiftUIExtensions"), .package(path: "../XPCHelper"), ], diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index 4316b5e980..a6fea8ea0e 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: "158.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "158.1.0"), .package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.1"), .package(path: "../AppLauncher"), .package(path: "../UDSHelper"), diff --git a/LocalPackages/SubscriptionUI/Package.swift b/LocalPackages/SubscriptionUI/Package.swift index 15501c7cfe..c36ef82219 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: "158.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "158.1.0"), .package(path: "../SwiftUIExtensions") ], targets: [