From 27e7f4dbee0b6d096941949fe2ff930e8acfdf7e Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Fri, 10 May 2024 15:12:41 +0200 Subject: [PATCH] Enable gzip compression for Sync PATCH payloads (#2805) Task/Issue URL: https://app.asana.com/0/0/1206919211758354/f Description: This change adds gzip compression to all Sync data PATCH requests. --- Core/PixelEvent.swift | 6 ++++++ Core/SyncErrorHandler.swift | 10 ++++++++++ Core/SyncSettingsAdapter.swift | 2 ++ DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 15 ++++++++++++--- .../SyncSettingsViewController+SyncDelegate.swift | 2 -- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index a7e0c917c8..8fc73d888e 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -525,10 +525,13 @@ extension Pixel { case syncSentUnauthenticatedRequest case syncMetadataCouldNotLoadDatabase case syncBookmarksFailed + case syncBookmarksPatchCompressionFailed case syncCredentialsProviderInitializationFailed case syncCredentialsFailed + case syncCredentialsPatchCompressionFailed case syncSettingsFailed case syncSettingsMetadataUpdateFailed + case syncSettingsPatchCompressionFailed case syncSignupError case syncLoginError case syncLogoutError @@ -1173,10 +1176,13 @@ extension Pixel.Event { case .syncSentUnauthenticatedRequest: return "m_d_sync_sent_unauthenticated_request" case .syncMetadataCouldNotLoadDatabase: return "m_d_sync_metadata_could_not_load_database" case .syncBookmarksFailed: return "m_d_sync_bookmarks_failed" + case .syncBookmarksPatchCompressionFailed: return "m_d_sync_bookmarks_patch_compression_failed" case .syncCredentialsProviderInitializationFailed: return "m_d_sync_credentials_provider_initialization_failed" case .syncCredentialsFailed: return "m_d_sync_credentials_failed" + case .syncCredentialsPatchCompressionFailed: return "m_d_sync_credentials_patch_compression_failed" case .syncSettingsFailed: return "m_d_sync_settings_failed" case .syncSettingsMetadataUpdateFailed: return "m_d_sync_settings_metadata_update_failed" + case .syncSettingsPatchCompressionFailed: return "m_d_sync_settings_patch_compression_failed" case .syncSignupError: return "m_d_sync_signup_error" case .syncLoginError: return "m_d_sync_login_error" case .syncLogoutError: return "m_d_sync_logout_error" diff --git a/Core/SyncErrorHandler.swift b/Core/SyncErrorHandler.swift index c59a3462fe..87a4c6bdee 100644 --- a/Core/SyncErrorHandler.swift +++ b/Core/SyncErrorHandler.swift @@ -156,6 +156,16 @@ extension SyncErrorHandler { private func handleError(_ error: Error, modelType: ModelType) { switch error { + case SyncError.patchPayloadCompressionFailed(let errorCode): + let pixel: Pixel.Event = { + switch modelType { + case .bookmarks: + return .syncBookmarksPatchCompressionFailed + case .credentials: + return .syncCredentialsPatchCompressionFailed + } + }() + Pixel.fire(pixel: pixel, withAdditionalParameters: ["error": "\(errorCode)"]) case let syncError as SyncError: handleSyncError(syncError, modelType: modelType) default: diff --git a/Core/SyncSettingsAdapter.swift b/Core/SyncSettingsAdapter.swift index 9b310a9291..5f99a3610c 100644 --- a/Core/SyncSettingsAdapter.swift +++ b/Core/SyncSettingsAdapter.swift @@ -63,6 +63,8 @@ public final class SyncSettingsAdapter { syncErrorCancellable = provider.syncErrorPublisher .sink { error in switch error { + case SyncError.patchPayloadCompressionFailed(let errorCode): + Pixel.fire(pixel: .syncSettingsPatchCompressionFailed, withAdditionalParameters: ["error": "\(errorCode)"]) case let syncError as SyncError: Pixel.fire(pixel: .syncSettingsFailed, error: syncError) case let settingsMetadataError as SettingsSyncMetadataSaveError: diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 64a7f8094c..a5f1381fb0 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -9806,7 +9806,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 144.0.5; + version = 144.0.6; }; }; 9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index e44f305dc1..d352edeb83 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -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" } }, { @@ -72,6 +72,15 @@ "version" : "2.3.0" } }, + { + "identity" : "gzipswift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/1024jp/GzipSwift.git", + "state" : { + "revision" : "731037f6cc2be2ec01562f6597c1d0aa3fe6fd05", + "version" : "6.0.1" + } + }, { "identity" : "ios-js-support", "kind" : "remoteSourceControl", @@ -129,7 +138,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" diff --git a/DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift b/DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift index 98f844aa15..3ffee80dc6 100644 --- a/DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift +++ b/DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift @@ -298,7 +298,6 @@ extension SyncSettingsViewController: SyncManagementViewModelDelegate { } let confirmAction = UIAlertAction(title: UserText.syncTurnOffConfirmAction, style: .destructive) { _ in self.onConfirmSyncDisable?() - continuation.resume(returning: true) } alert.addAction(cancelAction) alert.addAction(confirmAction) @@ -329,7 +328,6 @@ extension SyncSettingsViewController: SyncManagementViewModelDelegate { } alert.addAction(title: UserText.syncDeleteAllConfirmAction, style: .destructive) { self.onConfirmAndDeleteAllData?() - continuation.resume(returning: true) } self.present(alert, animated: true) }