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 #2805

Merged
merged 7 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions Core/SyncErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Core/SyncSettingsAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public final class SyncSettingsAdapter {
syncErrorCancellable = provider.syncErrorPublisher
.sink { error in
switch error {
case SyncError.patchPayloadCompressionFailed(let errorCode):
Copy link
Contributor

Choose a reason for hiding this comment

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

I will move it into SyncErrorHandler when I got some time

Pixel.fire(pixel: .syncSettingsPatchCompressionFailed, withAdditionalParameters: ["error": "\(errorCode)"])
case let syncError as SyncError:
Pixel.fire(pixel: .syncSettingsFailed, error: syncError)
case let settingsMetadataError as SettingsSyncMetadataSaveError:
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
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 @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
Loading