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

Enable gzip compression for Sync PATCH payloads #2723

Merged
merged 11 commits into from
May 10, 2024
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12842,7 +12842,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 144.0.5;
version = 144.0.6;
};
};
9FF521422BAA8FF300B9819B /* 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" : "151737e0b690437a127cc6f1b9f443481cf2f645",
"version" : "144.0.5"
"revision" : "72be4e73360989af170399bc063fd5c628e1e84c",
"version" : "144.0.6"
}
},
{
Expand Down Expand Up @@ -63,6 +63,15 @@
"version" : "2.3.0"
}
},
{
"identity" : "gzipswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/1024jp/GzipSwift.git",
"state" : {
"revision" : "731037f6cc2be2ec01562f6597c1d0aa3fe6fd05",
"version" : "6.0.1"
}
},
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -120,7 +129,7 @@
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "46989693916f56d1186bd59ac15124caef896560",
"version" : "1.3.1"
Expand All @@ -138,7 +147,7 @@
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"location" : "https://github.com/apple/swift-syntax",
"state" : {
"revision" : "64889f0c732f210a935a0ad7cda38f77f876262d",
"version" : "509.1.1"
Expand All @@ -165,7 +174,7 @@
{
"identity" : "trackerradarkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/TrackerRadarKit",
"location" : "https://github.com/duckduckgo/TrackerRadarKit.git",
"state" : {
"revision" : "6c84fd19139414fc0edbf9673ade06e532a564f0",
"version" : "2.0.0"
Expand Down
6 changes: 6 additions & 0 deletions DuckDuckGo/Statistics/GeneralPixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,13 @@ enum GeneralPixel: PixelKitEventV2 {
case syncMetadataCouldNotLoadDatabase
case syncBookmarksProviderInitializationFailed
case syncBookmarksFailed
case syncBookmarksPatchCompressionFailed
case syncCredentialsProviderInitializationFailed
case syncCredentialsFailed
case syncCredentialsPatchCompressionFailed
case syncSettingsFailed
case syncSettingsMetadataUpdateFailed
case syncSettingsPatchCompressionFailed
case syncSignupError(error: Error)
case syncLoginError(error: Error)
case syncLogoutError(error: Error)
Expand Down Expand Up @@ -756,10 +759,13 @@ enum GeneralPixel: PixelKitEventV2 {
case .syncMetadataCouldNotLoadDatabase: return "sync_metadata_could_not_load_database"
case .syncBookmarksProviderInitializationFailed: return "sync_bookmarks_provider_initialization_failed"
case .syncBookmarksFailed: return "sync_bookmarks_failed"
case .syncBookmarksPatchCompressionFailed: return "sync_bookmarks_patch_compression_failed"
case .syncCredentialsProviderInitializationFailed: return "sync_credentials_provider_initialization_failed"
case .syncCredentialsFailed: return "sync_credentials_failed"
case .syncCredentialsPatchCompressionFailed: return "sync_credentials_patch_compression_failed"
case .syncSettingsFailed: return "sync_settings_failed"
case .syncSettingsMetadataUpdateFailed: return "sync_settings_metadata_update_failed"
case .syncSettingsPatchCompressionFailed: return "sync_settings_patch_compression_failed"
case .syncSignupError: return "sync_signup_error"
case .syncLoginError: return "sync_login_error"
case .syncLogoutError: return "sync_logout_error"
Expand Down
10 changes: 10 additions & 0 deletions DuckDuckGo/Sync/SyncErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ extension SyncErrorHandler: SyncErrorHandling {

private func handleError(_ error: Error, modelType: ModelType) {
switch error {
case SyncError.patchPayloadCompressionFailed(let errorCode):
let pixel: PixelKit.Event = {
switch modelType {
case .bookmarks:
return DebugEvent(GeneralPixel.syncBookmarksPatchCompressionFailed)
case .credentials:
return DebugEvent(GeneralPixel.syncCredentialsPatchCompressionFailed)
}
}()
PixelKit.fire(pixel, withAdditionalParameters: ["error": "\(errorCode)"])
case let syncError as SyncError:
switch modelType {
case .bookmarks:
Expand Down
5 changes: 5 additions & 0 deletions DuckDuckGo/Sync/SyncSettingsAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ final class SyncSettingsAdapter {
syncErrorCancellable = provider.syncErrorPublisher
.sink { error in
switch error {
case SyncError.patchPayloadCompressionFailed(let errorCode):
PixelKit.fire(
DebugEvent(GeneralPixel.syncSettingsPatchCompressionFailed),
withAdditionalParameters: ["error": "\(errorCode)"]
)
case let syncError as SyncError:
PixelKit.fire(DebugEvent(GeneralPixel.syncSettingsFailed, error: syncError))
case let settingsMetadataError as SettingsSyncMetadataSaveError:
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: "144.0.5"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "144.0.6"),
.package(path: "../SwiftUIExtensions"),
.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 @@ -31,7 +31,7 @@ let package = Package(
.library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "144.0.5"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "144.0.6"),
.package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.1"),
.package(path: "../XPCHelper"),
.package(path: "../SwiftUIExtensions"),
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: "144.0.5"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "144.0.6"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down
Loading