diff options
author | bunnei <bunneidev@gmail.com> | 2017-08-23 06:08:07 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2017-08-26 05:10:02 +0200 |
commit | 9f0da33c3349df47580d93fcd25346be4d2b94a7 (patch) | |
tree | d981fbe3cf164598a2459cc02d74e8e9fa8df191 /src/core | |
parent | default_ini: Use correct telemetry endpoint URL. (diff) | |
download | yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.tar yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.tar.gz yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.tar.bz2 yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.tar.lz yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.tar.xz yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.tar.zst yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/telemetry_session.cpp | 19 | ||||
-rw-r--r-- | src/core/telemetry_session.h | 12 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 61ba78457..d0f257f58 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -38,21 +38,21 @@ static u64 GenerateTelemetryId() { return telemetry_id; } -static u64 GetTelemetryId() { +u64 GetTelemetryId() { u64 telemetry_id{}; static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; if (FileUtil::Exists(filename)) { FileUtil::IOFile file(filename, "rb"); if (!file.IsOpen()) { - LOG_ERROR(WebService, "failed to open telemetry_id: %s", filename.c_str()); + LOG_ERROR(Core, "failed to open telemetry_id: %s", filename.c_str()); return {}; } file.ReadBytes(&telemetry_id, sizeof(u64)); } else { FileUtil::IOFile file(filename, "wb"); if (!file.IsOpen()) { - LOG_ERROR(WebService, "failed to open telemetry_id: %s", filename.c_str()); + LOG_ERROR(Core, "failed to open telemetry_id: %s", filename.c_str()); return {}; } telemetry_id = GenerateTelemetryId(); @@ -62,6 +62,19 @@ static u64 GetTelemetryId() { return telemetry_id; } +u64 RegenerateTelemetryId() { + const u64 new_telemetry_id{GenerateTelemetryId()}; + static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; + + FileUtil::IOFile file(filename, "wb"); + if (!file.IsOpen()) { + LOG_ERROR(Core, "failed to open telemetry_id: %s", filename.c_str()); + return {}; + } + file.WriteBytes(&new_telemetry_id, sizeof(u64)); + return new_telemetry_id; +} + TelemetrySession::TelemetrySession() { #ifdef ENABLE_WEB_SERVICE backend = std::make_unique<WebService::TelemetryJson>(); diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h index cf53835c3..65613daae 100644 --- a/src/core/telemetry_session.h +++ b/src/core/telemetry_session.h @@ -35,4 +35,16 @@ private: std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields }; +/** + * Gets TelemetryId, a unique identifier used for the user's telemetry sessions. + * @returns The current TelemetryId for the session. + */ +u64 GetTelemetryId(); + +/** + * Regenerates TelemetryId, a unique identifier used for the user's telemetry sessions. + * @returns The new TelemetryId that was generated. + */ +u64 RegenerateTelemetryId(); + } // namespace Core |