Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 56dbee7

Browse files
authored
Send pixel on sync secure storage read failure (#1058)
<!-- Note: This checklist is a reminder of our shared engineering expectations. --> Please review the release process for BrowserServicesKit [here](https://app.asana.com/0/1200194497630846/1200837094583426). **Required**: Task/Issue URL: https://app.asana.com/0/1201493110486074/1208686320819590/f iOS PR: duckduckgo/iOS#3530 macOS PR: duckduckgo/macos-browser#3497 What kind of version bump will this require?: Minor **Description:** On investigating a hard-to-reproduce issue with sync, I noticed there's a gap in error reporting when the secure storage (keychain) is not available. This adds a pixel for that case. **Steps to test this PR:** Just a pixel in an error case. Hard to test without altering code. But if you do want to do that: Enable sync Change BSK.DDGSync.SecureStorage.account() to throw every time Go to the Settings -> Sync screen You should see the `sync_secure_storage_read_error` Pixel in the debug console **OS Testing**: * [ ] iOS 14 * [ ] iOS 15 * [ ] iOS 16 * [ ] macOS 10.15 * [ ] macOS 11 * [ ] macOS 12 --- ###### Internal references: [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943)
1 parent 19f1e5c commit 56dbee7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Sources/DDGSync/DDGSync.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ public class DDGSync: DDGSyncing {
4242
}
4343

4444
public var account: SyncAccount? {
45-
try? dependencies.secureStore.account()
45+
do {
46+
return try dependencies.secureStore.account()
47+
} catch {
48+
if let syncError = error as? SyncError {
49+
dependencies.errorEvents.fire(syncError, error: syncError)
50+
}
51+
return nil
52+
}
4653
}
4754

4855
public var scheduler: Scheduling {

Sources/DDGSync/SyncError.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,14 @@ extension SyncError: CustomNSError {
190190
}
191191
}
192192

193+
public var errorUserInfo: [String: Any] {
194+
switch self {
195+
case .failedToReadSecureStore(let status), .failedToWriteSecureStore(let status), .failedToRemoveSecureStore(let status):
196+
let underlyingError = NSError(domain: "secError", code: Int(status))
197+
return [NSUnderlyingErrorKey: underlyingError]
198+
default:
199+
return [:]
200+
}
201+
}
202+
193203
}

0 commit comments

Comments
 (0)