diff --git a/DuckDuckGo/DataImport/Bookmarks/Safari/SafariDataImporter.swift b/DuckDuckGo/DataImport/Bookmarks/Safari/SafariDataImporter.swift index 0f3daaef5d..ddf719b5f1 100644 --- a/DuckDuckGo/DataImport/Bookmarks/Safari/SafariDataImporter.swift +++ b/DuckDuckGo/DataImport/Bookmarks/Safari/SafariDataImporter.swift @@ -96,6 +96,7 @@ final class SafariDataImporter: DataImporter { private func importFavicons(from dataDirectoryURL: URL) async { let faviconsReader = SafariFaviconsReader(safariDataDirectoryURL: dataDirectoryURL) let faviconsResult = faviconsReader.readFavicons() + let sourceVersion = profile.installedAppsMajorVersionDescription() switch faviconsResult { case .success(let faviconsByURL): @@ -112,9 +113,10 @@ final class SafariDataImporter: DataImporter { result[pageURL] = favicons } await faviconManager.handleFaviconsByDocumentUrl(faviconsByDocument) + PixelKit.fire(GeneralPixel.dataImportSucceeded(action: .favicons, source: source, sourceVersion: sourceVersion)) case .failure(let error): - PixelKit.fire(GeneralPixel.dataImportFailed(source: source, sourceVersion: profile.installedAppsMajorVersionDescription(), error: error)) + PixelKit.fire(GeneralPixel.dataImportFailed(source: source, sourceVersion: sourceVersion, error: error)) } } diff --git a/DuckDuckGo/DataImport/Logins/Chromium/ChromiumDataImporter.swift b/DuckDuckGo/DataImport/Logins/Chromium/ChromiumDataImporter.swift index 1f920dd809..8db3ac1878 100644 --- a/DuckDuckGo/DataImport/Logins/Chromium/ChromiumDataImporter.swift +++ b/DuckDuckGo/DataImport/Logins/Chromium/ChromiumDataImporter.swift @@ -122,6 +122,7 @@ internal class ChromiumDataImporter: DataImporter { private func importFavicons() async { let faviconsReader = ChromiumFaviconsReader(chromiumDataDirectoryURL: profile.profileURL) let faviconsResult = faviconsReader.readFavicons() + let sourceVersion = profile.installedAppsMajorVersionDescription() switch faviconsResult { case .success(let faviconsByURL): @@ -138,9 +139,9 @@ internal class ChromiumDataImporter: DataImporter { result[pageURL] = favicons } await faviconManager.handleFaviconsByDocumentUrl(faviconsByDocument) - + PixelKit.fire(GeneralPixel.dataImportSucceeded(action: .favicons, source: source, sourceVersion: sourceVersion)) case .failure(let error): - PixelKit.fire(GeneralPixel.dataImportFailed(source: source, sourceVersion: profile.installedAppsMajorVersionDescription(), error: error)) + PixelKit.fire(GeneralPixel.dataImportFailed(source: source, sourceVersion: sourceVersion, error: error)) } } diff --git a/DuckDuckGo/DataImport/Logins/Firefox/FirefoxDataImporter.swift b/DuckDuckGo/DataImport/Logins/Firefox/FirefoxDataImporter.swift index 5eb7ca6353..ed42e8740e 100644 --- a/DuckDuckGo/DataImport/Logins/Firefox/FirefoxDataImporter.swift +++ b/DuckDuckGo/DataImport/Logins/Firefox/FirefoxDataImporter.swift @@ -122,6 +122,7 @@ internal class FirefoxDataImporter: DataImporter { private func importFavicons() async { let faviconsReader = FirefoxFaviconsReader(firefoxDataDirectoryURL: profile.profileURL) let faviconsResult = faviconsReader.readFavicons() + let sourceVersion = profile.installedAppsMajorVersionDescription() switch faviconsResult { case .success(let faviconsByURL): @@ -138,9 +139,10 @@ internal class FirefoxDataImporter: DataImporter { result[pageURL] = favicons } await faviconManager.handleFaviconsByDocumentUrl(faviconsByDocument) + PixelKit.fire(GeneralPixel.dataImportSucceeded(action: .favicons, source: source, sourceVersion: sourceVersion)) case .failure(let error): - PixelKit.fire(GeneralPixel.dataImportFailed(source: source, sourceVersion: profile.installedAppsMajorVersionDescription(), error: error)) + PixelKit.fire(GeneralPixel.dataImportFailed(source: source, sourceVersion: sourceVersion, error: error)) } } diff --git a/DuckDuckGo/DataImport/Model/DataImportViewModel.swift b/DuckDuckGo/DataImport/Model/DataImportViewModel.swift index 3660f02777..254295f6d5 100644 --- a/DuckDuckGo/DataImport/Model/DataImportViewModel.swift +++ b/DuckDuckGo/DataImport/Model/DataImportViewModel.swift @@ -245,12 +245,14 @@ struct DataImportViewModel { var nextScreen: Screen? // merge new import results into the model import summary keeping the original DataType sorting order for (dataType, result) in DataType.allCases.compactMap({ dataType in summary[dataType].map { (dataType, $0) } }) { + let sourceVersion = importSource.installedAppsMajorVersionDescription(selectedProfile: selectedProfile) switch result { case .success(let dataTypeSummary): // if a data type can‘t be imported (Yandex/Passwords) - switch to its file import displaying successful import results if dataTypeSummary.isEmpty, !(screen.isFileImport && screen.fileImportDataType == dataType), nextScreen == nil { nextScreen = .fileImport(dataType: dataType, summary: Set(summary.filter({ $0.value.isSuccess }).keys)) } + PixelKit.fire(GeneralPixel.dataImportSucceeded(action: .init(dataType), source: importSource, sourceVersion: sourceVersion)) case .failure(let error): // successful imports are appended above self.summary.append( .init(dataType, result) ) @@ -260,7 +262,7 @@ struct DataImportViewModel { // switch to file import of the failed data type displaying successful import results nextScreen = .fileImport(dataType: dataType, summary: Set(summary.filter({ $0.value.isSuccess }).keys)) } - PixelKit.fire(GeneralPixel.dataImportFailed(source: importSource, sourceVersion: importSource.installedAppsMajorVersionDescription(selectedProfile: selectedProfile), error: error)) + PixelKit.fire(GeneralPixel.dataImportFailed(source: importSource, sourceVersion: sourceVersion, error: error)) } } diff --git a/DuckDuckGo/Statistics/GeneralPixel.swift b/DuckDuckGo/Statistics/GeneralPixel.swift index d7861dd042..2f5a897199 100644 --- a/DuckDuckGo/Statistics/GeneralPixel.swift +++ b/DuckDuckGo/Statistics/GeneralPixel.swift @@ -37,6 +37,7 @@ enum GeneralPixel: PixelKitEventV2 { case dailyOsVersionCounter case dataImportFailed(source: DataImport.Source, sourceVersion: String?, error: any DataImportError) + case dataImportSucceeded(action: DataImportAction, source: DataImport.Source, sourceVersion: String?) case formAutofilled(kind: FormAutofillKind) case autofillItemSaved(kind: FormAutofillKind) @@ -474,6 +475,9 @@ enum GeneralPixel: PixelKitEventV2 { case .dataImportFailed(source: let source, sourceVersion: _, error: let error): return "m_mac_data-import-failed_\(error.action)_\(source)" + case .dataImportSucceeded(action: let action, source: let source, sourceVersion: _): + return "m_mac_data-import-succeeded_\(action)_\(source)" + case .formAutofilled(kind: let kind): return "m_mac_autofill_\(kind)" @@ -1134,6 +1138,14 @@ enum GeneralPixel: PixelKitEventV2 { } return params + case .dataImportSucceeded(action: _, source: _, sourceVersion: let version): + var params = [String: String]() + + if let version { + params[PixelKit.Parameters.sourceBrowserVersion] = version + } + return params + case .launchInitial(let cohort): return [PixelKit.Parameters.experimentCohort: cohort]