Skip to content

Commit

Permalink
Sync: Send pixels for account removal + decoding issues (#3530)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1201493110486074/1208723035104886/f
Tech Design URL:
CC:

**Description**:

Adds sync errors for catching when the keychain read throws a decoding
error and when the account is deleted for various reasons

Steps to test this PR:

1. Make sure you've already activated sync.
2. Deactivate sync (either delete the server data or just turn it off)
3. You should see the sync_account_removed_reason_user-turned-off pixel
in the console.

**Definition of Done**:

* [ ] Does this PR satisfy our [Definition of
Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?

---
###### Internal references:
[Pull Request Review
Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f)
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
[Pull Request
Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f)
  • Loading branch information
graeme committed Nov 11, 2024
1 parent 94e30ff commit 564ea8c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 41 deletions.
31 changes: 1 addition & 30 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15024,31 +15024,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 208.0.0;
};
};
9D84E4002CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "OHHTTPStubs" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/AliSoftware/OHHTTPStubs.git";
requirement = {
kind = exactVersion;
version = 9.1.0;
};
};
9D84E4032CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/pointfreeco/swift-snapshot-testing";
requirement = {
kind = exactVersion;
version = 1.15.4;
};
};
9D84E4052CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 200.3.0;
version = 208.1.0;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down Expand Up @@ -15650,22 +15626,18 @@
};
9D84E3FF2CD4E66F0046CD8B /* OHHTTPStubs */ = {
isa = XCSwiftPackageProductDependency;
package = 9D84E4002CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "OHHTTPStubs" */;
productName = OHHTTPStubs;
};
9D84E4012CD4E66F0046CD8B /* OHHTTPStubsSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 9D84E4002CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "OHHTTPStubs" */;
productName = OHHTTPStubsSwift;
};
9D84E4022CD4E66F0046CD8B /* SnapshotTesting */ = {
isa = XCSwiftPackageProductDependency;
package = 9D84E4032CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */;
productName = SnapshotTesting;
};
9D84E4042CD4E66F0046CD8B /* PixelKitTestingUtilities */ = {
isa = XCSwiftPackageProductDependency;
package = 9D84E4052CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = PixelKitTestingUtilities;
};
9D84E4062CD4E66F0046CD8B /* AppKitExtensions */ = {
Expand All @@ -15674,7 +15646,6 @@
};
9D84E4072CD4E66F0046CD8B /* Common */ = {
isa = XCSwiftPackageProductDependency;
package = 9D84E4052CD4E66F0046CD8B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = Common;
};
9D9AE8F82AAA3AD00026E7DC /* DataBrokerProtection */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "17154907fe86c75942331ed6d037694c666ddd95",
"version" : "208.0.0"
"revision" : "6be781530a2516c703b8e1bcf0c90e6e763d3300",
"version" : "208.1.0"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "1733ee59f06f6e725a98cf6cd8322159f59d664b",
"version" : "6.31.0"
"revision" : "adca39c379b1a124f9990e9d0308c374f32f5018",
"version" : "6.32.0"
}
},
{
Expand Down
5 changes: 5 additions & 0 deletions DuckDuckGo/Statistics/GeneralPixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ enum GeneralPixel: PixelKitEventV2 {
case syncLoginExistingAccountError(error: Error)
case syncCannotCreateRecoveryPDF
case syncSecureStorageReadError(error: Error)
case syncSecureStorageDecodingError(error: Error)
case syncAccountRemoved(reason: String)

case bookmarksCleanupFailed
case bookmarksCleanupAttemptedWhileSyncWasEnabled
Expand Down Expand Up @@ -1058,6 +1060,8 @@ enum GeneralPixel: PixelKitEventV2 {
case .syncLoginExistingAccountError: return "sync_login_existing_account_error"
case .syncCannotCreateRecoveryPDF: return "sync_cannot_create_recovery_pdf"
case .syncSecureStorageReadError: return "sync_secure_storage_read_error"
case .syncSecureStorageDecodingError: return "sync_secure_storage_decoding_error"
case .syncAccountRemoved(let reason): return "sync_account_removed_reason_\(reason)"

case .bookmarksCleanupFailed: return "bookmarks_cleanup_failed"
case .bookmarksCleanupAttemptedWhileSyncWasEnabled: return "bookmarks_cleanup_attempted_while_sync_was_enabled"
Expand Down Expand Up @@ -1119,6 +1123,7 @@ enum GeneralPixel: PixelKitEventV2 {
.syncDeleteAccountError(let error),
.syncLoginExistingAccountError(let error),
.syncSecureStorageReadError(let error),
.syncSecureStorageDecodingError(let error),
.bookmarksCouldNotLoadDatabase(let error?):
return error
default: return nil
Expand Down
16 changes: 12 additions & 4 deletions DuckDuckGo/Sync/SyncErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,26 @@ public class SyncErrorHandler: EventMapping<SyncError>, ObservableObject {

let alertPresenter: SyncAlertsPresenting

public init(alertPresenter: SyncAlertsPresenting = SyncAlertsPresenter()) {
self.alertPresenter = alertPresenter
super.init { event, _, _, _ in
static var errorHandlerMapping: Mapping {
return { event, _, _, _ in
switch event {
case .failedToReadSecureStore(let status):
case .failedToReadSecureStore:
PixelKit.fire(DebugEvent(GeneralPixel.syncSecureStorageReadError(error: event), error: event))
case .failedToDecodeSecureStoreData(let error):
PixelKit.fire(DebugEvent(GeneralPixel.syncSecureStorageDecodingError(error: error), error: error))
case .accountRemoved(let reason):
PixelKit.fire(DebugEvent(GeneralPixel.syncAccountRemoved(reason: reason.rawValue), error: event))
default:
PixelKit.fire(DebugEvent(GeneralPixel.syncSentUnauthenticatedRequest, error: event))
}
}
}

public init(alertPresenter: SyncAlertsPresenting = SyncAlertsPresenter()) {
self.alertPresenter = alertPresenter
super.init(mapping: Self.errorHandlerMapping)
}

override init(mapping: @escaping EventMapping<SyncError>.Mapping) {
fatalError("Use init()")
}
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: "208.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "208.1.0"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../AppKitExtensions"),
.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: "208.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "208.1.0"),
.package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"),
.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: "208.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "208.1.0"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down

0 comments on commit 564ea8c

Please sign in to comment.