Skip to content

Commit

Permalink
Autofill engagement KPIs for pixel reporting (BSK update) (#2885)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/72649045549333/1207357107981852/f
Tech Design URL:
CC:

Description:
Update to use BSK for Autofill engagement KPIs for pixel reporting
  • Loading branch information
amddg44 authored May 23, 2024
1 parent f0ad26e commit 919b602
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 402 deletions.
4 changes: 0 additions & 4 deletions Core/StatisticsLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,3 @@ public class StatisticsLoader {
}
}
}

extension NSNotification.Name {
public static let searchDAU: NSNotification.Name = Notification.Name(rawValue: "com.duckduckgo.notification.searchDAU")
}
10 changes: 1 addition & 9 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,6 @@
C12726EE2A5FF88C00215B02 /* EmailSignupPromptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12726ED2A5FF88C00215B02 /* EmailSignupPromptView.swift */; };
C12726F02A5FF89900215B02 /* EmailSignupPromptViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12726EF2A5FF89900215B02 /* EmailSignupPromptViewModel.swift */; };
C12726F22A5FF8CB00215B02 /* EmailSignupPromptViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12726F12A5FF8CB00215B02 /* EmailSignupPromptViewController.swift */; };
C12B6E7A2BED639500050D93 /* AutofillPixelReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12B6E792BED639500050D93 /* AutofillPixelReporter.swift */; };
C12B6E7C2BED69C100050D93 /* AutofillPixelReporterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12B6E7B2BED69C100050D93 /* AutofillPixelReporterTests.swift */; };
C136C7542BEB8CFC00ACC3B0 /* PasswordsSurveyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C136C7532BEB8CFC00ACC3B0 /* PasswordsSurveyView.swift */; };
C13B32D22A0E750700A59236 /* AutofillSettingStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = C13B32D12A0E750700A59236 /* AutofillSettingStatus.swift */; };
C13F3F682B7F88100083BE40 /* AuthConfirmationPromptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C13F3F672B7F88100083BE40 /* AuthConfirmationPromptView.swift */; };
Expand Down Expand Up @@ -2291,8 +2289,6 @@
C12726ED2A5FF88C00215B02 /* EmailSignupPromptView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailSignupPromptView.swift; sourceTree = "<group>"; };
C12726EF2A5FF89900215B02 /* EmailSignupPromptViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailSignupPromptViewModel.swift; sourceTree = "<group>"; };
C12726F12A5FF8CB00215B02 /* EmailSignupPromptViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailSignupPromptViewController.swift; sourceTree = "<group>"; };
C12B6E792BED639500050D93 /* AutofillPixelReporter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutofillPixelReporter.swift; sourceTree = "<group>"; };
C12B6E7B2BED69C100050D93 /* AutofillPixelReporterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutofillPixelReporterTests.swift; sourceTree = "<group>"; };
C136C7532BEB8CFC00ACC3B0 /* PasswordsSurveyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordsSurveyView.swift; sourceTree = "<group>"; };
C13B32D12A0E750700A59236 /* AutofillSettingStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutofillSettingStatus.swift; sourceTree = "<group>"; };
C13F3F672B7F88100083BE40 /* AuthConfirmationPromptView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthConfirmationPromptView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5425,7 +5421,6 @@
F40F843528C938370081AE75 /* AutofillLoginListViewModelTests.swift */,
C1D21E2E293A599C006E5A05 /* AutofillLoginSessionTests.swift */,
C1CDA31D2AFBF811006D1476 /* AutofillNeverPromptWebsitesManagerTests.swift */,
C12B6E7B2BED69C100050D93 /* AutofillPixelReporterTests.swift */,
);
name = Autofill;
sourceTree = "<group>";
Expand All @@ -5437,7 +5432,6 @@
F4147353283BF834004AA7A5 /* AutofillContentScopeFeatureToggles.swift */,
C1D21E2C293A5965006E5A05 /* AutofillLoginSession.swift */,
C1CDA3152AFB9C7F006D1476 /* AutofillNeverPromptWebsitesManager.swift */,
C12B6E792BED639500050D93 /* AutofillPixelReporter.swift */,
C13B32D12A0E750700A59236 /* AutofillSettingStatus.swift */,
319A370F28299A850079FBCE /* PasswordHider.swift */,
C136C7532BEB8CFC00ACC3B0 /* PasswordsSurveyView.swift */,
Expand Down Expand Up @@ -6400,7 +6394,6 @@
BDFF03222BA3D8E200F324C9 /* NetworkProtectionFeatureVisibility.swift in Sources */,
B652DEFD287BE67400C12A9C /* UserScripts.swift in Sources */,
1D200C992BA3176D00108701 /* SettingsOthersView.swift in Sources */,
C12B6E7A2BED639500050D93 /* AutofillPixelReporter.swift in Sources */,
31DD208427395A5A008FB313 /* VoiceSearchHelper.swift in Sources */,
9874F9EE2187AFCE00CAF33D /* Themable.swift in Sources */,
F44D279E27F331BB0037F371 /* AutofillLoginPromptViewModel.swift in Sources */,
Expand Down Expand Up @@ -6915,7 +6908,6 @@
9F2510142BF5809E0096DB16 /* SubscriptionFlowViewModelTests.swift in Sources */,
F189AED71F18F6DE001EBAE1 /* TabTests.swift in Sources */,
F13B4BFB1F18E3D900814661 /* TabsModelPersistenceExtensionTests.swift in Sources */,
C12B6E7C2BED69C100050D93 /* AutofillPixelReporterTests.swift in Sources */,
CB48D3372B90DF2000631D8B /* UserBehaviorMonitorTests.swift in Sources */,
8528AE7E212EF5FF00D0BD74 /* AppRatingPromptTests.swift in Sources */,
981FED692201FE69008488D7 /* AutoClearSettingsScreenTests.swift in Sources */,
Expand Down Expand Up @@ -9838,7 +9830,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 146.1.0;
version = 146.2.0;
};
};
9F8FE9472BAE50E50071E372 /* 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" : "65f3ccadd0118bcef112e3f5fff03e491b3261cd",
"version" : "146.1.0"
"revision" : "e1e436422bc167933baa0f90838958f2ac7119f3",
"version" : "146.2.0"
}
},
{
Expand Down
26 changes: 23 additions & 3 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import WebKit
private let crashCollection = CrashCollection(platform: .iOS, log: .generalLog)
private var crashReportUploaderOnboarding: CrashCollectionOnboarding?

private let autofillPixelReporter = AutofillPixelReporter()
private var autofillPixelReporter: AutofillPixelReporter?

// MARK: lifecycle

Expand Down Expand Up @@ -340,6 +340,8 @@ import WebKit

AppDependencyProvider.shared.userBehaviorMonitor.handleAction(.reopenApp)

setUpAutofillPixelReporter()

return true
}

Expand Down Expand Up @@ -681,8 +683,6 @@ import WebKit
}

AppDependencyProvider.shared.userBehaviorMonitor.handleAction(.reopenApp)

autofillPixelReporter.checkIfOnboardedUser()
}

func applicationDidEnterBackground(_ application: UIApplication) {
Expand Down Expand Up @@ -911,6 +911,26 @@ import WebKit
return window?.rootViewController as? MainViewController
}

private func setUpAutofillPixelReporter() {
autofillPixelReporter = AutofillPixelReporter(
userDefaults: .standard,
eventMapping: EventMapping<AutofillPixelEvent> {event, _, params, _ in
switch event {
case .autofillActiveUser:
Pixel.fire(pixel: .autofillActiveUser)
case .autofillEnabledUser:
Pixel.fire(pixel: .autofillEnabledUser)
case .autofillOnboardedUser:
Pixel.fire(pixel: .autofillOnboardedUser)
case .autofillLoginsStacked:
Pixel.fire(pixel: .autofillLoginsStacked, withAdditionalParameters: params ?? [:])
default:
break
}
},
installDate: StatisticsUserDefaults().installDate ?? Date())
}

@MainActor
func refreshShortcuts() async {
#if NETWORK_PROTECTION
Expand Down
12 changes: 11 additions & 1 deletion DuckDuckGo/AutofillDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
import UIKit
import BrowserServicesKit
import Core
import Common

class AutofillDebugViewController: UITableViewController {

enum Row: Int {
case toggleAutofillDebugScript = 201
case resetEmailProtectionInContextSignUp = 202
case resetDaysSinceInstalledTo0 = 203
case toggleAutofillSurvey = 204
case resetAutofillData = 204
case toggleAutofillSurvey = 205
}

let defaults = AppUserDefaults()
Expand All @@ -46,6 +48,14 @@ class AutofillDebugViewController: UITableViewController {
defaults.autofillDebugScriptEnabled.toggle()
cell.accessoryType = defaults.autofillDebugScriptEnabled ? .checkmark : .none
NotificationCenter.default.post(Notification(name: AppUserDefaults.Notifications.autofillDebugScriptToggled))
} else if cell.tag == Row.resetAutofillData.rawValue {
let secureVault = try? AutofillSecureVaultFactory.makeVault(reporter: SecureVaultReporter.shared)
try? secureVault?.deleteAllWebsiteCredentials()
let autofillPixelReporter = AutofillPixelReporter(
userDefaults: .standard,
eventMapping: EventMapping<AutofillPixelEvent> { _, _, _, _ in })
autofillPixelReporter.resetStoreDefaults()
ActionMessageView.present(message: "Autofill Data reset")
} else if cell.tag == Row.toggleAutofillSurvey.rawValue {
defaults.autofillSurveyEnabled = true
ActionMessageView.present(message: "Passwords Survey enabled")
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/AutofillLoginDetailsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ final class AutofillLoginDetailsViewModel: ObservableObject {
self.updateData(with: newCredential.account)
}

NotificationCenter.default.post(name: .autofillSaveEvent, object: nil)
} catch let error {
handleSecureVaultError(error)
}
Expand Down
178 changes: 0 additions & 178 deletions DuckDuckGo/AutofillPixelReporter.swift

This file was deleted.

Loading

0 comments on commit 919b602

Please sign in to comment.