From 7a266d08646fd9fcc057de13ad1564c1670f5a2d Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Wed, 27 Mar 2024 10:45:57 +0100 Subject: [PATCH 1/8] Add support for sending crash reports from the App Store build via MetricKit --- DuckDuckGo.xcodeproj/project.pbxproj | 36 ++++++++++----- .../xcshareddata/swiftpm/Package.resolved | 6 +-- DuckDuckGo/Application/AppDelegate.swift | 21 ++++++++- .../CrashReports/Model/CrashReport.swift | 14 +++++- .../Model/CrashReportPromptPresenter.swift | 4 +- .../Model/CrashReportSender.swift | 45 ------------------- .../CrashReports/Model/CrashReporter.swift | 36 +++++---------- .../CrashReportPromptViewController.swift | 15 ++----- 8 files changed, 79 insertions(+), 98 deletions(-) delete mode 100644 DuckDuckGo/CrashReports/Model/CrashReportSender.swift diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 12118c66c1..adac3c0ff0 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -505,7 +505,6 @@ 3706FBC7293F65D500E42796 /* EncryptedHistoryStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7527B263B056C00B973F8 /* EncryptedHistoryStore.swift */; }; 3706FBC8293F65D500E42796 /* FirePopoverCollectionViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE246F12709EF3B00BEEAEE /* FirePopoverCollectionViewItem.swift */; }; 3706FBC9293F65D500E42796 /* ArrayExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA61C0D12727F59B00E6B681 /* ArrayExtension.swift */; }; - 3706FBCA293F65D500E42796 /* CrashReportSender.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC30A2B268F1ECD00D2D9CD /* CrashReportSender.swift */; }; 3706FBCB293F65D500E42796 /* BookmarkHTMLImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 373A1AAF2842C4EA00586521 /* BookmarkHTMLImporter.swift */; }; 3706FBCC293F65D500E42796 /* CustomRoundedCornersShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31C3CE0128EDC1E70002C24A /* CustomRoundedCornersShape.swift */; }; 3706FBCD293F65D500E42796 /* LocaleExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8D9061276D1D880078DB17 /* LocaleExtension.swift */; }; @@ -1085,6 +1084,9 @@ 37CD54D027F2FDD100F1F7B9 /* DefaultBrowserPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37CD54C827F2FDD100F1F7B9 /* DefaultBrowserPreferences.swift */; }; 37CEFCA92A6737A2001EF741 /* CredentialsCleanupErrorHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37CEFCA82A6737A2001EF741 /* CredentialsCleanupErrorHandling.swift */; }; 37CEFCAA2A6737A2001EF741 /* CredentialsCleanupErrorHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37CEFCA82A6737A2001EF741 /* CredentialsCleanupErrorHandling.swift */; }; + 37CF91592BB416A500BADCAE /* Crashes in Frameworks */ = {isa = PBXBuildFile; productRef = 37CF91582BB416A500BADCAE /* Crashes */; }; + 37CF915B2BB416AC00BADCAE /* Crashes in Frameworks */ = {isa = PBXBuildFile; productRef = 37CF915A2BB416AC00BADCAE /* Crashes */; }; + 37CF915D2BB416B300BADCAE /* Crashes in Frameworks */ = {isa = PBXBuildFile; productRef = 37CF915C2BB416B300BADCAE /* Crashes */; }; 37D2377A287EB8CA00BCE03B /* TabIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37D23779287EB8CA00BCE03B /* TabIndex.swift */; }; 37D2377C287EBDA300BCE03B /* TabIndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37D2377B287EBDA300BCE03B /* TabIndexTests.swift */; }; 37D23780287EFEE200BCE03B /* PinnedTabsManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37D2377F287EFEE200BCE03B /* PinnedTabsManagerTests.swift */; }; @@ -1703,7 +1705,6 @@ 4B957AD22AC7AE700062CA31 /* FirePopoverCollectionViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE246F12709EF3B00BEEAEE /* FirePopoverCollectionViewItem.swift */; }; 4B957AD32AC7AE700062CA31 /* ArrayExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA61C0D12727F59B00E6B681 /* ArrayExtension.swift */; }; 4B957AD42AC7AE700062CA31 /* NetworkProtectionInviteCodeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B4D60702A0B29FA00BCD287 /* NetworkProtectionInviteCodeViewModel.swift */; }; - 4B957AD52AC7AE700062CA31 /* CrashReportSender.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC30A2B268F1ECD00D2D9CD /* CrashReportSender.swift */; }; 4B957AD62AC7AE700062CA31 /* BookmarkHTMLImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 373A1AAF2842C4EA00586521 /* BookmarkHTMLImporter.swift */; }; 4B957AD72AC7AE700062CA31 /* CustomRoundedCornersShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31C3CE0128EDC1E70002C24A /* CustomRoundedCornersShape.swift */; }; 4B957AD82AC7AE700062CA31 /* LocaleExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8D9061276D1D880078DB17 /* LocaleExtension.swift */; }; @@ -2659,7 +2660,6 @@ AAC30A26268DFEE200D2D9CD /* CrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC30A25268DFEE200D2D9CD /* CrashReporter.swift */; }; AAC30A28268E045400D2D9CD /* CrashReportReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC30A27268E045400D2D9CD /* CrashReportReader.swift */; }; AAC30A2A268E239100D2D9CD /* CrashReport.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC30A29268E239100D2D9CD /* CrashReport.swift */; }; - AAC30A2C268F1ECD00D2D9CD /* CrashReportSender.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC30A2B268F1ECD00D2D9CD /* CrashReportSender.swift */; }; AAC30A2E268F1EE300D2D9CD /* CrashReportPromptPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC30A2D268F1EE300D2D9CD /* CrashReportPromptPresenter.swift */; }; AAC5E4C725D6A6E8007F5990 /* AddBookmarkPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC5E4C425D6A6E8007F5990 /* AddBookmarkPopover.swift */; }; AAC5E4D025D6A709007F5990 /* Bookmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC5E4CD25D6A709007F5990 /* Bookmark.swift */; }; @@ -4307,7 +4307,6 @@ AAC30A25268DFEE200D2D9CD /* CrashReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReporter.swift; sourceTree = ""; }; AAC30A27268E045400D2D9CD /* CrashReportReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReportReader.swift; sourceTree = ""; }; AAC30A29268E239100D2D9CD /* CrashReport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReport.swift; sourceTree = ""; }; - AAC30A2B268F1ECD00D2D9CD /* CrashReportSender.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReportSender.swift; sourceTree = ""; }; AAC30A2D268F1EE300D2D9CD /* CrashReportPromptPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReportPromptPresenter.swift; sourceTree = ""; }; AAC5E4C425D6A6E8007F5990 /* AddBookmarkPopover.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddBookmarkPopover.swift; sourceTree = ""; }; AAC5E4CD25D6A709007F5990 /* Bookmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bookmark.swift; sourceTree = ""; }; @@ -4726,6 +4725,7 @@ B6EC37FF29B8D915001ACE79 /* Configuration in Frameworks */, 372217822B33380700B8E9C2 /* TestUtils in Frameworks */, 3706FCAA293F65D500E42796 /* UserScript in Frameworks */, + 37CF915B2BB416AC00BADCAE /* Crashes in Frameworks */, 3706FCAB293F65D500E42796 /* TrackerRadarKit in Frameworks */, 85E2BBD02B8F534A00DBEC7A /* History in Frameworks */, 4BF97AD52B43C43F00EB4240 /* NetworkProtection in Frameworks */, @@ -4844,6 +4844,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 37CF915D2BB416B300BADCAE /* Crashes in Frameworks */, 4B957BD52AC7AE700062CA31 /* QuickLookUI.framework in Frameworks */, 3143C8792B0D1F3D00382627 /* DataBrokerProtection in Frameworks */, 372217842B33380E00B8E9C2 /* TestUtils in Frameworks */, @@ -4931,6 +4932,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 37CF91592BB416A500BADCAE /* Crashes in Frameworks */, 373FB4B12B4D6C42004C88D6 /* PreferencesViews in Frameworks */, 85E2BBCE2B8F534000DBEC7A /* History in Frameworks */, 1EA7B8D32B7E078C000330A4 /* SubscriptionUI in Frameworks */, @@ -7748,7 +7750,6 @@ children = ( AAC30A25268DFEE200D2D9CD /* CrashReporter.swift */, AAC30A27268E045400D2D9CD /* CrashReportReader.swift */, - AAC30A2B268F1ECD00D2D9CD /* CrashReportSender.swift */, AAC30A2D268F1EE300D2D9CD /* CrashReportPromptPresenter.swift */, AAC30A29268E239100D2D9CD /* CrashReport.swift */, ); @@ -8763,6 +8764,7 @@ 4BCBE4572BA7E17800FC75A1 /* SubscriptionUI */, 85D44B872BA08D30001B4AB5 /* Suggestions */, 4BCBE4592BA7E17800FC75A1 /* Subscription */, + 37CF915A2BB416AC00BADCAE /* Crashes */, ); productName = DuckDuckGo; productReference = 3706FD05293F65D500E42796 /* DuckDuckGo App Store.app */; @@ -9053,6 +9055,7 @@ 85E2BBD12B8F536F00DBEC7A /* History */, F1D43AF62B98E48F00BAB743 /* BareBonesBrowserKit */, 85D44B892BA08D3B001B4AB5 /* Suggestions */, + 37CF915C2BB416B300BADCAE /* Crashes */, ); productName = DuckDuckGo; productReference = 4B957C412AC7AE700062CA31 /* DuckDuckGo Privacy Pro.app */; @@ -9225,6 +9228,7 @@ 1EA7B8D42B7E078C000330A4 /* Subscription */, F1D43AF22B98E47800BAB743 /* BareBonesBrowserKit */, 85D44B852BA08D29001B4AB5 /* Suggestions */, + 37CF91582BB416A500BADCAE /* Crashes */, ); productName = DuckDuckGo; productReference = AA585D7E248FD31100E9A3E2 /* DuckDuckGo.app */; @@ -10502,7 +10506,6 @@ 3706FBC7293F65D500E42796 /* EncryptedHistoryStore.swift in Sources */, 3706FBC8293F65D500E42796 /* FirePopoverCollectionViewItem.swift in Sources */, 3706FBC9293F65D500E42796 /* ArrayExtension.swift in Sources */, - 3706FBCA293F65D500E42796 /* CrashReportSender.swift in Sources */, 3706FBCB293F65D500E42796 /* BookmarkHTMLImporter.swift in Sources */, 4BF97ADC2B43C5E200EB4240 /* VPNFeedbackSender.swift in Sources */, 987799F72999996B005D8EB6 /* BookmarkDatabase.swift in Sources */, @@ -11745,7 +11748,6 @@ 4B957AD22AC7AE700062CA31 /* FirePopoverCollectionViewItem.swift in Sources */, 4B957AD32AC7AE700062CA31 /* ArrayExtension.swift in Sources */, 4B957AD42AC7AE700062CA31 /* NetworkProtectionInviteCodeViewModel.swift in Sources */, - 4B957AD52AC7AE700062CA31 /* CrashReportSender.swift in Sources */, B6BCC5212AFCD9ED002C5499 /* DataImportSourcePicker.swift in Sources */, 4B957AD62AC7AE700062CA31 /* BookmarkHTMLImporter.swift in Sources */, 4B957AD72AC7AE700062CA31 /* CustomRoundedCornersShape.swift in Sources */, @@ -12559,7 +12561,6 @@ 4B41EDA32B1543B9001EEDF4 /* VPNPreferencesModel.swift in Sources */, AA61C0D22727F59B00E6B681 /* ArrayExtension.swift in Sources */, 4B4D60CC2A0C849600BCD287 /* NetworkProtectionInviteCodeViewModel.swift in Sources */, - AAC30A2C268F1ECD00D2D9CD /* CrashReportSender.swift in Sources */, 373A1AB02842C4EA00586521 /* BookmarkHTMLImporter.swift in Sources */, B6B5F57F2B024105008DB58A /* DataImportSummaryView.swift in Sources */, 31C3CE0228EDC1E70002C24A /* CustomRoundedCornersShape.swift in Sources */, @@ -14182,8 +14183,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { - kind = exactVersion; - version = 132.0.0; + branch = "dominik/sentry-appstore"; + kind = branch; }; }; AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = { @@ -14420,6 +14421,21 @@ isa = XCSwiftPackageProductDependency; productName = SyncUI; }; + 37CF91582BB416A500BADCAE /* Crashes */ = { + isa = XCSwiftPackageProductDependency; + package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */; + productName = Crashes; + }; + 37CF915A2BB416AC00BADCAE /* Crashes */ = { + isa = XCSwiftPackageProductDependency; + package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */; + productName = Crashes; + }; + 37CF915C2BB416B300BADCAE /* Crashes */ = { + isa = XCSwiftPackageProductDependency; + package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */; + productName = Crashes; + }; 37DF000429F9C056002B7D3E /* SyncDataProviders */ = { isa = XCSwiftPackageProductDependency; package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */; diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index b823bae73e..1c9b22ec0f 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "revision" : "dfb35745561322b2b80f8be0810ddb2c806e077e", - "version" : "132.0.0" + "branch" : "dominik/sentry-appstore", + "revision" : "852c5e65e21bd8c298ee8bafb712fb82cd2d6e07" } }, { @@ -165,7 +165,7 @@ { "identity" : "trackerradarkit", "kind" : "remoteSourceControl", - "location" : "https://github.com/duckduckgo/TrackerRadarKit.git", + "location" : "https://github.com/duckduckgo/TrackerRadarKit", "state" : { "revision" : "a6b7ba151d9dc6684484f3785293875ec01cc1ff", "version" : "1.2.2" diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index a76b942094..802ade3cee 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -23,8 +23,10 @@ import Combine import Common import Configuration import CoreData +import Crashes import DDGSync import History +import MetricKit import Networking import Persistence import PixelKit @@ -65,9 +67,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel let fileStore: FileStore +#if APPSTORE + private let crashCollection = CrashCollection(platform: .macOS, log: .default) +#else + private let crashReporter = CrashReporter() +#endif + private(set) var stateRestorationManager: AppStateRestorationManager! private var grammarFeaturesManager = GrammarFeaturesManager() - private let crashReporter = CrashReporter() let internalUserDecider: InternalUserDecider let featureFlagger: FeatureFlagger private var appIconChanger: AppIconChanger! @@ -278,7 +285,19 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel applyPreferredTheme() +#if APPSTORE + crashCollection.start { pixelParameters, payloads, completion in + pixelParameters.forEach { _ in Pixel.fire(.crash) } + guard let lastPayload = payloads.last else { + return + } + DispatchQueue.main.async { + CrashReportPromptPresenter().showPrompt(for: lastPayload, userDidAllowToReport: completion) + } + } +#else crashReporter.checkForNewReports() +#endif urlEventHandler.applicationDidFinishLaunching() diff --git a/DuckDuckGo/CrashReports/Model/CrashReport.swift b/DuckDuckGo/CrashReports/Model/CrashReport.swift index 773c66cd27..922ef45d41 100644 --- a/DuckDuckGo/CrashReports/Model/CrashReport.swift +++ b/DuckDuckGo/CrashReports/Model/CrashReport.swift @@ -17,13 +17,17 @@ // import Foundation +import MetricKit -protocol CrashReport { +protocol CrashReportPresenting { + var content: String? { get } +} + +protocol CrashReport: CrashReportPresenting { static var fileExtension: String { get } var url: URL { get } - var content: String? { get } var contentData: Data? { get } } @@ -91,3 +95,9 @@ struct JSONCrashReport: CrashReport { } } + +extension MXDiagnosticPayload: CrashReportPresenting { + var content: String? { + jsonRepresentation().utf8String() + } +} diff --git a/DuckDuckGo/CrashReports/Model/CrashReportPromptPresenter.swift b/DuckDuckGo/CrashReports/Model/CrashReportPromptPresenter.swift index 3d4e17cd2f..313c6a1e95 100644 --- a/DuckDuckGo/CrashReports/Model/CrashReportPromptPresenter.swift +++ b/DuckDuckGo/CrashReports/Model/CrashReportPromptPresenter.swift @@ -31,9 +31,9 @@ final class CrashReportPromptPresenter { // swiftlint:enable force_cast } - func showPrompt(_ delegate: CrashReportPromptViewControllerDelegate, for crashReport: CrashReport) { - viewController.delegate = delegate + func showPrompt(for crashReport: CrashReportPresenting, userDidAllowToReport: @escaping () -> Void) { viewController.crashReport = crashReport + viewController.userDidAllowToReport = userDidAllowToReport windowController.showWindow(self) windowController.window?.center() diff --git a/DuckDuckGo/CrashReports/Model/CrashReportSender.swift b/DuckDuckGo/CrashReports/Model/CrashReportSender.swift deleted file mode 100644 index e6ac958fc3..0000000000 --- a/DuckDuckGo/CrashReports/Model/CrashReportSender.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// CrashReportSender.swift -// -// Copyright © 2021 DuckDuckGo. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import Foundation - -final class CrashReportSender { - - static let reportServiceUrl = URL(string: "https://duckduckgo.com/crash.js")! - - private let session = URLSession(configuration: .ephemeral) - - func send(_ crashReport: CrashReport) { - guard let contentData = crashReport.contentData else { - assertionFailure("CrashReportSender: Can't get the content of the crash report") - return - } - var request = URLRequest(url: Self.reportServiceUrl) - request.setValue("text/plain", forHTTPHeaderField: "Content-Type") - request.setValue("ddg_mac", forHTTPHeaderField: "User-Agent") - request.httpMethod = "POST" - request.httpBody = contentData - - session.dataTask(with: request) { (_, _, error) in - if error != nil { - assertionFailure("CrashReportSender: Failed to send the crash reprot") - } - }.resume() - } - -} diff --git a/DuckDuckGo/CrashReports/Model/CrashReporter.swift b/DuckDuckGo/CrashReports/Model/CrashReporter.swift index 39288b6043..4a93d7779e 100644 --- a/DuckDuckGo/CrashReports/Model/CrashReporter.swift +++ b/DuckDuckGo/CrashReports/Model/CrashReporter.swift @@ -16,19 +16,19 @@ // limitations under the License. // +import Common +import Crashes import Foundation final class CrashReporter { private let reader = CrashReportReader() - private lazy var sender = CrashReportSender() + private lazy var sender = CrashReportSender(platform: .macOS, log: .default) private lazy var promptPresenter = CrashReportPromptPresenter() @UserDefaultsWrapper(key: .lastCrashReportCheckDate, defaultValue: nil) private var lastCheckDate: Date? - private var latestCrashReport: CrashReport? - func checkForNewReports() { #if !DEBUG @@ -49,29 +49,17 @@ final class CrashReporter { Pixel.fire(.crash) - latestCrashReport = latest - promptPresenter.showPrompt(self, for: latest) - -#endif - - } - -} - -extension CrashReporter: CrashReportPromptViewControllerDelegate { - - func crashReportPromptViewController(_ crashReportPromptViewController: CrashReportPromptViewController, - userDidAllowToReport: Bool) { - guard userDidAllowToReport else { - return + promptPresenter.showPrompt(for: latest) { + guard let contentData = latest.contentData else { + assertionFailure("CrashReporter: Can't get the content of the crash report") + return + } + Task { + await sender.send(contentData) + } } - guard let latestCrashReport = latestCrashReport else { - assertionFailure("CrashReporter: The latest crash report is nil") - return - } +#endif - sender.send(latestCrashReport) } - } diff --git a/DuckDuckGo/CrashReports/View/CrashReportPromptViewController.swift b/DuckDuckGo/CrashReports/View/CrashReportPromptViewController.swift index f8977d640b..4b21d7a222 100644 --- a/DuckDuckGo/CrashReports/View/CrashReportPromptViewController.swift +++ b/DuckDuckGo/CrashReports/View/CrashReportPromptViewController.swift @@ -18,13 +18,6 @@ import Cocoa -protocol CrashReportPromptViewControllerDelegate: AnyObject { - - func crashReportPromptViewController(_ crashReportPromptViewController: CrashReportPromptViewController, - userDidAllowToReport: Bool) - -} - final class CrashReportPromptViewController: NSViewController { @IBOutlet weak var titleLabel: NSTextField! @IBOutlet weak var dontSendButton: NSButton! @@ -33,8 +26,9 @@ final class CrashReportPromptViewController: NSViewController { @IBOutlet weak var descriptionLabel: NSTextField! @IBOutlet var textView: NSTextView! - weak var delegate: CrashReportPromptViewControllerDelegate? - var crashReport: CrashReport? { + var userDidAllowToReport: () -> Void = {} + + var crashReport: CrashReportPresenting? { didSet { updateView() } @@ -58,12 +52,11 @@ final class CrashReportPromptViewController: NSViewController { } @IBAction func sendAction(_ sender: Any) { - delegate?.crashReportPromptViewController(self, userDidAllowToReport: true) + userDidAllowToReport() view.window?.close() } @IBAction func dontSendAction(_ sender: Any) { - delegate?.crashReportPromptViewController(self, userDidAllowToReport: false) view.window?.close() } From a46173d598b50b7c3d0a9c5717611424487cba41 Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Wed, 27 Mar 2024 11:54:48 +0100 Subject: [PATCH 2/8] Use a dedicated UA for macOS App Store crash reporting --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 2 +- DuckDuckGo/Application/AppDelegate.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 1c9b22ec0f..06962c1713 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -33,7 +33,7 @@ "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { "branch" : "dominik/sentry-appstore", - "revision" : "852c5e65e21bd8c298ee8bafb712fb82cd2d6e07" + "revision" : "bcacbabb84b6d81f06fcaa5d6b1169c43cadceec" } }, { diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index 802ade3cee..f0f9801e4b 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -68,7 +68,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel let fileStore: FileStore #if APPSTORE - private let crashCollection = CrashCollection(platform: .macOS, log: .default) + private let crashCollection = CrashCollection(platform: .macOSAppStore, log: .default) #else private let crashReporter = CrashReporter() #endif From 61bfdff0fc43ac0c050d3003dcf3ec4ba189e248 Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Thu, 28 Mar 2024 13:38:51 +0100 Subject: [PATCH 3/8] Update BSK ref --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 06962c1713..5281501796 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -33,7 +33,7 @@ "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { "branch" : "dominik/sentry-appstore", - "revision" : "bcacbabb84b6d81f06fcaa5d6b1169c43cadceec" + "revision" : "c8f8b9ee37ab516d7a3c00e49bc2f70370e9e67b" } }, { From 502f6a14b5186800d07dd7c47e12f9cc4d5831b3 Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Thu, 28 Mar 2024 13:49:45 +0100 Subject: [PATCH 4/8] Fix compilation --- DuckDuckGo/CrashReports/Model/CrashReporter.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DuckDuckGo/CrashReports/Model/CrashReporter.swift b/DuckDuckGo/CrashReports/Model/CrashReporter.swift index 4a93d7779e..1ddc844479 100644 --- a/DuckDuckGo/CrashReports/Model/CrashReporter.swift +++ b/DuckDuckGo/CrashReports/Model/CrashReporter.swift @@ -55,7 +55,7 @@ final class CrashReporter { return } Task { - await sender.send(contentData) + await self.sender.send(contentData) } } From 4f1c92d84ac326525244106ab53701597ac79ec5 Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Fri, 12 Apr 2024 08:03:57 +0200 Subject: [PATCH 5/8] Update BSK ref --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 76a643592a..855a6ba672 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -33,7 +33,7 @@ "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { "branch" : "dominik/sentry-appstore", - "revision" : "e55997d7e19741f8e393877893f3e4fe41a9c22b" + "revision" : "f6ac4b52028be3b60fadc4cd2bb7d2c11fcf59cf" } }, { From 1a2ab1fe44e3845078d0c7c689c2a0e25cdb7210 Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Fri, 12 Apr 2024 15:28:06 +0200 Subject: [PATCH 6/8] Update BSK ref --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 9da03cd9ad..bb0e555f76 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -33,7 +33,7 @@ "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { "branch" : "dominik/sentry-appstore", - "revision" : "21a9a111d64ffb162c44a89f706763d2b8f8b167" + "revision" : "753db4880937c5b7d818d874dec2ae23fc874480" } }, { From c063ec6dd1b810aff92695d3d3282d2a82163a17 Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Thu, 18 Apr 2024 12:38:52 +0200 Subject: [PATCH 7/8] Use BSK 137.0.0 --- DuckDuckGo.xcodeproj/project.pbxproj | 10 ++-------- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- LocalPackages/DataBrokerProtection/Package.swift | 2 +- LocalPackages/NetworkProtectionMac/Package.swift | 2 +- LocalPackages/SubscriptionUI/Package.swift | 2 +- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 87611db519..36eb9784e0 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -1030,7 +1030,6 @@ 37CEFCAA2A6737A2001EF741 /* CredentialsCleanupErrorHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37CEFCA82A6737A2001EF741 /* CredentialsCleanupErrorHandling.swift */; }; 37CF91592BB416A500BADCAE /* Crashes in Frameworks */ = {isa = PBXBuildFile; productRef = 37CF91582BB416A500BADCAE /* Crashes */; }; 37CF915B2BB416AC00BADCAE /* Crashes in Frameworks */ = {isa = PBXBuildFile; productRef = 37CF915A2BB416AC00BADCAE /* Crashes */; }; - 37CF915D2BB416B300BADCAE /* Crashes in Frameworks */ = {isa = PBXBuildFile; productRef = 37CF915C2BB416B300BADCAE /* Crashes */; }; 37D2377A287EB8CA00BCE03B /* TabIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37D23779287EB8CA00BCE03B /* TabIndex.swift */; }; 37D2377C287EBDA300BCE03B /* TabIndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37D2377B287EBDA300BCE03B /* TabIndexTests.swift */; }; 37D23780287EFEE200BCE03B /* PinnedTabsManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37D2377F287EFEE200BCE03B /* PinnedTabsManagerTests.swift */; }; @@ -12565,8 +12564,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { - branch = "dominik/sentry-appstore"; - kind = branch; + kind = exactVersion; + version = 137.0.0; }; }; 9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = { @@ -12793,11 +12792,6 @@ package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */; productName = Crashes; }; - 37CF915C2BB416B300BADCAE /* Crashes */ = { - isa = XCSwiftPackageProductDependency; - package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */; - productName = Crashes; - }; 37DF000429F9C056002B7D3E /* SyncDataProviders */ = { isa = XCSwiftPackageProductDependency; package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */; diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d697759f6a..56d2001fea 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "branch" : "dominik/sentry-appstore", - "revision" : "f2beb83770d30b5d18425ce0776b3fe26fc8dd21" + "revision" : "4ce049682cb47a9fb510237070666e5e8bf1e07b", + "version" : "137.0.0" } }, { diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index 484042994b..df2e1a5447 100644 --- a/LocalPackages/DataBrokerProtection/Package.swift +++ b/LocalPackages/DataBrokerProtection/Package.swift @@ -29,7 +29,7 @@ let package = Package( targets: ["DataBrokerProtection"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "136.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "137.0.0"), .package(path: "../PixelKit"), .package(path: "../SwiftUIExtensions"), .package(path: "../XPCHelper"), diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index f5b56a201d..17669b5f8a 100644 --- a/LocalPackages/NetworkProtectionMac/Package.swift +++ b/LocalPackages/NetworkProtectionMac/Package.swift @@ -31,7 +31,7 @@ let package = Package( .library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "136.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "137.0.0"), .package(path: "../XPCHelper"), .package(path: "../SwiftUIExtensions"), .package(path: "../LoginItems"), diff --git a/LocalPackages/SubscriptionUI/Package.swift b/LocalPackages/SubscriptionUI/Package.swift index 9f395e06a5..524e9ef352 100644 --- a/LocalPackages/SubscriptionUI/Package.swift +++ b/LocalPackages/SubscriptionUI/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["SubscriptionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "136.0.0"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "137.0.0"), .package(path: "../SwiftUIExtensions") ], targets: [ From 9a6a4b7e47eb4dc3ed82eeb369449ac904322a1e Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Thu, 18 Apr 2024 12:50:27 +0200 Subject: [PATCH 8/8] Fix firing crash pixel --- DuckDuckGo/Application/AppDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index 5c88f8631a..5b6d2a1eb4 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -284,7 +284,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { #if APPSTORE crashCollection.start { pixelParameters, payloads, completion in - pixelParameters.forEach { _ in Pixel.fire(.crash) } + pixelParameters.forEach { _ in PixelKit.fire(GeneralPixel.crash) } guard let lastPayload = payloads.last else { return }