From a5e128859670995ae5014fb85c4fe9529df7bb61 Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Mon, 9 Dec 2024 12:07:17 -0800 Subject: [PATCH 1/2] Add a daily crash pixel. --- DuckDuckGo/AppDelegate.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index eebeceda69..671b10a1cc 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -182,6 +182,16 @@ import os.log crashCollection.startAttachingCrashLogMessages { pixelParameters, payloads, sendReport in pixelParameters.forEach { params in Pixel.fire(pixel: .dbCrashDetected, withAdditionalParameters: params, includedParameters: []) + + // Each crash comes with an `appVersion` parameter representing the version that the crash occurred on. + // This is to disambiguate the situation where a crash occurs, but isn't sent until the next update. + // If for some reason the parameter can't be found, fall back to the current version. + if let crashAppVersion = params[PixelParameters.appVersion] { + let dailyParameters = [PixelParameters.appVersion: crashAppVersion] + DailyPixel.fireDaily(.dbCrashDetected, withAdditionalParameters: dailyParameters) + } else { + DailyPixel.fireDaily(.dbCrashDetected) + } } // Async dispatch because rootViewController may otherwise be nil here From ca0f25c13108e1afba2e826f67f180ab9ce7db05 Mon Sep 17 00:00:00 2001 From: Fernando Bunn Date: Mon, 9 Dec 2024 18:28:17 -0300 Subject: [PATCH 2/2] Change pixel name --- Core/PixelEvent.swift | 2 ++ DuckDuckGo/AppDelegate.swift | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index 48d2f36ac4..c566d27d93 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -506,6 +506,7 @@ extension Pixel { // MARK: debug pixels case dbCrashDetected + case dbCrashDetectedDaily case crashOnCrashHandlersSetUp case dbMigrationError @@ -1378,6 +1379,7 @@ extension Pixel.Event { // MARK: debug pixels case .dbCrashDetected: return "m_d_crash" + case .dbCrashDetectedDaily: return "m_d_crash_daily" case .crashOnCrashHandlersSetUp: return "m_d_crash_on_handlers_setup" case .dbMigrationError: return "m_d_dbme" case .dbRemovalError: return "m_d_dbre" diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index 671b10a1cc..75296ae8ea 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -188,9 +188,9 @@ import os.log // If for some reason the parameter can't be found, fall back to the current version. if let crashAppVersion = params[PixelParameters.appVersion] { let dailyParameters = [PixelParameters.appVersion: crashAppVersion] - DailyPixel.fireDaily(.dbCrashDetected, withAdditionalParameters: dailyParameters) + DailyPixel.fireDaily(.dbCrashDetectedDaily, withAdditionalParameters: dailyParameters) } else { - DailyPixel.fireDaily(.dbCrashDetected) + DailyPixel.fireDaily(.dbCrashDetectedDaily) } }