Rename autoUpload to shouldUpload
This commit is contained in:
parent
774b2f99f2
commit
7b8eb3e09c
11 changed files with 51 additions and 18 deletions
|
@ -40,6 +40,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
base::Bind(&CrashReporter::Start, report));
|
base::Bind(&CrashReporter::Start, report));
|
||||||
dict.SetMethod("_getUploadedReports",
|
dict.SetMethod("_getUploadedReports",
|
||||||
base::Bind(&CrashReporter::GetUploadedReports, report));
|
base::Bind(&CrashReporter::GetUploadedReports, report));
|
||||||
|
dict.SetMethod("_setShouldUpload",
|
||||||
|
base::Bind(&CrashReporter::SetShouldUpload, report));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -26,13 +26,13 @@ void CrashReporter::Start(const std::string& product_name,
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler,
|
bool skip_system_crash_handler,
|
||||||
const StringMap& extra_parameters) {
|
const StringMap& extra_parameters) {
|
||||||
SetUploadParameters(extra_parameters);
|
SetUploadParameters(extra_parameters);
|
||||||
|
|
||||||
InitBreakpad(product_name, ATOM_VERSION_STRING, company_name, submit_url,
|
InitBreakpad(product_name, ATOM_VERSION_STRING, company_name, submit_url,
|
||||||
crashes_dir, auto_submit, skip_system_crash_handler);
|
crashes_dir, should_upload, skip_system_crash_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrashReporter::SetUploadParameters(const StringMap& parameters) {
|
void CrashReporter::SetUploadParameters(const StringMap& parameters) {
|
||||||
|
@ -43,6 +43,10 @@ void CrashReporter::SetUploadParameters(const StringMap& parameters) {
|
||||||
SetUploadParameters();
|
SetUploadParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CrashReporter::SetShouldUpload(const bool should_upload) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<CrashReporter::UploadReportResult>
|
std::vector<CrashReporter::UploadReportResult>
|
||||||
CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
|
CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
|
||||||
std::string file_content;
|
std::string file_content;
|
||||||
|
|
|
@ -26,7 +26,7 @@ class CrashReporter {
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler,
|
bool skip_system_crash_handler,
|
||||||
const StringMap& extra_parameters);
|
const StringMap& extra_parameters);
|
||||||
|
|
||||||
|
@ -42,10 +42,12 @@ class CrashReporter {
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler);
|
bool skip_system_crash_handler);
|
||||||
virtual void SetUploadParameters();
|
virtual void SetUploadParameters();
|
||||||
|
|
||||||
|
virtual void SetShouldUpload();
|
||||||
|
|
||||||
StringMap upload_parameters_;
|
StringMap upload_parameters_;
|
||||||
bool is_browser_;
|
bool is_browser_;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ void CrashReporterLinux::InitBreakpad(const std::string& product_name,
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler) {
|
bool skip_system_crash_handler) {
|
||||||
EnableCrashDumping(crashes_dir);
|
EnableCrashDumping(crashes_dir);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class CrashReporterLinux : public CrashReporter {
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler) override;
|
bool skip_system_crash_handler) override;
|
||||||
void SetUploadParameters() override;
|
void SetUploadParameters() override;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class CrashReporterMac : public CrashReporter {
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler) override;
|
bool skip_system_crash_handler) override;
|
||||||
void SetUploadParameters() override;
|
void SetUploadParameters() override;
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ class CrashReporterMac : public CrashReporter {
|
||||||
const base::FilePath& crashes_dir) override;
|
const base::FilePath& crashes_dir) override;
|
||||||
|
|
||||||
std::unique_ptr<crashpad::SimpleStringDictionary> simple_string_dictionary_;
|
std::unique_ptr<crashpad::SimpleStringDictionary> simple_string_dictionary_;
|
||||||
|
std::unique_ptr<crashpad::CrashReportDatabase> database_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CrashReporterMac);
|
DISALLOW_COPY_AND_ASSIGN(CrashReporterMac);
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,7 +31,7 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler) {
|
bool skip_system_crash_handler) {
|
||||||
// check whether crashpad has been initialized.
|
// check whether crashpad has been initialized.
|
||||||
// Only need to initialize once.
|
// Only need to initialize once.
|
||||||
|
@ -73,14 +73,20 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
||||||
SetCrashKeyValue(upload_parameter.first, upload_parameter.second);
|
SetCrashKeyValue(upload_parameter.first, upload_parameter.second);
|
||||||
}
|
}
|
||||||
if (is_browser_) {
|
if (is_browser_) {
|
||||||
std::unique_ptr<crashpad::CrashReportDatabase> database =
|
database_ =
|
||||||
crashpad::CrashReportDatabase::Initialize(crashes_dir);
|
crashpad::CrashReportDatabase::Initialize(crashes_dir);
|
||||||
if (database) {
|
if (database_) {
|
||||||
database->GetSettings()->SetUploadsEnabled(auto_submit);
|
database_->GetSettings()->SetUploadsEnabled(should_upload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CrashReporterMac::SetShouldUpload(const bool should_upload) {
|
||||||
|
if (database_) {
|
||||||
|
database_->GetSettings()->SetUploadsEnabled(should_upload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CrashReporterMac::SetUploadParameters() {
|
void CrashReporterMac::SetUploadParameters() {
|
||||||
upload_parameters_["platform"] = "darwin";
|
upload_parameters_["platform"] = "darwin";
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler) {
|
bool skip_system_crash_handler) {
|
||||||
skip_system_crash_handler_ = skip_system_crash_handler;
|
skip_system_crash_handler_ = skip_system_crash_handler;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class CrashReporterWin : public CrashReporter {
|
||||||
const std::string& company_name,
|
const std::string& company_name,
|
||||||
const std::string& submit_url,
|
const std::string& submit_url,
|
||||||
const base::FilePath& crashes_dir,
|
const base::FilePath& crashes_dir,
|
||||||
bool auto_submit,
|
bool should_upload,
|
||||||
bool skip_system_crash_handler) override;
|
bool skip_system_crash_handler) override;
|
||||||
void SetUploadParameters() override;
|
void SetUploadParameters() override;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ The `crashReporter` module has the following methods:
|
||||||
* `companyName` String (optional)
|
* `companyName` String (optional)
|
||||||
* `submitURL` String - URL that crash reports will be sent to as POST.
|
* `submitURL` String - URL that crash reports will be sent to as POST.
|
||||||
* `productName` String (optional) - Defaults to `app.getName()`.
|
* `productName` String (optional) - Defaults to `app.getName()`.
|
||||||
* `autoSubmit` Boolean (optional) - Send the crash report without user interaction.
|
* `shouldUpload` Boolean (optional) _macOS_ - Whether crash reports should be sent to the server
|
||||||
Default is `true`.
|
Default is `true`.
|
||||||
* `ignoreSystemCrashHandler` Boolean (optional) - Default is `false`.
|
* `ignoreSystemCrashHandler` Boolean (optional) - Default is `false`.
|
||||||
* `extra` Object (optional) - An object you can define that will be sent along with the
|
* `extra` Object (optional) - An object you can define that will be sent along with the
|
||||||
|
@ -70,6 +70,12 @@ Returns [`CrashReport[]`](structures/crash-report.md):
|
||||||
Returns all uploaded crash reports. Each report contains the date and uploaded
|
Returns all uploaded crash reports. Each report contains the date and uploaded
|
||||||
ID.
|
ID.
|
||||||
|
|
||||||
|
### `crashReporter.setShouldUpload(shouldUpload)`
|
||||||
|
|
||||||
|
* `shouldUpload` Boolean _macOS_ - Whether reports should be submitted to the server
|
||||||
|
|
||||||
|
This would normally be controlled by user preferences.
|
||||||
|
|
||||||
## Crash Report Payload
|
## Crash Report Payload
|
||||||
|
|
||||||
The crash reporter will send the following data to the `submitURL` as
|
The crash reporter will send the following data to the `submitURL` as
|
||||||
|
|
|
@ -13,10 +13,12 @@ class CrashReporter {
|
||||||
options = {}
|
options = {}
|
||||||
}
|
}
|
||||||
this.productName = options.productName != null ? options.productName : app.getName()
|
this.productName = options.productName != null ? options.productName : app.getName()
|
||||||
let {autoSubmit, companyName, extra, ignoreSystemCrashHandler, submitURL} = options
|
let {autoSubmit, companyName, extra, ignoreSystemCrashHandler, submitURL, shouldUpload} = options
|
||||||
|
|
||||||
if (autoSubmit == null) {
|
if (autoSubmit == null && shouldUpload == null) {
|
||||||
autoSubmit = true
|
shouldUpload = true
|
||||||
|
} else {
|
||||||
|
shouldUpload = shouldUpload || autoSubmit
|
||||||
}
|
}
|
||||||
if (ignoreSystemCrashHandler == null) {
|
if (ignoreSystemCrashHandler == null) {
|
||||||
ignoreSystemCrashHandler = false
|
ignoreSystemCrashHandler = false
|
||||||
|
@ -56,7 +58,8 @@ class CrashReporter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.start(this.getProductName(), companyName, submitURL, this.getCrashesDirectory(), autoSubmit, ignoreSystemCrashHandler, extra)
|
this._shouldUpload = shouldUpload
|
||||||
|
binding.start(this.getProductName(), companyName, submitURL, this.getCrashesDirectory(), shouldUpload, ignoreSystemCrashHandler, extra)
|
||||||
}
|
}
|
||||||
|
|
||||||
getLastCrashReport () {
|
getLastCrashReport () {
|
||||||
|
@ -95,6 +98,15 @@ class CrashReporter {
|
||||||
}
|
}
|
||||||
return this.tempDirectory
|
return this.tempDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getShouldUpload() {
|
||||||
|
return this._shouldUpload
|
||||||
|
}
|
||||||
|
|
||||||
|
setShouldUpload(shouldUpload) {
|
||||||
|
this._shouldUpload = shouldUpload
|
||||||
|
return bindings._setShouldUpload(shouldUpload)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new CrashReporter()
|
module.exports = new CrashReporter()
|
||||||
|
|
Loading…
Reference in a new issue