From a78a34ffbc07456ce6fc616caefb3c3c3db51992 Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Mon, 9 Dec 2024 16:52:16 -0800 Subject: [PATCH] Add daily crash pixel (#3702) Task/Issue URL: https://app.asana.com/0/1200194497630846/1208908529122511/f Tech Design URL: CC: Description: This PR adds a daily crash pixel. --- Core/PixelEvent.swift | 2 ++ DuckDuckGo/AppDelegate.swift | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index 225e1a0662..4c9d909115 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 eebeceda69..75296ae8ea 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(.dbCrashDetectedDaily, withAdditionalParameters: dailyParameters) + } else { + DailyPixel.fireDaily(.dbCrashDetectedDaily) + } } // Async dispatch because rootViewController may otherwise be nil here