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

New daily pixel for history save failures #2533

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions DuckDuckGo/History/Services/EncryptedHistoryStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ final class EncryptedHistoryStore: HistoryStoring {
fetchedObjects = try self.context.fetch(fetchRequest)
} catch {
Pixel.fire(.debug(event: .historySaveFailed, error: error))
Pixel.fire(.debug(event: .historySaveFailedDaily, error: error), limitTo: .dailyFirst)
promise(.failure(error))
return
}
Expand Down Expand Up @@ -203,13 +204,15 @@ final class EncryptedHistoryStore: HistoryStoring {
switch insertionResult {
case .failure(let error):
Pixel.fire(.debug(event: .historySaveFailed, error: error))
Pixel.fire(.debug(event: .historySaveFailedDaily, error: error), limitTo: .dailyFirst)
context.reset()
promise(.failure(error))
case .success(let visitMOs):
do {
try self.context.save()
} catch {
Pixel.fire(.debug(event: .historySaveFailed, error: error))
Pixel.fire(.debug(event: .historySaveFailedDaily, error: error), limitTo: .dailyFirst)
context.reset()
promise(.failure(HistoryStoreError.savingFailed))
return
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Menus/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ import SubscriptionUI
}
NSMenuItem(title: "Reset Email Protection InContext Signup Prompt", action: #selector(MainViewController.resetEmailProtectionInContextPrompt))
NSMenuItem(title: "Reset Daily Pixels", action: #selector(MainViewController.resetDailyPixels))
NSMenuItem(title: "Reset History Save Failed Daily Pixel", action: #selector(MainViewController.resetHistorySaveFailedDailyPixel(_:)))
}.withAccessibilityIdentifier("MainMenu.resetData")
NSMenuItem(title: "UI Triggers") {
NSMenuItem(title: "Show Save Credentials Popover", action: #selector(MainViewController.showSaveCredentialsPopover))
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@ extension MainViewController {
UserDefaults.standard.removePersistentDomain(forName: DailyPixel.Constant.dailyPixelStorageIdentifier)
}

@objc func resetHistorySaveFailedDailyPixel(_ sender: Any?) {
Pixel.shared?.clearRepetitions(for: .debug(event: .historySaveFailedDaily))
}

@objc func in10PercentSurveyOn(_ sender: Any?) {
UserDefaults.standard.set(true, forKey: UserDefaultsWrapper<Bool?>.Key.homePageShowSurveyDay14in10Percent.rawValue)
UserDefaults.standard.set(true, forKey: UserDefaultsWrapper<Bool?>.Key.homePageShowSurveyDay0in10Percent.rawValue)
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/Statistics/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ extension Pixel {
case historyCleanEntriesFailed
case historyCleanVisitsFailed
case historySaveFailed
case historySaveFailedDaily
case historyInsertVisitFailed
case historyRemoveVisitsFailed

Expand Down Expand Up @@ -834,6 +835,8 @@ extension Pixel.Event.Debug {
return "history_clean_visits_failed"
case .historySaveFailed:
return "history_save_failed"
case .historySaveFailedDaily:
return "history_save_failed_daily"
case .historyInsertVisitFailed:
return "history_insert_visit_failed"
case .historyRemoveVisitsFailed:
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Statistics/PixelParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ extension Pixel.Event.Debug {
.historyCleanEntriesFailed,
.historyCleanVisitsFailed,
.historySaveFailed,
.historySaveFailedDaily,
.historyInsertVisitFailed,
.historyRemoveVisitsFailed,
.emailAutofillKeychainError,
Expand Down
Loading