From 5c7bf7ec551563cb8ec2478f62f030b957361ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20=C5=81yp?= Date: Thu, 14 Sep 2023 17:44:35 +0200 Subject: [PATCH 1/2] Send failed compilations pixel if needed --- Core/PixelEvent.swift | 4 ++++ DuckDuckGo.xcodeproj/project.pbxproj | 4 ++-- .../xcshareddata/swiftpm/Package.resolved | 8 ++++---- DuckDuckGo/AppDelegate.swift | 12 ++++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index 34c1adecdb..5b6f3e5a73 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -445,6 +445,8 @@ extension Pixel { case emailIncontextModalDismissed case emailIncontextModalExitEarly case emailIncontextModalExitEarlyContinue + + case compilationFailed } } @@ -881,6 +883,8 @@ extension Pixel.Event { case .emailIncontextModalDismissed: return "m_email_incontext_modal_dismissed" case .emailIncontextModalExitEarly: return "m_email_incontext_modal_exit_early" case .emailIncontextModalExitEarlyContinue: return "m_email_incontext_modal_exit_early_continue" + + case .compilationFailed: return "m_d_compilation_failed" } } diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 3715d07b19..18b76f5505 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -8877,8 +8877,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { - kind = exactVersion; - version = 77.2.0; + branch = "jacek/compilation-pixel"; + kind = branch; }; }; C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index a130d9919d..d2cc53d5e3 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -14,9 +14,9 @@ "package": "BrowserServicesKit", "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", "state": { - "branch": null, - "revision": "42b073f8a26165e8b328a5f72501abfecdd4c666", - "version": "77.2.0" + "branch": "jacek/compilation-pixel", + "revision": "7f04c144aa5dc7f1bf629695e844ecab942f394d", + "version": null } }, { @@ -156,7 +156,7 @@ }, { "package": "TrackerRadarKit", - "repositoryURL": "https://github.com/duckduckgo/TrackerRadarKit", + "repositoryURL": "https://github.com/duckduckgo/TrackerRadarKit.git", "state": { "branch": null, "revision": "4684440d03304e7638a2c8086895367e90987463", diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index 44add6f264..dd27ec01ec 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -309,6 +309,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } syncService.scheduler.notifyAppLifecycleEvent() + fireFailedCompilationsPixelIfNeeded() } private func fireAppLaunchPixel() { @@ -365,6 +366,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } #endif } + + private func fireFailedCompilationsPixelIfNeeded() { + let store = FailedCompilationsStore() + if store.hasAnyFailures { + DailyPixel.fire(pixel: .compilationFailed, withAdditionalParameters: store.summary) { error in + if error == nil { + store.cleanup() + } + } + } + } private func shouldShowKeyboardOnLaunch() -> Bool { guard let date = lastBackgroundDate else { return true } From 9b9c1f58c3afaa6e4f61468c3f2e989e2f79f9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20=C5=81yp?= Date: Mon, 25 Sep 2023 16:27:23 +0200 Subject: [PATCH 2/2] Use guard instead of if --- DuckDuckGo/AppDelegate.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index f791692b69..9f347056c7 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -391,9 +391,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let store = FailedCompilationsStore() if store.hasAnyFailures { DailyPixel.fire(pixel: .compilationFailed, withAdditionalParameters: store.summary) { error in - if error == nil { - store.cleanup() - } + guard error != nil else { return } + store.cleanup() } } }