Skip to content

Commit

Permalink
Additional Autofill KPI pixels (#2856)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amddg44 authored Jun 19, 2024
1 parent 5a2db46 commit 5e0175a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 24 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
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" : "61df946265d05c401b472d76f837a13552722367",
"version" : "158.0.0"
"revision" : "201a932642275eeccc213940a1e85c6c19a6f3d0",
"version" : "158.1.0"
}
},
{
Expand Down
45 changes: 28 additions & 17 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -650,23 +650,34 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

private func setUpAutofillPixelReporter() {
autofillPixelReporter = AutofillPixelReporter(
userDefaults: .standard,
eventMapping: EventMapping<AutofillPixelEvent> {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<AutofillPixelEvent> {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)
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,10 @@ extension MainViewController {
}
UserDefaults.standard.set(false, forKey: UserDefaultsWrapper<Bool>.Key.homePageContinueSetUpImport.rawValue)

let autofillPixelReporter = AutofillPixelReporter(userDefaults: .standard, eventMapping: EventMapping<AutofillPixelEvent> { _, _, _, _ in }, installDate: nil)
let autofillPixelReporter = AutofillPixelReporter(userDefaults: .standard,
autofillEnabled: AutofillPreferences().askToSaveUsernamesAndPasswords,
eventMapping: EventMapping<AutofillPixelEvent> { _, _, _, _ in },
installDate: nil)
autofillPixelReporter.resetStoreDefaults()
}

Expand Down
6 changes: 6 additions & 0 deletions DuckDuckGo/Statistics/GeneralPixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ enum GeneralPixel: PixelKitEventV2 {
case autofillActiveUser
case autofillEnabledUser
case autofillOnboardedUser
case autofillToggledOn
case autofillToggledOff
case autofillLoginsStacked
case autofillCreditCardsStacked

Expand Down Expand Up @@ -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:
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: "158.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "158.1.0"),
.package(path: "../SwiftUIExtensions"),
.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: "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"),
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: "158.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "158.1.0"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down

0 comments on commit 5e0175a

Please sign in to comment.