Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update login item failure pixel #2024

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,9 @@
4BA1A6E6258C270800F6F690 /* EncryptionKeyGeneratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BA1A6E5258C270800F6F690 /* EncryptionKeyGeneratorTests.swift */; };
4BA1A6F6258C4F9600F6F690 /* EncryptionMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BA1A6F5258C4F9600F6F690 /* EncryptionMocks.swift */; };
4BA1A6FE258C5C1300F6F690 /* EncryptedValueTransformerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BA1A6FD258C5C1300F6F690 /* EncryptedValueTransformerTests.swift */; };
4BA71EDA2B4B81E80002EBCE /* AppVersionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BA71ED92B4B81E80002EBCE /* AppVersionExtension.swift */; };
4BA71EDB2B4B81E80002EBCE /* AppVersionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BA71ED92B4B81E80002EBCE /* AppVersionExtension.swift */; };
4BA71EDC2B4B81E80002EBCE /* AppVersionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BA71ED92B4B81E80002EBCE /* AppVersionExtension.swift */; };
Comment on lines +2026 to +2028
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should hold back the PR but I'd consider adding these files to a common package under NetworkProtectionMac.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful to all parts of the codebase so I'd avoid keeping it out of a NetworkProtection directory if possible

4BB6CE5F26B77ED000EC5860 /* Cryptography.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB6CE5E26B77ED000EC5860 /* Cryptography.swift */; };
4BB88B4525B7B55C006F6B06 /* DebugUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB88B4425B7B55C006F6B06 /* DebugUserScript.swift */; };
4BB88B4A25B7B690006F6B06 /* SequenceExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB88B4925B7B690006F6B06 /* SequenceExtensions.swift */; };
Expand Down Expand Up @@ -3566,6 +3569,7 @@
4BA1A6EA258C288C00F6F690 /* EncryptionKeyStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionKeyStoreTests.swift; sourceTree = "<group>"; };
4BA1A6F5258C4F9600F6F690 /* EncryptionMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionMocks.swift; sourceTree = "<group>"; };
4BA1A6FD258C5C1300F6F690 /* EncryptedValueTransformerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptedValueTransformerTests.swift; sourceTree = "<group>"; };
4BA71ED92B4B81E80002EBCE /* AppVersionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppVersionExtension.swift; sourceTree = "<group>"; };
4BB6CE5E26B77ED000EC5860 /* Cryptography.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cryptography.swift; sourceTree = "<group>"; };
4BB88B4425B7B55C006F6B06 /* DebugUserScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugUserScript.swift; sourceTree = "<group>"; };
4BB88B4925B7B690006F6B06 /* SequenceExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequenceExtensions.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7324,6 +7328,7 @@
isa = PBXGroup;
children = (
AA7EB6E427E7D6DC00036718 /* AnimationView.swift */,
4BA71ED92B4B81E80002EBCE /* AppVersionExtension.swift */,
AA61C0D12727F59B00E6B681 /* ArrayExtension.swift */,
B6DB3CF826A00E2D00D459B7 /* AVCaptureDevice+SwizzledAuthState.swift */,
B6106B9D26A565DA0013B453 /* BundleExtension.swift */,
Expand Down Expand Up @@ -9746,6 +9751,7 @@
3706FC0B293F65D500E42796 /* CSVLoginExporter.swift in Sources */,
37197EAC294244D600394917 /* FutureExtension.swift in Sources */,
4B9DB0452A983B24000927DB /* WaitlistModalViewController.swift in Sources */,
4BA71EDB2B4B81E80002EBCE /* AppVersionExtension.swift in Sources */,
B66CA41F2AD910B300447CF0 /* DataImportView.swift in Sources */,
3706FC0C293F65D500E42796 /* NSAttributedStringExtension.swift in Sources */,
3706FC0D293F65D500E42796 /* AnimationView.swift in Sources */,
Expand Down Expand Up @@ -10878,6 +10884,7 @@
4B957B272AC7AE700062CA31 /* MenuItemSelectors.swift in Sources */,
4B957B282AC7AE700062CA31 /* FaviconView.swift in Sources */,
4B957B292AC7AE700062CA31 /* OnboardingFlow.swift in Sources */,
4BA71EDC2B4B81E80002EBCE /* AppVersionExtension.swift in Sources */,
4B957B2A2AC7AE700062CA31 /* PasswordManagementLoginModel.swift in Sources */,
4B957B2B2AC7AE700062CA31 /* TabViewModel.swift in Sources */,
4B957B2C2AC7AE700062CA31 /* TabDragAndDropManager.swift in Sources */,
Expand Down Expand Up @@ -11755,6 +11762,7 @@
AAC5E4F625D6BF2C007F5990 /* AddressBarButtonsViewController.swift in Sources */,
1D2DC0072901679C008083A1 /* BWError.swift in Sources */,
B68C92C42750EF76002AC6B0 /* PixelDataRecord.swift in Sources */,
4BA71EDA2B4B81E80002EBCE /* AppVersionExtension.swift in Sources */,
853014D625E671A000FB8205 /* PageObserverUserScript.swift in Sources */,
B677FC4F2B06376B0099EB04 /* ReportFeedbackView.swift in Sources */,
B642738227B65BAC0005DFD1 /* SecureVaultErrorReporter.swift in Sources */,
Expand Down
32 changes: 32 additions & 0 deletions DuckDuckGo/Common/Extensions/AppVersionExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// AppVersionExtension.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import Common

extension AppVersion {

static var buildType: String {
#if APPSTORE
return "appstore"
#else
return "dmg"
#endif
}

}
10 changes: 8 additions & 2 deletions DuckDuckGo/LoginItems/LoginItemsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@
do {
try action(item)()
} catch let error as NSError {
Pixel.fire(.debug(event: .loginItemUpdateError, error: error))
logOrAssertionFailure("🔴 Could not \(whatAreWeDoing) \(item): \(error.debugDescription)")
let event = Pixel.Event.Debug.loginItemUpdateError(
loginItemBundleID: item.agentBundleID,
action: whatAreWeDoing,
buildType: AppVersion.buildType
)

DailyPixel.fire(pixel: .debug(event: event, error: error), frequency: .dailyAndCount, includeAppVersionParameter: true)

Check failure on line 63 in DuckDuckGo/LoginItems/LoginItemsManager.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
// logOrAssertionFailure("🔴 Could not \(whatAreWeDoing) \(item): \(error.debugDescription)")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Statistics/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ extension Pixel {
case networkProtectionRemoteMessageFetchingFailed
case networkProtectionRemoteMessageStorageFailed

case loginItemUpdateError
case loginItemUpdateError(loginItemBundleID: String, action: String, buildType: String)
}

}
Expand Down
120 changes: 120 additions & 0 deletions DuckDuckGo/Statistics/PixelParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ extension Pixel.Event {
case .debug(event: let debugEvent, error: let error):
var params = error?.pixelParameters ?? [:]

if let debugParams = debugEvent.parameters {
params.merge(debugParams) { (current, _) in current }
}

if case let .assertionFailure(message, file, line) = debugEvent {
params[PixelKit.Parameters.assertionMessage] = message
params[PixelKit.Parameters.assertionFile] = String(file)
Expand Down Expand Up @@ -168,6 +172,122 @@ extension Pixel.Event {

}

extension Pixel.Event.Debug {

var parameters: [String: String]? {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't have the ability to do this before AFAIK, so I've added support for it here. This code avoids using default, so that any time someone adds a new debug event they're forced to consider whether parameters need adding.

switch self {
case .loginItemUpdateError(let loginItemBundleID, let action, let buildType):
return ["loginItemBundleID": loginItemBundleID, "action": action, "buildType": buildType]
case .pixelKitEvent,
.assertionFailure,
.dbMakeDatabaseError,
.dbContainerInitializationError,
.dbInitializationError,
.dbSaveExcludedHTTPSDomainsError,
.dbSaveBloomFilterError,
.configurationFetchError,
.trackerDataParseFailed,
.trackerDataReloadFailed,
.trackerDataCouldNotBeLoaded,
.privacyConfigurationParseFailed,
.privacyConfigurationReloadFailed,
.privacyConfigurationCouldNotBeLoaded,
.fileStoreWriteFailed,
.fileMoveToDownloadsFailed,
.fileGetDownloadLocationFailed,
.suggestionsFetchFailed,
.appOpenURLFailed,
.appStateRestorationFailed,
.contentBlockingErrorReportingIssue,
.contentBlockingCompilationFailed,
.contentBlockingCompilationTime,
.secureVaultInitError,
.secureVaultError,
.feedbackReportingFailed,
.blankNavigationOnBurnFailed,
.historyRemoveFailed,
.historyReloadFailed,
.historyCleanEntriesFailed,
.historyCleanVisitsFailed,
.historySaveFailed,
.historyInsertVisitFailed,
.historyRemoveVisitsFailed,
.emailAutofillKeychainError,
.bookmarksStoreRootFolderMigrationFailed,
.bookmarksStoreFavoritesFolderMigrationFailed,
.adAttributionCompilationFailedForAttributedRulesList,
.adAttributionGlobalAttributedRulesDoNotExist,
.adAttributionDetectionHeuristicsDidNotMatchDomain,
.adAttributionLogicUnexpectedStateOnRulesCompiled,
.adAttributionLogicUnexpectedStateOnInheritedAttribution,
.adAttributionLogicUnexpectedStateOnRulesCompilationFailed,
.adAttributionDetectionInvalidDomainInParameter,
.adAttributionLogicRequestingAttributionTimedOut,
.adAttributionLogicWrongVendorOnSuccessfulCompilation,
.adAttributionLogicWrongVendorOnFailedCompilation,
.webKitDidTerminate,
.removedInvalidBookmarkManagedObjects,
.bitwardenNotResponding,
.bitwardenRespondedCannotDecrypt,
.bitwardenRespondedCannotDecryptUnique,
.bitwardenHandshakeFailed,
.bitwardenDecryptionOfSharedKeyFailed,
.bitwardenStoringOfTheSharedKeyFailed,
.bitwardenCredentialRetrievalFailed,
.bitwardenCredentialCreationFailed,
.bitwardenCredentialUpdateFailed,
.bitwardenRespondedWithError,
.bitwardenNoActiveVault,
.bitwardenParsingFailed,
.bitwardenStatusParsingFailed,
.bitwardenHmacComparisonFailed,
.bitwardenDecryptionFailed,
.bitwardenSendingOfMessageFailed,
.bitwardenSharedKeyInjectionFailed,
.updaterAborted,
.userSelectedToSkipUpdate,
.userSelectedToInstallUpdate,
.userSelectedToDismissUpdate,
.faviconDecryptionFailedUnique,
.downloadListItemDecryptionFailedUnique,
.historyEntryDecryptionFailedUnique,
.permissionDecryptionFailedUnique,
.missingParent,
.bookmarksSaveFailed,
.bookmarksSaveFailedOnImport,
.bookmarksCouldNotLoadDatabase,
.bookmarksCouldNotPrepareDatabase,
.bookmarksMigrationAlreadyPerformed,
.bookmarksMigrationFailed,
.bookmarksMigrationCouldNotPrepareDatabase,
.bookmarksMigrationCouldNotPrepareDatabaseOnFailedMigration,
.bookmarksMigrationCouldNotRemoveOldStore,
.bookmarksMigrationCouldNotPrepareMultipleFavoriteFolders,
.syncSentUnauthenticatedRequest,
.syncMetadataCouldNotLoadDatabase,
.syncBookmarksProviderInitializationFailed,
.syncBookmarksFailed,
.syncCredentialsProviderInitializationFailed,
.syncCredentialsFailed,
.syncSettingsFailed,
.syncSettingsMetadataUpdateFailed,
.bookmarksCleanupFailed,
.bookmarksCleanupAttemptedWhileSyncWasEnabled,
.favoritesCleanupFailed,
.bookmarksFaviconsFetcherStateStoreInitializationFailed,
.bookmarksFaviconsFetcherFailed,
.credentialsDatabaseCleanupFailed,
.credentialsCleanupAttemptedWhileSyncWasEnabled,
.invalidPayload,
.burnerTabMisplaced,
.networkProtectionRemoteMessageFetchingFailed,
.networkProtectionRemoteMessageStorageFailed:
return nil
}
}

}

extension Error {

var pixelParameters: [String: String] {
Expand Down
7 changes: 1 addition & 6 deletions DuckDuckGo/VPNFeedbackForm/VPNMetadataCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,7 @@ final class DefaultVPNMetadataCollector: VPNMetadataCollector {
}

private func collectDeviceInfoMetadata() -> VPNMetadata.DeviceInfo {
#if APPSTORE
let buildFlavor: String = "appstore"
#else
let buildFlavor: String = "dmg"
#endif

let buildFlavor = AppVersion.buildType
let osVersion = AppVersion.shared.osVersion
let lowPowerModeEnabled: Bool

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import ServiceManagement
///
public struct LoginItem: Equatable, Hashable {

let agentBundleID: String
public let agentBundleID: String
private let launchInformation: LoginItemLaunchInformation
private let defaults: UserDefaults
private let log: OSLog
Expand Down
Loading