diff options
Diffstat (limited to '')
| -rw-r--r-- | src/common/telemetry.h | 4 | ||||
| -rw-r--r-- | src/core/telemetry_session.cpp | 9 | ||||
| -rw-r--r-- | src/core/telemetry_session.h | 6 | ||||
| -rw-r--r-- | src/web_service/telemetry_json.cpp | 21 | ||||
| -rw-r--r-- | src/web_service/telemetry_json.h | 1 | ||||
| -rw-r--r-- | src/yuzu/compatdb.cpp | 27 | ||||
| -rw-r--r-- | src/yuzu/compatdb.h | 4 |
7 files changed, 65 insertions, 7 deletions
diff --git a/src/common/telemetry.h b/src/common/telemetry.h index 8d6ab986b..854a73fae 100644 --- a/src/common/telemetry.h +++ b/src/common/telemetry.h | |||
| @@ -153,6 +153,7 @@ struct VisitorInterface : NonCopyable { | |||
| 153 | 153 | ||
| 154 | /// Completion method, called once all fields have been visited | 154 | /// Completion method, called once all fields have been visited |
| 155 | virtual void Complete() = 0; | 155 | virtual void Complete() = 0; |
| 156 | virtual bool SubmitTestcase() = 0; | ||
| 156 | }; | 157 | }; |
| 157 | 158 | ||
| 158 | /** | 159 | /** |
| @@ -178,6 +179,9 @@ struct NullVisitor : public VisitorInterface { | |||
| 178 | void Visit(const Field<std::chrono::microseconds>& /*field*/) override {} | 179 | void Visit(const Field<std::chrono::microseconds>& /*field*/) override {} |
| 179 | 180 | ||
| 180 | void Complete() override {} | 181 | void Complete() override {} |
| 182 | bool SubmitTestcase() override { | ||
| 183 | return false; | ||
| 184 | } | ||
| 181 | }; | 185 | }; |
| 182 | 186 | ||
| 183 | /// Appends build-specific information to the given FieldCollection, | 187 | /// Appends build-specific information to the given FieldCollection, |
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 0de13edd3..a3b08c740 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp | |||
| @@ -184,4 +184,13 @@ TelemetrySession::~TelemetrySession() { | |||
| 184 | backend = nullptr; | 184 | backend = nullptr; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | bool TelemetrySession::SubmitTestcase() { | ||
| 188 | #ifdef ENABLE_WEB_SERVICE | ||
| 189 | field_collection.Accept(*backend); | ||
| 190 | return backend->SubmitTestcase(); | ||
| 191 | #else | ||
| 192 | return false; | ||
| 193 | #endif | ||
| 194 | } | ||
| 195 | |||
| 187 | } // namespace Core | 196 | } // namespace Core |
diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h index 2a4845797..023612b79 100644 --- a/src/core/telemetry_session.h +++ b/src/core/telemetry_session.h | |||
| @@ -31,6 +31,12 @@ public: | |||
| 31 | field_collection.AddField(type, name, std::move(value)); | 31 | field_collection.AddField(type, name, std::move(value)); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | /** | ||
| 35 | * Submits a Testcase. | ||
| 36 | * @returns A bool indicating whether the submission succeeded | ||
| 37 | */ | ||
| 38 | bool SubmitTestcase(); | ||
| 39 | |||
| 34 | private: | 40 | private: |
| 35 | Telemetry::FieldCollection field_collection; ///< Tracks all added fields for the session | 41 | Telemetry::FieldCollection field_collection; ///< Tracks all added fields for the session |
| 36 | std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields | 42 | std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields |
diff --git a/src/web_service/telemetry_json.cpp b/src/web_service/telemetry_json.cpp index 0a8f2bd9e..9156ce802 100644 --- a/src/web_service/telemetry_json.cpp +++ b/src/web_service/telemetry_json.cpp | |||
| @@ -102,16 +102,27 @@ void TelemetryJson::Complete() { | |||
| 102 | impl->SerializeSection(Telemetry::FieldType::App, "App"); | 102 | impl->SerializeSection(Telemetry::FieldType::App, "App"); |
| 103 | impl->SerializeSection(Telemetry::FieldType::Session, "Session"); | 103 | impl->SerializeSection(Telemetry::FieldType::Session, "Session"); |
| 104 | impl->SerializeSection(Telemetry::FieldType::Performance, "Performance"); | 104 | impl->SerializeSection(Telemetry::FieldType::Performance, "Performance"); |
| 105 | impl->SerializeSection(Telemetry::FieldType::UserFeedback, "UserFeedback"); | ||
| 106 | impl->SerializeSection(Telemetry::FieldType::UserConfig, "UserConfig"); | 105 | impl->SerializeSection(Telemetry::FieldType::UserConfig, "UserConfig"); |
| 107 | impl->SerializeSection(Telemetry::FieldType::UserSystem, "UserSystem"); | 106 | impl->SerializeSection(Telemetry::FieldType::UserSystem, "UserSystem"); |
| 108 | 107 | ||
| 109 | auto content = impl->TopSection().dump(); | 108 | auto content = impl->TopSection().dump(); |
| 110 | // Send the telemetry async but don't handle the errors since they were written to the log | 109 | // Send the telemetry async but don't handle the errors since they were written to the log |
| 111 | Common::DetachedTasks::AddTask( | 110 | Common::DetachedTasks::AddTask([host{impl->host}, content]() { |
| 112 | [host{impl->host}, username{impl->username}, token{impl->token}, content]() { | 111 | Client{host, "", ""}.PostJson("/telemetry", content, true); |
| 113 | Client{host, username, token}.PostJson("/telemetry", content, true); | 112 | }); |
| 114 | }); | 113 | } |
| 114 | |||
| 115 | bool TelemetryJson::SubmitTestcase() { | ||
| 116 | impl->SerializeSection(Telemetry::FieldType::App, "App"); | ||
| 117 | impl->SerializeSection(Telemetry::FieldType::Session, "Session"); | ||
| 118 | impl->SerializeSection(Telemetry::FieldType::UserFeedback, "UserFeedback"); | ||
| 119 | impl->SerializeSection(Telemetry::FieldType::UserSystem, "UserSystem"); | ||
| 120 | |||
| 121 | auto content = impl->TopSection().dump(); | ||
| 122 | Client client(impl->host, impl->username, impl->token); | ||
| 123 | auto value = client.PostJson("/gamedb/testcase", content, false); | ||
| 124 | |||
| 125 | return value.result_code == Common::WebResult::Code::Success; | ||
| 115 | } | 126 | } |
| 116 | 127 | ||
| 117 | } // namespace WebService | 128 | } // namespace WebService |
diff --git a/src/web_service/telemetry_json.h b/src/web_service/telemetry_json.h index 93371414a..dfd202829 100644 --- a/src/web_service/telemetry_json.h +++ b/src/web_service/telemetry_json.h | |||
| @@ -35,6 +35,7 @@ public: | |||
| 35 | void Visit(const Telemetry::Field<std::chrono::microseconds>& field) override; | 35 | void Visit(const Telemetry::Field<std::chrono::microseconds>& field) override; |
| 36 | 36 | ||
| 37 | void Complete() override; | 37 | void Complete() override; |
| 38 | bool SubmitTestcase() override; | ||
| 38 | 39 | ||
| 39 | private: | 40 | private: |
| 40 | struct Impl; | 41 | struct Impl; |
diff --git a/src/yuzu/compatdb.cpp b/src/yuzu/compatdb.cpp index 91e754274..5f0896f84 100644 --- a/src/yuzu/compatdb.cpp +++ b/src/yuzu/compatdb.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <QButtonGroup> | 5 | #include <QButtonGroup> |
| 6 | #include <QMessageBox> | 6 | #include <QMessageBox> |
| 7 | #include <QPushButton> | 7 | #include <QPushButton> |
| 8 | #include <QtConcurrent/qtconcurrentrun.h> | ||
| 8 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 9 | #include "common/telemetry.h" | 10 | #include "common/telemetry.h" |
| 10 | #include "core/core.h" | 11 | #include "core/core.h" |
| @@ -23,6 +24,8 @@ CompatDB::CompatDB(QWidget* parent) | |||
| 23 | connect(ui->radioButton_IntroMenu, &QRadioButton::clicked, this, &CompatDB::EnableNext); | 24 | connect(ui->radioButton_IntroMenu, &QRadioButton::clicked, this, &CompatDB::EnableNext); |
| 24 | connect(ui->radioButton_WontBoot, &QRadioButton::clicked, this, &CompatDB::EnableNext); | 25 | connect(ui->radioButton_WontBoot, &QRadioButton::clicked, this, &CompatDB::EnableNext); |
| 25 | connect(button(NextButton), &QPushButton::clicked, this, &CompatDB::Submit); | 26 | connect(button(NextButton), &QPushButton::clicked, this, &CompatDB::Submit); |
| 27 | connect(&testcase_watcher, &QFutureWatcher<bool>::finished, this, | ||
| 28 | &CompatDB::OnTestcaseSubmitted); | ||
| 26 | } | 29 | } |
| 27 | 30 | ||
| 28 | CompatDB::~CompatDB() = default; | 31 | CompatDB::~CompatDB() = default; |
| @@ -48,18 +51,38 @@ void CompatDB::Submit() { | |||
| 48 | } | 51 | } |
| 49 | break; | 52 | break; |
| 50 | case CompatDBPage::Final: | 53 | case CompatDBPage::Final: |
| 54 | back(); | ||
| 51 | LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId()); | 55 | LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId()); |
| 52 | Core::Telemetry().AddField(Telemetry::FieldType::UserFeedback, "Compatibility", | 56 | Core::Telemetry().AddField(Telemetry::FieldType::UserFeedback, "Compatibility", |
| 53 | compatibility->checkedId()); | 57 | compatibility->checkedId()); |
| 54 | // older versions of QT don't support the "NoCancelButtonOnLastPage" option, this is a | 58 | |
| 55 | // workaround | 59 | button(NextButton)->setEnabled(false); |
| 60 | button(NextButton)->setText(tr("Submitting")); | ||
| 56 | button(QWizard::CancelButton)->setVisible(false); | 61 | button(QWizard::CancelButton)->setVisible(false); |
| 62 | |||
| 63 | testcase_watcher.setFuture(QtConcurrent::run( | ||
| 64 | [this]() { return Core::System::GetInstance().TelemetrySession().SubmitTestcase(); })); | ||
| 57 | break; | 65 | break; |
| 58 | default: | 66 | default: |
| 59 | LOG_ERROR(Frontend, "Unexpected page: {}", currentId()); | 67 | LOG_ERROR(Frontend, "Unexpected page: {}", currentId()); |
| 60 | } | 68 | } |
| 61 | } | 69 | } |
| 62 | 70 | ||
| 71 | void CompatDB::OnTestcaseSubmitted() { | ||
| 72 | if (!testcase_watcher.result()) { | ||
| 73 | QMessageBox::critical(this, tr("Communication error"), | ||
| 74 | tr("An error occured while sending the Testcase")); | ||
| 75 | button(NextButton)->setEnabled(true); | ||
| 76 | button(NextButton)->setText(tr("Next")); | ||
| 77 | button(QWizard::CancelButton)->setVisible(true); | ||
| 78 | } else { | ||
| 79 | next(); | ||
| 80 | // older versions of QT don't support the "NoCancelButtonOnLastPage" option, this is a | ||
| 81 | // workaround | ||
| 82 | button(QWizard::CancelButton)->setVisible(false); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 63 | void CompatDB::EnableNext() { | 86 | void CompatDB::EnableNext() { |
| 64 | button(NextButton)->setEnabled(true); | 87 | button(NextButton)->setEnabled(true); |
| 65 | } | 88 | } |
diff --git a/src/yuzu/compatdb.h b/src/yuzu/compatdb.h index ca0dd11d6..5381f67f7 100644 --- a/src/yuzu/compatdb.h +++ b/src/yuzu/compatdb.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <QFutureWatcher> | ||
| 8 | #include <QWizard> | 9 | #include <QWizard> |
| 9 | 10 | ||
| 10 | namespace Ui { | 11 | namespace Ui { |
| @@ -19,8 +20,11 @@ public: | |||
| 19 | ~CompatDB(); | 20 | ~CompatDB(); |
| 20 | 21 | ||
| 21 | private: | 22 | private: |
| 23 | QFutureWatcher<bool> testcase_watcher; | ||
| 24 | |||
| 22 | std::unique_ptr<Ui::CompatDB> ui; | 25 | std::unique_ptr<Ui::CompatDB> ui; |
| 23 | 26 | ||
| 24 | void Submit(); | 27 | void Submit(); |
| 28 | void OnTestcaseSubmitted(); | ||
| 25 | void EnableNext(); | 29 | void EnableNext(); |
| 26 | }; | 30 | }; |