From 5ef686f7dceb00b15e9d7969cf59c505d95955b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jacek=20=C5=81yp?= <jlyp@duckduckgo.com>
Date: Thu, 19 Dec 2024 16:28:25 +0100
Subject: [PATCH] Fix issue

---
 DuckDuckGo/AppLifecycle/AppStateTransitions.swift  | 4 ++--
 DuckDuckGo/AppLifecycle/AppStates/Background.swift | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/DuckDuckGo/AppLifecycle/AppStateTransitions.swift b/DuckDuckGo/AppLifecycle/AppStateTransitions.swift
index ad90a1c946..7a0e6da79f 100644
--- a/DuckDuckGo/AppLifecycle/AppStateTransitions.swift
+++ b/DuckDuckGo/AppLifecycle/AppStateTransitions.swift
@@ -91,7 +91,7 @@ extension Background {
         case .openURL:
             return self
         case .backgrounding:
-            return DoubleBackground(firstTimeBackgroundTimestamp: timestamp)
+            return DoubleBackground(firstTimeBackgroundTimestamp: timestamp, consecutiveTimestamps: [])
         case .launching, .suspending:
             return handleUnexpectedEvent(event)
         }
@@ -111,7 +111,7 @@ extension DoubleBackground {
         case .suspending(let application):
             return Inactive(application: application)
         case .backgrounding(let application):
-            return DoubleBackground(firstTimeBackgroundTimestamp: firstTimeBackgroundTimestamp,)
+            return DoubleBackground(firstTimeBackgroundTimestamp: firstTimeBackgroundTimestamp, consecutiveTimestamps: consecutiveTimestamps)
         case .launching, .openURL:
             return self
         }
diff --git a/DuckDuckGo/AppLifecycle/AppStates/Background.swift b/DuckDuckGo/AppLifecycle/AppStates/Background.swift
index 4170df4ba6..6f3ac71b53 100644
--- a/DuckDuckGo/AppLifecycle/AppStates/Background.swift
+++ b/DuckDuckGo/AppLifecycle/AppStates/Background.swift
@@ -39,12 +39,13 @@ struct DoubleBackground: AppState {
     }()
 
     let firstTimeBackgroundTimestamp: Date
-    var consecutiveTimestamps: [Date]
+    var consecutiveTimestamps: [Date] = []
 
-    init(firstTimeBackgroundTimestamp: Date) {
+    init(firstTimeBackgroundTimestamp: Date, consecutiveTimestamps: [Date]) {
         self.firstTimeBackgroundTimestamp = firstTimeBackgroundTimestamp
+        self.consecutiveTimestamps = consecutiveTimestamps
         let lastTimestamp = Date()
-        consecutiveTimestamps.append(lastTimestamp)
+        self.consecutiveTimestamps.append(lastTimestamp)
 
         var parameters = [PixelParameters.firstBackgroundTimestamp: dateFormatter.string(from: firstTimeBackgroundTimestamp)]