summaryrefslogtreecommitdiffstats
path: root/src/core/telemetry_session.cpp
diff options
context:
space:
mode:
authorZach Hilman <DarkLordZach@users.noreply.github.com>2019-06-05 21:57:48 +0200
committerGitHub <noreply@github.com>2019-06-05 21:57:48 +0200
commit799302bc9d6edade951cf7746314d96d440c823c (patch)
tree0fd074d6ab32ef2b2590bdd0c21302784976d653 /src/core/telemetry_session.cpp
parentMerge pull request #2545 from lioncash/timing (diff)
parentcore/core: Remove unnecessary includes (diff)
downloadyuzu-799302bc9d6edade951cf7746314d96d440c823c.tar
yuzu-799302bc9d6edade951cf7746314d96d440c823c.tar.gz
yuzu-799302bc9d6edade951cf7746314d96d440c823c.tar.bz2
yuzu-799302bc9d6edade951cf7746314d96d440c823c.tar.lz
yuzu-799302bc9d6edade951cf7746314d96d440c823c.tar.xz
yuzu-799302bc9d6edade951cf7746314d96d440c823c.tar.zst
yuzu-799302bc9d6edade951cf7746314d96d440c823c.zip
Diffstat (limited to 'src/core/telemetry_session.cpp')
-rw-r--r--src/core/telemetry_session.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp
index 4b17bada5..90d06830f 100644
--- a/src/core/telemetry_session.cpp
+++ b/src/core/telemetry_session.cpp
@@ -12,7 +12,6 @@
#include "common/file_util.h"
#include "common/logging/log.h"
-#include "core/core.h"
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
#include "core/loader/loader.h"
@@ -101,7 +100,30 @@ bool VerifyLogin(const std::string& username, const std::string& token) {
#endif
}
-TelemetrySession::TelemetrySession() {
+TelemetrySession::TelemetrySession() = default;
+
+TelemetrySession::~TelemetrySession() {
+ // Log one-time session end information
+ const s64 shutdown_time{std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch())
+ .count()};
+ AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time);
+
+#ifdef ENABLE_WEB_SERVICE
+ auto backend = std::make_unique<WebService::TelemetryJson>(
+ Settings::values.web_api_url, Settings::values.yuzu_username, Settings::values.yuzu_token);
+#else
+ auto backend = std::make_unique<Telemetry::NullVisitor>();
+#endif
+
+ // Complete the session, submitting to the web service backend if necessary
+ field_collection.Accept(*backend);
+ if (Settings::values.enable_telemetry) {
+ backend->Complete();
+ }
+}
+
+void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) {
// Log one-time top-level information
AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId());
@@ -112,26 +134,28 @@ TelemetrySession::TelemetrySession() {
AddField(Telemetry::FieldType::Session, "Init_Time", init_time);
u64 program_id{};
- const Loader::ResultStatus res{System::GetInstance().GetAppLoader().ReadProgramId(program_id)};
+ const Loader::ResultStatus res{app_loader.ReadProgramId(program_id)};
if (res == Loader::ResultStatus::Success) {
const std::string formatted_program_id{fmt::format("{:016X}", program_id)};
AddField(Telemetry::FieldType::Session, "ProgramId", formatted_program_id);
std::string name;
- System::GetInstance().GetAppLoader().ReadTitle(name);
+ app_loader.ReadTitle(name);
if (name.empty()) {
auto [nacp, icon_file] = FileSys::PatchManager(program_id).GetControlMetadata();
- if (nacp != nullptr)
+ if (nacp != nullptr) {
name = nacp->GetApplicationName();
+ }
}
- if (!name.empty())
+ if (!name.empty()) {
AddField(Telemetry::FieldType::Session, "ProgramName", name);
+ }
}
AddField(Telemetry::FieldType::Session, "ProgramFormat",
- static_cast<u8>(System::GetInstance().GetAppLoader().GetFileType()));
+ static_cast<u8>(app_loader.GetFileType()));
// Log application information
Telemetry::AppendBuildInfo(field_collection);
@@ -162,27 +186,6 @@ TelemetrySession::TelemetrySession() {
Settings::values.use_docked_mode);
}
-TelemetrySession::~TelemetrySession() {
- // Log one-time session end information
- const s64 shutdown_time{std::chrono::duration_cast<std::chrono::milliseconds>(
- std::chrono::system_clock::now().time_since_epoch())
- .count()};
- AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time);
-
-#ifdef ENABLE_WEB_SERVICE
- auto backend = std::make_unique<WebService::TelemetryJson>(
- Settings::values.web_api_url, Settings::values.yuzu_username, Settings::values.yuzu_token);
-#else
- auto backend = std::make_unique<Telemetry::NullVisitor>();
-#endif
-
- // Complete the session, submitting to web service if necessary
- field_collection.Accept(*backend);
- if (Settings::values.enable_telemetry)
- backend->Complete();
- backend = nullptr;
-}
-
bool TelemetrySession::SubmitTestcase() {
#ifdef ENABLE_WEB_SERVICE
auto backend = std::make_unique<WebService::TelemetryJson>(