mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-03-27 06:20:08 +01:00
✨ Show modal about crash
This commit is contained in:
@@ -3901,7 +3901,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1667;
|
||||
CURRENT_PROJECT_VERSION = 1669;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = YES;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
@@ -3945,7 +3945,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1667;
|
||||
CURRENT_PROJECT_VERSION = 1669;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = NO;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
@@ -4127,7 +4127,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1667;
|
||||
CURRENT_PROJECT_VERSION = 1669;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = YES;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
@@ -4320,7 +4320,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1667;
|
||||
CURRENT_PROJECT_VERSION = 1669;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = NO;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
import Foundation
|
||||
import CrashReporter
|
||||
import NVAlert
|
||||
import AppKit
|
||||
|
||||
class CrashReporter {
|
||||
|
||||
@@ -32,27 +34,61 @@ class CrashReporter {
|
||||
}
|
||||
|
||||
if crashReporter.hasPendingCrashReport() {
|
||||
CrashReporter.requestSendingCrashReport(crashReporter)
|
||||
Task { @MainActor in
|
||||
CrashReporter.requestSendingCrashReport(crashReporter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func requestSendingCrashReport(_ crashReporter: PLCrashReporter) {
|
||||
/**
|
||||
If a pending crash report can be sent, show an alert to the user.
|
||||
*/
|
||||
@MainActor static func requestSendingCrashReport(_ crashReporter: PLCrashReporter) {
|
||||
do {
|
||||
let data = try crashReporter.loadPendingCrashReportDataAndReturnError()
|
||||
let report = try PLCrashReport(data: data)
|
||||
|
||||
if let text = PLCrashReportTextFormatter.stringValue(for: report, with: PLCrashReportTextFormatiOS) {
|
||||
submitCrashReportToApi(text)
|
||||
// Ask the user to submit the crash report
|
||||
let response = NVAlert().withInformation(
|
||||
title: "crash_reporter.title".localized,
|
||||
subtitle: "crash_reporter.subtitle".localized,
|
||||
description: "crash_reporter.description".localized
|
||||
)
|
||||
.withTertiary(text: "", action: { _ in
|
||||
try? text.write(toFile: "/tmp/pm_crash_log.txt", atomically: true, encoding: .utf8)
|
||||
let fileUrl = URL(string: "file:///private/tmp/pm_crash_log.txt")!
|
||||
NSWorkspace.shared.open(fileUrl)
|
||||
})
|
||||
.withSecondary(text: "crash_reporter.do_not_send".localized, action: { alert in
|
||||
alert.close(with: .abort)
|
||||
})
|
||||
.withPrimary(text: "crash_reporter.send_report".localized, action: { alert in
|
||||
alert.close(with: .OK)
|
||||
}).runModal()
|
||||
|
||||
if response == .abort {
|
||||
Log.warn("[CrashReporter] The user has chosen not to send the report.")
|
||||
crashReporter.purgePendingCrashReport()
|
||||
}
|
||||
if response == .OK {
|
||||
submitCrashReportToApi(text)
|
||||
crashReporter.purgePendingCrashReport()
|
||||
}
|
||||
} else {
|
||||
Log.err("[CrashReporter] Could not convert report to text.")
|
||||
crashReporter.purgePendingCrashReport()
|
||||
}
|
||||
} catch let error {
|
||||
Log.err("[CrashReporter] Failed to load and parse with error: \(error)")
|
||||
crashReporter.purgePendingCrashReport()
|
||||
}
|
||||
|
||||
crashReporter.purgePendingCrashReport()
|
||||
}
|
||||
|
||||
/**
|
||||
Submits the crash report to the API. Does this with high priority on the main thread
|
||||
and we wait for completion (w/ a DispatchSemaphore) before continuing boot.
|
||||
*/
|
||||
private static func submitCrashReportToApi(_ text: String) {
|
||||
let timeout = TimeInterval.seconds(10)
|
||||
|
||||
|
||||
@@ -190,6 +190,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
||||
// MARK: - Menu Item Functionality
|
||||
|
||||
@objc func openAbout() {
|
||||
fatalError("Woof we intentionally crashed")
|
||||
NSApplication.shared.activate(ignoringOtherApps: true)
|
||||
NSApplication.shared.orderFrontStandardAboutPanel(self)
|
||||
}
|
||||
|
||||
@@ -932,3 +932,9 @@ If you want to make edits to this file, please do so before upgrading. When you
|
||||
PHP Monitor will tell Valet to unsecure and re-secure all expired domains for you. This can take a while, as nginx may be restarted a few times if multiple domains need to be re-secured.";
|
||||
"cert_alert.renew" = "Re-secure Domain(s)";
|
||||
"cert_alert.cancel" = "Not Now";
|
||||
|
||||
"crash_reporter.title" = "PHP Monitor crashed earlier, want to send a crash report?";
|
||||
"crash_reporter.subtitle" = "It is possible to send the crash report to the developer of the app, so this issue can be fixed. This is highly recommended. Would you like to do that?";
|
||||
"crash_reporter.description" = "Without sending this crash report, the developer may not be aware of this particular issue. No logs or personal data is sent with the crash report, only the unsymbolicated crash report. No further action is necessary on your part.";
|
||||
"crash_reporter.send_report" = "Send Report";
|
||||
"crash_reporter.do_not_send" = "Don't Send";
|
||||
|
||||
Reference in New Issue
Block a user