Skip to content

Commit

Permalink
Add daily crash pixel (#3702)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/1200194497630846/1208908529122511/f
Tech Design URL:
CC:

Description:

This PR adds a daily crash pixel.
  • Loading branch information
samsymons authored Dec 10, 2024
1 parent 41b434c commit a78a34f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ extension Pixel {

// MARK: debug pixels
case dbCrashDetected
case dbCrashDetectedDaily
case crashOnCrashHandlersSetUp

case dbMigrationError
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a78a34f

Please sign in to comment.