From 6542be09ee7619fcf05d9eb8d0f2c2a2ecb880e6 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Fri, 10 Sep 2021 15:53:08 +0300 Subject: [PATCH] Clarify what sentry sends, add a way to turn off the warning --- include/Common.h | 4 +++- src/TConfig.cpp | 11 ++++++++++- src/TSentry.cpp | 18 +++++++++++++++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/include/Common.h b/include/Common.h index 3897bbb..99c39bf 100644 --- a/include/Common.h +++ b/include/Common.h @@ -31,7 +31,8 @@ public: , MaxCars(1) , DebugModeEnabled(false) , Port(30814) - , SendErrors(true) { } + , SendErrors(true) + , SendErrorsMessageEnabled(true) { } std::string ServerName; std::string ServerDesc; std::string Resource; @@ -44,6 +45,7 @@ public: int Port; std::string CustomIP; bool SendErrors; + bool SendErrorsMessageEnabled; [[nodiscard]] bool HasCustomIP() const { return !CustomIP.empty(); } }; using TShutdownHandler = std::function; diff --git a/src/TConfig.cpp b/src/TConfig.cpp index 5132a66..fa3bb5d 100644 --- a/src/TConfig.cpp +++ b/src/TConfig.cpp @@ -19,6 +19,7 @@ static constexpr std::string_view StrDescription = "Description"; static constexpr std::string_view StrResourceFolder = "ResourceFolder"; static constexpr std::string_view StrAuthKey = "AuthKey"; static constexpr std::string_view StrSendErrors = "SendErrors"; +static constexpr std::string_view StrSendErrorsMessageEnabled = "SendErrorsShowMessage"; TConfig::TConfig() { if (!fs::exists(ConfigFileName) || !fs::is_regular_file(ConfigFileName)) { @@ -35,7 +36,9 @@ TConfig::TConfig() { void WriteSendErrors(const std::string& name) { std::ofstream CfgFile { name, std::ios::out | std::ios::app }; - CfgFile << "# If SendErrors is `true`, the server will send helpful info about crashes and other issues back to the BeamMP developers. This info may include your config, who is on your server at the time of the error, and similar data. You can opt-out of this system by setting this to `false`." + CfgFile << "# You can turn on/off the SendErrors message you get on startup here" << std::endl + << StrSendErrorsMessageEnabled << " = true" << std::endl + << "# If SendErrors is `true`, the server will send helpful info about crashes and other issues back to the BeamMP developers. This info may include your config, who is on your server at the time of the error, and similar general information. This kind of data is vital in helping us diagnose and fix issues faster. This has no impact on server performance. You can opt-out of this system by setting this to `false`." << std::endl << StrSendErrors << " = true" << std::endl; } @@ -150,6 +153,12 @@ void TConfig::ParseFromFile(std::string_view name) { // dont throw, instead write it into the file and use default WriteSendErrors(std::string(name)); } + if (auto val = GeneralTable[StrSendErrorsMessageEnabled].value(); val.has_value()) { + Application::Settings.SendErrorsMessageEnabled = val.value(); + } else { + // no idea what to do here, ignore...? + // this entire toml parser sucks and is replaced in the upcoming lua. + } } catch (const std::exception& err) { error("Error parsing config file value: " + std::string(err.what())); mFailed = true; diff --git a/src/TSentry.cpp b/src/TSentry.cpp index d09df92..ab20e31 100644 --- a/src/TSentry.cpp +++ b/src/TSentry.cpp @@ -36,12 +36,24 @@ void TSentry::PrintWelcome() { if (mValid) { if (!Application::Settings.SendErrors) { mValid = false; - info("Opted out of error reporting (SendErrors), Sentry disabled."); + if (Application::Settings.SendErrorsMessageEnabled) { + info("Opted out of error reporting (SendErrors), Sentry disabled."); + } else { + info("Sentry disabled"); + } } else { - info("Sentry started! Reporting errors automatically. You can opt-out of this in the ServerConfig."); + if (Application::Settings.SendErrorsMessageEnabled) { + info("Sentry started! Reporting errors automatically. This sends data to the developers in case of errors and crashes. You can learn more, turn this message off or opt-out of this in the ServerConfig.toml."); + } else { + info("Sentry started"); + } } } else { - info("Sentry disabled in unofficial build. Automatic error reporting disabled."); + if (Application::Settings.SendErrorsMessageEnabled) { + info("Sentry disabled in unofficial build. Automatic error reporting disabled."); + } else { + info("Sentry disabled in unofficial build"); + } } }