Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS 12 crash report handling #431

Merged
merged 16 commits into from
Feb 23, 2022
Merged

Conversation

samsymons
Copy link
Collaborator

@samsymons samsymons commented Feb 18, 2022

Task/Issue URL: https://app.asana.com/0/1177771139624306/1201348868339182/f
Tech Design URL:
CC: @tomasstrba

Description:

This PR updates the app to look for and send .ips crash reports to the backend. The backend is already running the changes needed to interpret this format.

Steps to test this PR:

  1. Enable the Debug menu in production builds, and disable the logic that checks the date before sending crashes, so that you can test this repeatedly - I've added a git patch in the description below that you can apply to do this automatically
  2. Archive a production build, and use the Debug menu to crash it
  3. Wait for the system to prompt you to re-launch the app
  4. Launch the app, review the presented crash report, and send it
  5. Check Asana to verify that the crash was uploaded and that the attached file is what you expect it to be

👇 Git patch attached here 👇

Expand for git patch - save this into `crash_pr.patch` and run `git apply crash_pr.patch`

diff --git a/DuckDuckGo/Crash Reports/Model/CrashReporter.swift b/DuckDuckGo/Crash Reports/Model/CrashReporter.swift
index 9e631b75..007a0ac9 100644
--- a/DuckDuckGo/Crash Reports/Model/CrashReporter.swift
+++ b/DuckDuckGo/Crash Reports/Model/CrashReporter.swift
@@ -33,13 +33,13 @@ final class CrashReporter {

     func checkForNewReports() {

-#if !DEBUG
-
-        guard let lastCheckDate = lastCheckDate else {
-            // Initial run
-            self.lastCheckDate = Date()
-            return
-        }
+//        guard let lastCheckDate = lastCheckDate else {
+//            // Initial run
+//            self.lastCheckDate = Date()
+//            return
+//        }
+
+        let lastCheckDate = Date.distantPast

         let crashReports = reader.getCrashReports(since: lastCheckDate)
         self.lastCheckDate = Date()
@@ -49,13 +49,11 @@ final class CrashReporter {
             return
         }

-        Pixel.fire(.crash)
+        // Pixel.fire(.crash)

         latestCrashReport = latest
         promptPresenter.showPrompt(self, for: latest)

-#endif
-
     }

 }
diff --git a/DuckDuckGo/Menus/MainMenu.swift b/DuckDuckGo/Menus/MainMenu.swift
index 3fce730d..c01dffb0 100644
--- a/DuckDuckGo/Menus/MainMenu.swift
+++ b/DuckDuckGo/Menus/MainMenu.swift
@@ -58,9 +58,9 @@ final class MainMenu: NSMenu {
     @IBOutlet weak var debugMenuItem: NSMenuItem? {
         didSet {
             #if !DEBUG && !REVIEW
-            if let item = debugMenuItem {
-                removeItem(item)
-            }
+//            if let item = debugMenuItem {
+//                removeItem(item)
+//            }
             #endif
         }
     }

Testing checklist:

  • Test with Release configuration

Internal references:

Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM

# By Alistair Brown (9) and others
# Via GitHub
* develop: (36 commits)
  Partial tech debt cleanup (#345)
  Address Bar visual tweaks (#310)
  Bump find-in-page to latest version (#352)
  Bump privacy dashboard to latest version (#349)
  fix popover message bug (#348)
  Add missing next and previous find-in-page button handlers (#351)
  add asserts to check that atb and install date are nil before being set (#350)
  copy private email address (#344)
  Reset tracker info on page change (#335)
  remove history menu and re-home other items (#343)
  Update the credit card model + UI tweaks (#342)
  0.17.6
  Add Usage Pixel (#336)
  Bump find-in-page to latest version (#337)
  Forward delete collision with suffix resolved (#334)
  Avoid using a specific browser as the default. (#341)
  Closing animation duration changed to 0.15 (#333)
  Hiding the favicon view when favicon is nil (#326)
  export bookmarks (#339)
  Ensure ITP database is cleared (#328)
  ...

# Conflicts:
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
# By Alexey Martemyanov (20) and others
# Via Tomas Strba (2) and others
* develop: (63 commits)
  Tweaks of suggestions and autocomplete (#403)
  Bump privacy dashboard to latest version (#409)
  Point to the latest BrowserServicesKit branch. (#414)
  Move embedded TDS from BSK to platform repo (#412)
  Image of shield with dot replaced (#410)
  Expand Fireproofing to include Local Storage and IndexedDB (#408)
  Version 0.18.5
  support privacy config for clickToLoad (#407)
  Automatically select available login (#405)
  initial FB Click to Load (WIP) (#329)
  onboarding updates (#398)
  Version 0.18.4
  Configuration of Sparkle - Setting SUAllowsAutomaticUpdates to NO (#404)
  Hide downloads button if the popover is opened/closed manually (#397)
  Textfield of the homepage is empty and unfocused right after switching to the homepage (#400)
  Remove navigatorCredentials (#392)
  Remove GPC header if it exists when not needed (#366)
  Version 0.18.3
  Fireproofing encrypted storage (#332)
  Fix Lock Screen UI issues (#399)
  ...

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo/Crash Reports/Model/CrashReportSender.swift
* develop:
  Fix non-debug builds (#428)
  new tds url (#430)
  Sparkle 1.27.1 (#411)
  Disable CVDisplayLing logging (#421)
  Update Fire Popover graphics (#426)
  Version 0.18.7
  Refresh the address bar when reloading (#413)
  Fix tabs leakage after Drag-Drop (#423)
  Point to BrowserServicesKit 8.0. (#425)
  Import error improvements (#406)
  Replace Burn and Fireproof icons (#416)
  don't disable the UI unless onboarding has been marked as finished (#420)
  fix nested RunLoop waiting (#422)
  Version 0.18.6
Comment on lines 80 to 81
let patternToReplace = "\"\(itemToFilter)\"\\s*:\\s*\".*\""
let redactedKeyValuePair = "\"\(itemToFilter)\":\"<removed>\""
Copy link
Collaborator Author

@samsymons samsymons Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully my regexes are sensible 🙂 Here's a copy of it on regex101 if you want to play with it.

Copy link
Contributor

@tomasstrba tomasstrba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎖️

This PR is a masterpiece 💯

@tomasstrba tomasstrba assigned samsymons and unassigned tomasstrba Feb 22, 2022
@samsymons samsymons merged commit eea0943 into develop Feb 23, 2022
@samsymons samsymons deleted the sam/macos-12-crash-report-handling branch February 23, 2022 03:29
samsymons added a commit that referenced this pull request Feb 24, 2022
# Via GitHub
* develop:
  Remove the Never option from the Save Credentials VC. (#437)
  Check the current sheets for a lock screen before presenting. (#434)
  macOS 12 crash report handling (#431)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo/SecureVault/View/PasswordManager.storyboard
samsymons added a commit that referenced this pull request Feb 24, 2022
* develop:
  Logins+ filtering and sorting (#427)
  Remove the Never option from the Save Credentials VC. (#437)
  Check the current sheets for a lock screen before presenting. (#434)
  macOS 12 crash report handling (#431)
samsymons added a commit that referenced this pull request Feb 24, 2022
# Via GitHub
* develop:
  Logins+ filtering and sorting (#427)
  Remove the Never option from the Save Credentials VC. (#437)
  Check the current sheets for a lock screen before presenting. (#434)
  macOS 12 crash report handling (#431)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo/AppDelegate/AppDelegate.swift
#	DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
#	DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift
#	DuckDuckGo/SecureVault/Extensions/UserText+PasswordManager.swift
#	DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift
#	DuckDuckGo/SecureVault/View/PasswordManager.storyboard
#	DuckDuckGo/Statistics/PixelArguments.swift
jonathanKingston pushed a commit that referenced this pull request Feb 25, 2022
* Handle macOS 12 crashes.

* TEMP: Changes to allow sending crashes to a dev instance in DEBUG mode.

Revert this!

* Reset the crash reporter service URL.

* Resolve merge conflicts.

* Considering parsing the macOS 12 format.

* Remove the initial parsing code.

* Restore crash pixel.

* Restore the last-check logic.

* Remove more old debugging code.

* Remove more unused changes.

* Use one place for tracking the file extensions.

* Strip out more data.

* Fix up the regex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants