Skip to content

Commit

Permalink
Add validation error pixel
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Jul 5, 2024
1 parent 967c4eb commit 543d111
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DuckDuckGo/Statistics/GeneralPixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ enum GeneralPixel: PixelKitEventV2 {
case syncBookmarksTooManyRequestsDaily
case syncCredentialsTooManyRequestsDaily
case syncSettingsTooManyRequestsDaily
case syncBookmarksValidationErrorDaily
case syncCredentialsValidationErrorDaily
case syncSettingsValidationErrorDaily

// DataBroker Protection Waitlist
case dataBrokerProtectionWaitlistUserActive
Expand Down Expand Up @@ -623,6 +626,9 @@ enum GeneralPixel: PixelKitEventV2 {
case .syncBookmarksTooManyRequestsDaily: return "m_mac_sync_bookmarks_too_many_requests_daily"
case .syncCredentialsTooManyRequestsDaily: return "m_mac_sync_credentials_too_many_requests_daily"
case .syncSettingsTooManyRequestsDaily: return "m_mac_sync_settings_too_many_requests_daily"
case .syncBookmarksValidationErrorDaily: return "m_mac_sync_bookmarks_validation_error_daily"
case .syncCredentialsValidationErrorDaily: return "m_mac_sync_credentials_validation_error_daily"
case .syncSettingsValidationErrorDaily: return "m_mac_sync_settings_validation_error_daily"

case .dataBrokerProtectionWaitlistUserActive:
return "m_mac_dbp_waitlist_user_active"
Expand Down
12 changes: 12 additions & 0 deletions DuckDuckGo/Sync/SyncErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ extension SyncErrorHandler: SyncErrorHandling {
case .settings:
break
}
PixelKit.fire(modelType.badRequestPixel, frequency: .legacyDaily)
case .unexpectedStatusCode(401):
syncIsPaused(errorType: .invalidLoginCredentials)
case .unexpectedStatusCode(418), .unexpectedStatusCode(429):
Expand Down Expand Up @@ -408,6 +409,17 @@ extension SyncErrorHandler: SyncErrorHandling {
.syncSettingsTooManyRequestsDaily
}
}

var badRequestPixel: GeneralPixel {
switch self {
case .bookmarks:
.syncBookmarksTooManyRequestsDaily
case .credentials:
.syncCredentialsTooManyRequestsDaily
case .settings:
.syncSettingsTooManyRequestsDaily
}
}
}

@MainActor
Expand Down

0 comments on commit 543d111

Please sign in to comment.