Skip to content

Commit

Permalink
Rename and add didPerformFetch timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklyp committed Dec 20, 2024
1 parent 0a694ec commit d8cd0a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
12 changes: 7 additions & 5 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ import os.log
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

Logger.lifecycle.debug(#function)

didPerformFetchTimestamp = Date()
AppConfigurationFetch().start(isBackgroundFetch: true) { result in
switch result {
case .noData:
Expand Down Expand Up @@ -1171,13 +1171,15 @@ import os.log
didReceiveMemoryWarningTimestamp = Date()
}
var didReceiveMXPayloadTimestamp: Date?
var didReceiveUNNotification: Date?
var didStartRemoteMessagingClientBackgroundTask: Date? {
var didReceiveUNNotificationTimestamp: Date?
var didStartRemoteMessagingClientBackgroundTaskTimestamp: Date? {
remoteMessagingClient.didStartBackgroundTaskTimestamp
}
var didStartAppConfigurationFetchBackgroundTask: Date? {
var didStartAppConfigurationFetchBackgroundTaskTimestamp: Date? {
AppConfigurationFetch.didStartBackgroundTaskTimestamp
}

var didPerformFetchTimestamp: Date?
}

extension AppDelegate: BlankSnapshotViewRecoveringDelegate {
Expand Down Expand Up @@ -1230,7 +1232,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
didReceiveUNNotification = Date()
didReceiveUNNotificationTimestamp = Date()
if response.actionIdentifier == UNNotificationDefaultActionIdentifier {
let identifier = response.notification.request.identifier

Expand Down
18 changes: 9 additions & 9 deletions DuckDuckGo/AppLifecycle/AppStates/Background.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ struct DoubleBackground: AppState {
isValid(timestamp: didReceiveMXPayloadTimestamp) {
parameters[PixelParameters.didReceiveMXPayloadTimestamp] = dateFormatter.string(from: didReceiveMXPayloadTimestamp)
}
if let didReceiveUNNotification = appDelegate.didReceiveUNNotification,
isValid(timestamp: didReceiveUNNotification) {
parameters[PixelParameters.didReceiveUNNotification] = dateFormatter.string(from: didReceiveUNNotification)
if let didReceiveUNNotificationTimestamp = appDelegate.didReceiveUNNotificationTimestamp,
isValid(timestamp: didReceiveUNNotificationTimestamp) {
parameters[PixelParameters.didReceiveUNNotification] = dateFormatter.string(from: didReceiveUNNotificationTimestamp)
}
if let didStartRemoteMessagingClientBackgroundTask = appDelegate.didStartRemoteMessagingClientBackgroundTask,
isValid(timestamp: didStartRemoteMessagingClientBackgroundTask) {
parameters[PixelParameters.didStartRemoteMessagingClientBackgroundTask] = dateFormatter.string(from: didStartRemoteMessagingClientBackgroundTask)
if let didStartRemoteMessagingClientBackgroundTaskTimestamp = appDelegate.didStartRemoteMessagingClientBackgroundTaskTimestamp,
isValid(timestamp: didStartRemoteMessagingClientBackgroundTaskTimestamp) {
parameters[PixelParameters.didStartRemoteMessagingClientBackgroundTask] = dateFormatter.string(from: didStartRemoteMessagingClientBackgroundTaskTimestamp)
}
if let didStartAppConfigurationFetchBackgroundTask = appDelegate.didStartAppConfigurationFetchBackgroundTask,
isValid(timestamp: didStartAppConfigurationFetchBackgroundTask) {
parameters[PixelParameters.didStartAppConfigurationFetchBackgroundTask] = dateFormatter.string(from: didStartAppConfigurationFetchBackgroundTask)
if let didStartAppConfigurationFetchBackgroundTaskTimestamp = appDelegate.didStartAppConfigurationFetchBackgroundTaskTimestamp,
isValid(timestamp: didStartAppConfigurationFetchBackgroundTaskTimestamp) {
parameters[PixelParameters.didStartAppConfigurationFetchBackgroundTask] = dateFormatter.string(from: didStartAppConfigurationFetchBackgroundTaskTimestamp)
}
}
Pixel.fire(pixel: .appDidConsecutivelyBackground, withAdditionalParameters: parameters)
Expand Down

0 comments on commit d8cd0a4

Please sign in to comment.