diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.cpp | 2 | ||||
| -rw-r--r-- | src/core/telemetry_session.cpp | 60 | ||||
| -rw-r--r-- | src/core/telemetry_session.h | 22 |
3 files changed, 54 insertions, 30 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 7106151bd..9f9356f53 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -144,7 +144,6 @@ struct System::Impl { | |||
| 144 | ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, | 144 | ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, |
| 145 | const std::string& filepath) { | 145 | const std::string& filepath) { |
| 146 | app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath)); | 146 | app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath)); |
| 147 | |||
| 148 | if (!app_loader) { | 147 | if (!app_loader) { |
| 149 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); | 148 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); |
| 150 | return ResultStatus::ErrorGetLoader; | 149 | return ResultStatus::ErrorGetLoader; |
| @@ -167,6 +166,7 @@ struct System::Impl { | |||
| 167 | return init_result; | 166 | return init_result; |
| 168 | } | 167 | } |
| 169 | 168 | ||
| 169 | telemetry_session->AddInitialInfo(*app_loader); | ||
| 170 | auto main_process = Kernel::Process::Create(system, "main"); | 170 | auto main_process = Kernel::Process::Create(system, "main"); |
| 171 | const auto [load_result, load_parameters] = app_loader->Load(*main_process); | 171 | const auto [load_result, load_parameters] = app_loader->Load(*main_process); |
| 172 | if (load_result != Loader::ResultStatus::Success) { | 172 | if (load_result != Loader::ResultStatus::Success) { |
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 4b17bada5..4f8aff816 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "common/file_util.h" | 12 | #include "common/file_util.h" |
| 13 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 14 | 14 | ||
| 15 | #include "core/core.h" | ||
| 16 | #include "core/file_sys/control_metadata.h" | 15 | #include "core/file_sys/control_metadata.h" |
| 17 | #include "core/file_sys/patch_manager.h" | 16 | #include "core/file_sys/patch_manager.h" |
| 18 | #include "core/loader/loader.h" | 17 | #include "core/loader/loader.h" |
| @@ -101,7 +100,31 @@ bool VerifyLogin(const std::string& username, const std::string& token) { | |||
| 101 | #endif | 100 | #endif |
| 102 | } | 101 | } |
| 103 | 102 | ||
| 104 | TelemetrySession::TelemetrySession() { | 103 | TelemetrySession::TelemetrySession() = default; |
| 104 | |||
| 105 | TelemetrySession::~TelemetrySession() { | ||
| 106 | // Log one-time session end information | ||
| 107 | const s64 shutdown_time{std::chrono::duration_cast<std::chrono::milliseconds>( | ||
| 108 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 109 | .count()}; | ||
| 110 | AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time); | ||
| 111 | |||
| 112 | #ifdef ENABLE_WEB_SERVICE | ||
| 113 | auto backend = std::make_unique<WebService::TelemetryJson>( | ||
| 114 | Settings::values.web_api_url, Settings::values.yuzu_username, Settings::values.yuzu_token); | ||
| 115 | #else | ||
| 116 | auto backend = std::make_unique<Telemetry::NullVisitor>(); | ||
| 117 | #endif | ||
| 118 | |||
| 119 | // Complete the session, submitting to web service if necessary | ||
| 120 | field_collection.Accept(*backend); | ||
| 121 | if (Settings::values.enable_telemetry) { | ||
| 122 | backend->Complete(); | ||
| 123 | } | ||
| 124 | backend = nullptr; | ||
| 125 | } | ||
| 126 | |||
| 127 | void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) { | ||
| 105 | // Log one-time top-level information | 128 | // Log one-time top-level information |
| 106 | AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId()); | 129 | AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId()); |
| 107 | 130 | ||
| @@ -112,26 +135,28 @@ TelemetrySession::TelemetrySession() { | |||
| 112 | AddField(Telemetry::FieldType::Session, "Init_Time", init_time); | 135 | AddField(Telemetry::FieldType::Session, "Init_Time", init_time); |
| 113 | 136 | ||
| 114 | u64 program_id{}; | 137 | u64 program_id{}; |
| 115 | const Loader::ResultStatus res{System::GetInstance().GetAppLoader().ReadProgramId(program_id)}; | 138 | const Loader::ResultStatus res{app_loader.ReadProgramId(program_id)}; |
| 116 | if (res == Loader::ResultStatus::Success) { | 139 | if (res == Loader::ResultStatus::Success) { |
| 117 | const std::string formatted_program_id{fmt::format("{:016X}", program_id)}; | 140 | const std::string formatted_program_id{fmt::format("{:016X}", program_id)}; |
| 118 | AddField(Telemetry::FieldType::Session, "ProgramId", formatted_program_id); | 141 | AddField(Telemetry::FieldType::Session, "ProgramId", formatted_program_id); |
| 119 | 142 | ||
| 120 | std::string name; | 143 | std::string name; |
| 121 | System::GetInstance().GetAppLoader().ReadTitle(name); | 144 | app_loader.ReadTitle(name); |
| 122 | 145 | ||
| 123 | if (name.empty()) { | 146 | if (name.empty()) { |
| 124 | auto [nacp, icon_file] = FileSys::PatchManager(program_id).GetControlMetadata(); | 147 | auto [nacp, icon_file] = FileSys::PatchManager(program_id).GetControlMetadata(); |
| 125 | if (nacp != nullptr) | 148 | if (nacp != nullptr) { |
| 126 | name = nacp->GetApplicationName(); | 149 | name = nacp->GetApplicationName(); |
| 150 | } | ||
| 127 | } | 151 | } |
| 128 | 152 | ||
| 129 | if (!name.empty()) | 153 | if (!name.empty()) { |
| 130 | AddField(Telemetry::FieldType::Session, "ProgramName", name); | 154 | AddField(Telemetry::FieldType::Session, "ProgramName", name); |
| 155 | } | ||
| 131 | } | 156 | } |
| 132 | 157 | ||
| 133 | AddField(Telemetry::FieldType::Session, "ProgramFormat", | 158 | AddField(Telemetry::FieldType::Session, "ProgramFormat", |
| 134 | static_cast<u8>(System::GetInstance().GetAppLoader().GetFileType())); | 159 | static_cast<u8>(app_loader.GetFileType())); |
| 135 | 160 | ||
| 136 | // Log application information | 161 | // Log application information |
| 137 | Telemetry::AppendBuildInfo(field_collection); | 162 | Telemetry::AppendBuildInfo(field_collection); |
| @@ -162,27 +187,6 @@ TelemetrySession::TelemetrySession() { | |||
| 162 | Settings::values.use_docked_mode); | 187 | Settings::values.use_docked_mode); |
| 163 | } | 188 | } |
| 164 | 189 | ||
| 165 | TelemetrySession::~TelemetrySession() { | ||
| 166 | // Log one-time session end information | ||
| 167 | const s64 shutdown_time{std::chrono::duration_cast<std::chrono::milliseconds>( | ||
| 168 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 169 | .count()}; | ||
| 170 | AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time); | ||
| 171 | |||
| 172 | #ifdef ENABLE_WEB_SERVICE | ||
| 173 | auto backend = std::make_unique<WebService::TelemetryJson>( | ||
| 174 | Settings::values.web_api_url, Settings::values.yuzu_username, Settings::values.yuzu_token); | ||
| 175 | #else | ||
| 176 | auto backend = std::make_unique<Telemetry::NullVisitor>(); | ||
| 177 | #endif | ||
| 178 | |||
| 179 | // Complete the session, submitting to web service if necessary | ||
| 180 | field_collection.Accept(*backend); | ||
| 181 | if (Settings::values.enable_telemetry) | ||
| 182 | backend->Complete(); | ||
| 183 | backend = nullptr; | ||
| 184 | } | ||
| 185 | |||
| 186 | bool TelemetrySession::SubmitTestcase() { | 190 | bool TelemetrySession::SubmitTestcase() { |
| 187 | #ifdef ENABLE_WEB_SERVICE | 191 | #ifdef ENABLE_WEB_SERVICE |
| 188 | auto backend = std::make_unique<WebService::TelemetryJson>( | 192 | auto backend = std::make_unique<WebService::TelemetryJson>( |
diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h index 7d0c8d413..17ac22377 100644 --- a/src/core/telemetry_session.h +++ b/src/core/telemetry_session.h | |||
| @@ -7,6 +7,10 @@ | |||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include "common/telemetry.h" | 8 | #include "common/telemetry.h" |
| 9 | 9 | ||
| 10 | namespace Loader { | ||
| 11 | class AppLoader; | ||
| 12 | } | ||
| 13 | |||
| 10 | namespace Core { | 14 | namespace Core { |
| 11 | 15 | ||
| 12 | /** | 16 | /** |
| @@ -16,7 +20,7 @@ namespace Core { | |||
| 16 | */ | 20 | */ |
| 17 | class TelemetrySession { | 21 | class TelemetrySession { |
| 18 | public: | 22 | public: |
| 19 | TelemetrySession(); | 23 | explicit TelemetrySession(); |
| 20 | ~TelemetrySession(); | 24 | ~TelemetrySession(); |
| 21 | 25 | ||
| 22 | TelemetrySession(const TelemetrySession&) = delete; | 26 | TelemetrySession(const TelemetrySession&) = delete; |
| @@ -26,6 +30,22 @@ public: | |||
| 26 | TelemetrySession& operator=(TelemetrySession&&) = delete; | 30 | TelemetrySession& operator=(TelemetrySession&&) = delete; |
| 27 | 31 | ||
| 28 | /** | 32 | /** |
| 33 | * Adds the initial telemetry info necessary when starting up a title. | ||
| 34 | * | ||
| 35 | * This includes information such as: | ||
| 36 | * - Telemetry ID | ||
| 37 | * - Initialization time | ||
| 38 | * - Title ID | ||
| 39 | * - Title name | ||
| 40 | * - Title file format | ||
| 41 | * - Miscellaneous settings values. | ||
| 42 | * | ||
| 43 | * @param app_loader The application loader to use to retrieve | ||
| 44 | * title-specific information. | ||
| 45 | */ | ||
| 46 | void AddInitialInfo(Loader::AppLoader& app_loader); | ||
| 47 | |||
| 48 | /** | ||
| 29 | * Wrapper around the Telemetry::FieldCollection::AddField method. | 49 | * Wrapper around the Telemetry::FieldCollection::AddField method. |
| 30 | * @param type Type of the field to add. | 50 | * @param type Type of the field to add. |
| 31 | * @param name Name of the field to add. | 51 | * @param name Name of the field to add. |