remove the telemetry except from the renderers as I'm not being capable to remove it from there

This commit is contained in:
Miguel 2024-03-27 16:17:58 +01:00 committed by GitHub
parent a442389a60
commit 0789b45307
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 12 additions and 886 deletions

View file

@ -39,7 +39,6 @@
#include "core/hle/service/am/am.h" #include "core/hle/service/am/am.h"
#include "core/hle/service/cfg/cfg.h" #include "core/hle/service/cfg/cfg.h"
#include "core/movie.h" #include "core/movie.h"
#include "core/telemetry_session.h"
#include "input_common/main.h" #include "input_common/main.h"
#include "network/network.h" #include "network/network.h"
#include "video_core/gpu.h" #include "video_core/gpu.h"
@ -436,8 +435,6 @@ int main(int argc, char** argv) {
break; break;
} }
system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "SDL");
if (use_multiplayer) { if (use_multiplayer) {
if (auto member = Network::GetRoomMember().lock()) { if (auto member = Network::GetRoomMember().lock()) {
member->BindOnChatMessageRecieved(OnMessageReceived); member->BindOnChatMessageRecieved(OnMessageReceived);

View file

@ -7,14 +7,12 @@
#include <QPushButton> #include <QPushButton>
#include <QtConcurrent/qtconcurrentrun.h> #include <QtConcurrent/qtconcurrentrun.h>
#include "citra_qt/compatdb.h" #include "citra_qt/compatdb.h"
#include "common/telemetry.h"
#include "core/core.h" #include "core/core.h"
#include "core/telemetry_session.h"
#include "ui_compatdb.h" #include "ui_compatdb.h"
CompatDB::CompatDB(Core::TelemetrySession& telemetry_session_, QWidget* parent) CompatDB::CompatDB(QWidget* parent)
: QWizard(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), : QWizard(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
ui{std::make_unique<Ui::CompatDB>()}, telemetry_session{telemetry_session_} { ui{std::make_unique<Ui::CompatDB>()} {
ui->setupUi(this); ui->setupUi(this);
connect(ui->radioButton_Perfect, &QRadioButton::clicked, this, &CompatDB::EnableNext); connect(ui->radioButton_Perfect, &QRadioButton::clicked, this, &CompatDB::EnableNext);
connect(ui->radioButton_Great, &QRadioButton::clicked, this, &CompatDB::EnableNext); connect(ui->radioButton_Great, &QRadioButton::clicked, this, &CompatDB::EnableNext);
@ -52,15 +50,11 @@ void CompatDB::Submit() {
case CompatDBPage::Final: case CompatDBPage::Final:
back(); back();
LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId()); LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId());
telemetry_session.AddField(Common::Telemetry::FieldType::UserFeedback, "Compatibility",
compatibility->checkedId());
button(NextButton)->setEnabled(false); button(NextButton)->setEnabled(false);
button(NextButton)->setText(tr("Submitting")); button(NextButton)->setText(tr("Submitting"));
button(CancelButton)->setVisible(false); button(CancelButton)->setVisible(false);
testcase_watcher.setFuture(
QtConcurrent::run([this] { return telemetry_session.SubmitTestcase(); }));
break; break;
default: default:
LOG_ERROR(Frontend, "Unexpected page: {}", currentId()); LOG_ERROR(Frontend, "Unexpected page: {}", currentId());

View file

@ -8,10 +8,6 @@
#include <QFutureWatcher> #include <QFutureWatcher>
#include <QWizard> #include <QWizard>
namespace Core {
class TelemetrySession;
}
namespace Ui { namespace Ui {
class CompatDB; class CompatDB;
} }
@ -20,7 +16,7 @@ class CompatDB : public QWizard {
Q_OBJECT Q_OBJECT
public: public:
explicit CompatDB(Core::TelemetrySession& telemetry_session_, QWidget* parent = nullptr); explicit CompatDB(QWidget* parent = nullptr);
~CompatDB(); ~CompatDB();
private: private:
@ -31,6 +27,4 @@ private:
void Submit(); void Submit();
void OnTestcaseSubmitted(); void OnTestcaseSubmitted();
void EnableNext(); void EnableNext();
Core::TelemetrySession& telemetry_session;
}; };

View file

@ -7,7 +7,6 @@
#include <QtConcurrent/QtConcurrentRun> #include <QtConcurrent/QtConcurrentRun>
#include "citra_qt/configuration/configure_web.h" #include "citra_qt/configuration/configure_web.h"
#include "citra_qt/uisettings.h" #include "citra_qt/uisettings.h"
#include "core/telemetry_session.h"
#include "network/network_settings.h" #include "network/network_settings.h"
#include "ui_configure_web.h" #include "ui_configure_web.h"
@ -39,8 +38,6 @@ static std::string TokenFromDisplayToken(const std::string& display_token) {
ConfigureWeb::ConfigureWeb(QWidget* parent) ConfigureWeb::ConfigureWeb(QWidget* parent)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureWeb>()) { : QWidget(parent), ui(std::make_unique<Ui::ConfigureWeb>()) {
ui->setupUi(this); ui->setupUi(this);
connect(ui->button_regenerate_telemetry_id, &QPushButton::clicked, this,
&ConfigureWeb::RefreshTelemetryID);
connect(ui->button_verify_login, &QPushButton::clicked, this, &ConfigureWeb::VerifyLogin); connect(ui->button_verify_login, &QPushButton::clicked, this, &ConfigureWeb::VerifyLogin);
connect(&verify_watcher, &QFutureWatcher<bool>::finished, this, &ConfigureWeb::OnLoginVerified); connect(&verify_watcher, &QFutureWatcher<bool>::finished, this, &ConfigureWeb::OnLoginVerified);
@ -54,12 +51,6 @@ ConfigureWeb::~ConfigureWeb() = default;
void ConfigureWeb::SetConfiguration() { void ConfigureWeb::SetConfiguration() {
ui->web_credentials_disclaimer->setWordWrap(true); ui->web_credentials_disclaimer->setWordWrap(true);
ui->telemetry_learn_more->setOpenExternalLinks(true);
ui->telemetry_learn_more->setText(tr("<a "
"href='https://citra-emu.org/entry/"
"telemetry-and-why-thats-a-good-thing/'><span "
"style=\"text-decoration: underline; "
"color:#039be5;\">Learn more</span></a>"));
ui->web_signup_link->setOpenExternalLinks(true); ui->web_signup_link->setOpenExternalLinks(true);
ui->web_signup_link->setText( ui->web_signup_link->setText(
@ -70,8 +61,6 @@ void ConfigureWeb::SetConfiguration() {
tr("<a href='https://citra-emu.org/wiki/citra-web-service/'><span style=\"text-decoration: " tr("<a href='https://citra-emu.org/wiki/citra-web-service/'><span style=\"text-decoration: "
"underline; color:#039be5;\">What is my token?</span></a>")); "underline; color:#039be5;\">What is my token?</span></a>"));
ui->toggle_telemetry->setChecked(NetSettings::values.enable_telemetry);
if (NetSettings::values.citra_username.empty()) { if (NetSettings::values.citra_username.empty()) {
ui->username->setText(tr("Unspecified")); ui->username->setText(tr("Unspecified"));
} else { } else {
@ -83,15 +72,11 @@ void ConfigureWeb::SetConfiguration() {
// Connect after setting the values, to avoid calling OnLoginChanged now // Connect after setting the values, to avoid calling OnLoginChanged now
connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged);
ui->label_telemetry_id->setText(
tr("Telemetry ID: 0x%1").arg(QString::number(Core::GetTelemetryId(), 16).toUpper()));
user_verified = true; user_verified = true;
ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence.GetValue()); ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence.GetValue());
} }
void ConfigureWeb::ApplyConfiguration() { void ConfigureWeb::ApplyConfiguration() {
NetSettings::values.enable_telemetry = ui->toggle_telemetry->isChecked();
UISettings::values.enable_discord_presence = ui->toggle_discordrpc->isChecked(); UISettings::values.enable_discord_presence = ui->toggle_discordrpc->isChecked();
if (user_verified) { if (user_verified) {
NetSettings::values.citra_username = NetSettings::values.citra_username =
@ -105,12 +90,6 @@ void ConfigureWeb::ApplyConfiguration() {
} }
} }
void ConfigureWeb::RefreshTelemetryID() {
const u64 new_telemetry_id{Core::RegenerateTelemetryId()};
ui->label_telemetry_id->setText(
tr("Telemetry ID: 0x%1").arg(QString::number(new_telemetry_id, 16).toUpper()));
}
void ConfigureWeb::OnLoginChanged() { void ConfigureWeb::OnLoginChanged() {
if (ui->edit_token->text().isEmpty()) { if (ui->edit_token->text().isEmpty()) {
user_verified = true; user_verified = true;
@ -131,7 +110,12 @@ void ConfigureWeb::VerifyLogin() {
verify_watcher.setFuture(QtConcurrent::run( verify_watcher.setFuture(QtConcurrent::run(
[username = UsernameFromDisplayToken(ui->edit_token->text().toStdString()), [username = UsernameFromDisplayToken(ui->edit_token->text().toStdString()),
token = TokenFromDisplayToken(ui->edit_token->text().toStdString())] { token = TokenFromDisplayToken(ui->edit_token->text().toStdString())] {
return Core::VerifyLogin(username, token); #ifdef ENABLE_WEB_SERVICE
return WebService::VerifyLogin(Settings::values.web_api_url.GetValue(), username,
token);
#else
return false;
#endif
})); }));
} }

View file

@ -25,7 +25,6 @@ public:
void SetWebServiceConfigEnabled(bool enabled); void SetWebServiceConfigEnabled(bool enabled);
private: private:
void RefreshTelemetryID();
void OnLoginChanged(); void OnLoginChanged();
void VerifyLogin(); void VerifyLogin();
void OnLoginVerified(); void OnLoginVerified();

View file

@ -119,56 +119,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Telemetry</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="toggle_telemetry">
<property name="text">
<string>Share anonymous usage data with the Citra team</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="telemetry_learn_more">
<property name="text">
<string>Learn more</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayoutTelemetryId">
<item row="0" column="0">
<widget class="QLabel" name="label_telemetry_id">
<property name="text">
<string>Telemetry ID:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="button_regenerate_telemetry_id">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Regenerate</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View file

@ -15,7 +15,6 @@
#include <QtGui> #include <QtGui>
#include <QtWidgets> #include <QtWidgets>
#include <fmt/format.h> #include <fmt/format.h>
#include "core/telemetry_session.h"
#ifdef __APPLE__ #ifdef __APPLE__
#include <unistd.h> // for chdir #include <unistd.h> // for chdir
#endif #endif
@ -128,27 +127,6 @@ constexpr int default_mouse_timeout = 2500;
* is a bitfield "callout_flags" options, used to track if a message has already been shown to the * is a bitfield "callout_flags" options, used to track if a message has already been shown to the
* user. This is 32-bits - if we have more than 32 callouts, we should retire and recycle old ones. * user. This is 32-bits - if we have more than 32 callouts, we should retire and recycle old ones.
*/ */
enum class CalloutFlag : uint32_t {
Telemetry = 0x1,
};
void GMainWindow::ShowTelemetryCallout() {
if (UISettings::values.callout_flags.GetValue() &
static_cast<uint32_t>(CalloutFlag::Telemetry)) {
return;
}
UISettings::values.callout_flags =
UISettings::values.callout_flags.GetValue() | static_cast<uint32_t>(CalloutFlag::Telemetry);
const QString telemetry_message =
tr("<a href='https://citra-emu.org/entry/telemetry-and-why-thats-a-good-thing/'>Anonymous "
"data is collected</a> to help improve Citra. "
"<br/><br/>Would you like to share your usage data with us?");
if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) == QMessageBox::Yes) {
NetSettings::values.enable_telemetry = true;
system.ApplySettings();
}
}
const int GMainWindow::max_recent_files_item; const int GMainWindow::max_recent_files_item;
@ -263,9 +241,6 @@ GMainWindow::GMainWindow(Core::System& system_)
game_list->LoadCompatibilityList(); game_list->LoadCompatibilityList();
game_list->PopulateAsync(UISettings::values.game_dirs); game_list->PopulateAsync(UISettings::values.game_dirs);
// Show one-time "callout" messages to the user
ShowTelemetryCallout();
mouse_hide_timer.setInterval(default_mouse_timeout); mouse_hide_timer.setInterval(default_mouse_timeout);
connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::OnMouseActivity); connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::OnMouseActivity);
@ -1244,7 +1219,6 @@ bool GMainWindow::LoadROM(const QString& filename) {
game_path = filename; game_path = filename;
system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt");
return true; return true;
} }
@ -1988,7 +1962,7 @@ void GMainWindow::OnLoadComplete() {
void GMainWindow::OnMenuReportCompatibility() { void GMainWindow::OnMenuReportCompatibility() {
if (!NetSettings::values.citra_token.empty() && !NetSettings::values.citra_username.empty()) { if (!NetSettings::values.citra_token.empty() && !NetSettings::values.citra_username.empty()) {
CompatDB compatdb{system.TelemetrySession(), this}; CompatDB compatdb{this};
compatdb.exec(); compatdb.exec();
} else { } else {
QMessageBox::critical(this, tr("Missing Citra Account"), QMessageBox::critical(this, tr("Missing Citra Account"),
@ -3241,3 +3215,4 @@ int main(int argc, char* argv[]) {
detached_tasks.WaitForAllTasks(); detached_tasks.WaitForAllTasks();
return result; return result;
} }

View file

@ -130,8 +130,6 @@ add_library(citra_common STATIC
string_util.cpp string_util.cpp
string_util.h string_util.h
swap.h swap.h
telemetry.cpp
telemetry.h
texture.cpp texture.cpp
texture.h texture.h
thread.cpp thread.cpp

View file

@ -1,92 +1 @@
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <algorithm>
#include <cstring>
#include "common/arch.h"
#include "common/assert.h"
#include "common/scm_rev.h"
#include "common/telemetry.h"
#if CITRA_ARCH(x86_64)
#include "common/x64/cpu_detect.h"
#endif
namespace Common::Telemetry {
void FieldCollection::Accept(VisitorInterface& visitor) const {
for (const auto& field : fields) {
field.second->Accept(visitor);
}
}
void FieldCollection::AddField(std::unique_ptr<FieldInterface> field) {
fields[field->GetName()] = std::move(field);
}
template <class T>
void Field<T>::Accept(VisitorInterface& visitor) const {
visitor.Visit(*this);
}
template class Field<bool>;
template class Field<double>;
template class Field<float>;
template class Field<u8>;
template class Field<u16>;
template class Field<u32>;
template class Field<u64>;
template class Field<s8>;
template class Field<s16>;
template class Field<s32>;
template class Field<s64>;
template class Field<std::string>;
template class Field<const char*>;
template class Field<std::chrono::microseconds>;
void AppendBuildInfo(FieldCollection& fc) {
const bool is_git_dirty{std::strstr(Common::g_scm_desc, "dirty") != nullptr};
fc.AddField(FieldType::App, "Git_IsDirty", is_git_dirty);
fc.AddField(FieldType::App, "Git_Branch", Common::g_scm_branch);
fc.AddField(FieldType::App, "Git_Revision", Common::g_scm_rev);
fc.AddField(FieldType::App, "BuildDate", Common::g_build_date);
fc.AddField(FieldType::App, "BuildName", Common::g_build_name);
}
void AppendCPUInfo(FieldCollection& fc) {
#if CITRA_ARCH(x86_64)
fc.AddField(FieldType::UserSystem, "CPU_Model", Common::GetCPUCaps().cpu_string);
fc.AddField(FieldType::UserSystem, "CPU_BrandString", Common::GetCPUCaps().brand_string);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AES", Common::GetCPUCaps().aes);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AVX", Common::GetCPUCaps().avx);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AVX2", Common::GetCPUCaps().avx2);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AVX512", Common::GetCPUCaps().avx512);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_BMI1", Common::GetCPUCaps().bmi1);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_BMI2", Common::GetCPUCaps().bmi2);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_FMA", Common::GetCPUCaps().fma);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_FMA4", Common::GetCPUCaps().fma4);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE", Common::GetCPUCaps().sse);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE2", Common::GetCPUCaps().sse2);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE3", Common::GetCPUCaps().sse3);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSSE3", Common::GetCPUCaps().ssse3);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE41", Common::GetCPUCaps().sse4_1);
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_SSE42", Common::GetCPUCaps().sse4_2);
#else
fc.AddField(FieldType::UserSystem, "CPU_Model", "Other");
#endif
}
void AppendOSInfo(FieldCollection& fc) {
#ifdef __APPLE__
fc.AddField(FieldType::UserSystem, "OsPlatform", "Apple");
#elif defined(_WIN32)
fc.AddField(FieldType::UserSystem, "OsPlatform", "Windows");
#elif defined(__linux__) || defined(linux) || defined(__linux)
fc.AddField(FieldType::UserSystem, "OsPlatform", "Linux");
#else
fc.AddField(FieldType::UserSystem, "OsPlatform", "Unknown");
#endif
}
} // namespace Common::Telemetry

View file

@ -1,199 +1 @@
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <chrono>
#include <map>
#include <memory>
#include <string>
#include "common/common_types.h"
namespace Common::Telemetry {
/// Field type, used for grouping fields together in the final submitted telemetry log
enum class FieldType : u8 {
None = 0, ///< No specified field group
App, ///< Citra application fields (e.g. version, branch, etc.)
Session, ///< Emulated session fields (e.g. title ID, log, etc.)
Performance, ///< Emulated performance (e.g. fps, emulated CPU speed, etc.)
UserFeedback, ///< User submitted feedback (e.g. star rating, user notes, etc.)
UserConfig, ///< User configuration fields (e.g. emulated CPU core, renderer, etc.)
UserSystem, ///< User system information (e.g. host CPU type, RAM, etc.)
};
struct VisitorInterface;
/**
* Interface class for telemetry data fields.
*/
class FieldInterface : NonCopyable {
public:
virtual ~FieldInterface() = default;
/**
* Accept method for the visitor pattern.
* @param visitor Reference to the visitor that will visit this field.
*/
virtual void Accept(VisitorInterface& visitor) const = 0;
/**
* Gets the name of this field.
* @returns Name of this field as a string.
*/
virtual const std::string& GetName() const = 0;
};
/**
* Represents a telemetry data field, i.e. a unit of data that gets logged and submitted to our
* telemetry web service.
*/
template <typename T>
class Field : public FieldInterface {
public:
Field(FieldType type, std::string name, T value)
: name(std::move(name)), type(type), value(std::move(value)) {}
Field(const Field&) = default;
Field& operator=(const Field&) = default;
Field(Field&&) = default;
Field& operator=(Field&& other) = default;
void Accept(VisitorInterface& visitor) const override;
[[nodiscard]] const std::string& GetName() const override {
return name;
}
/**
* Returns the type of the field.
*/
[[nodiscard]] FieldType GetType() const {
return type;
}
/**
* Returns the value of the field.
*/
[[nodiscard]] const T& GetValue() const {
return value;
}
[[nodiscard]] bool operator==(const Field& other) const {
return (type == other.type) && (name == other.name) && (value == other.value);
}
[[nodiscard]] bool operator!=(const Field& other) const {
return !operator==(other);
}
private:
std::string name; ///< Field name, must be unique
FieldType type{}; ///< Field type, used for grouping fields together
T value; ///< Field value
};
/**
* Collection of data fields that have been logged.
*/
class FieldCollection final : NonCopyable {
public:
FieldCollection() = default;
/**
* Accept method for the visitor pattern, visits each field in the collection.
* @param visitor Reference to the visitor that will visit each field.
*/
void Accept(VisitorInterface& visitor) const;
/**
* Creates a new field and adds it to the field collection.
* @param type Type of the field to add.
* @param name Name of the field to add.
* @param value Value for the field to add.
*/
template <typename T>
void AddField(FieldType type, const char* name, T value) {
return AddField(std::make_unique<Field<T>>(type, name, std::move(value)));
}
/**
* Adds a new field to the field collection.
* @param field Field to add to the field collection.
*/
void AddField(std::unique_ptr<FieldInterface> field);
private:
std::map<std::string, std::unique_ptr<FieldInterface>> fields;
};
/**
* Telemetry fields visitor interface class. A backend to log to a web service should implement
* this interface.
*/
struct VisitorInterface : NonCopyable {
virtual ~VisitorInterface() = default;
virtual void Visit(const Field<bool>& field) = 0;
virtual void Visit(const Field<double>& field) = 0;
virtual void Visit(const Field<float>& field) = 0;
virtual void Visit(const Field<u8>& field) = 0;
virtual void Visit(const Field<u16>& field) = 0;
virtual void Visit(const Field<u32>& field) = 0;
virtual void Visit(const Field<u64>& field) = 0;
virtual void Visit(const Field<s8>& field) = 0;
virtual void Visit(const Field<s16>& field) = 0;
virtual void Visit(const Field<s32>& field) = 0;
virtual void Visit(const Field<s64>& field) = 0;
virtual void Visit(const Field<std::string>& field) = 0;
virtual void Visit(const Field<const char*>& field) = 0;
virtual void Visit(const Field<std::chrono::microseconds>& field) = 0;
/// Completion method, called once all fields have been visited
virtual void Complete() = 0;
virtual bool SubmitTestcase() = 0;
};
/**
* Empty implementation of VisitorInterface that drops all fields. Used when a functional
* backend implementation is not available.
*/
struct NullVisitor : public VisitorInterface {
~NullVisitor() = default;
void Visit(const Field<bool>& /*field*/) override {}
void Visit(const Field<double>& /*field*/) override {}
void Visit(const Field<float>& /*field*/) override {}
void Visit(const Field<u8>& /*field*/) override {}
void Visit(const Field<u16>& /*field*/) override {}
void Visit(const Field<u32>& /*field*/) override {}
void Visit(const Field<u64>& /*field*/) override {}
void Visit(const Field<s8>& /*field*/) override {}
void Visit(const Field<s16>& /*field*/) override {}
void Visit(const Field<s32>& /*field*/) override {}
void Visit(const Field<s64>& /*field*/) override {}
void Visit(const Field<std::string>& /*field*/) override {}
void Visit(const Field<const char*>& /*field*/) override {}
void Visit(const Field<std::chrono::microseconds>& /*field*/) override {}
void Complete() override {}
bool SubmitTestcase() override {
return false;
}
};
/// Appends build-specific information to the given FieldCollection,
/// such as branch name, revision hash, etc.
void AppendBuildInfo(FieldCollection& fc);
/// Appends CPU-specific information to the given FieldCollection,
/// such as instruction set extensions, etc.
void AppendCPUInfo(FieldCollection& fc);
/// Appends OS-specific information to the given FieldCollection,
/// such as platform name, etc.
void AppendOSInfo(FieldCollection& fc);
} // namespace Common::Telemetry

View file

@ -467,8 +467,6 @@ add_library(citra_core STATIC
savestate_data.h savestate_data.h
system_titles.cpp system_titles.cpp
system_titles.h system_titles.h
telemetry_session.cpp
telemetry_session.h
tracer/citrace.h tracer/citrace.h
tracer/recorder.cpp tracer/recorder.cpp
tracer/recorder.h tracer/recorder.h

View file

@ -47,7 +47,6 @@
#ifdef ENABLE_SCRIPTING #ifdef ENABLE_SCRIPTING
#include "core/rpc/server.h" #include "core/rpc/server.h"
#endif #endif
#include "core/telemetry_session.h"
#include "network/network.h" #include "network/network.h"
#include "video_core/custom_textures/custom_tex_manager.h" #include "video_core/custom_textures/custom_tex_manager.h"
#include "video_core/gpu.h" #include "video_core/gpu.h"
@ -322,7 +321,6 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st
restore_plugin_context.reset(); restore_plugin_context.reset();
} }
telemetry_session->AddInitialInfo(*app_loader);
std::shared_ptr<Kernel::Process> process; std::shared_ptr<Kernel::Process> process;
const Loader::ResultStatus load_result{app_loader->Load(process)}; const Loader::ResultStatus load_result{app_loader->Load(process)};
if (Loader::ResultStatus::Success != load_result) { if (Loader::ResultStatus::Success != load_result) {
@ -452,8 +450,6 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window,
Settings::values.output_device.GetValue()); Settings::values.output_device.GetValue());
dsp_core->EnableStretching(Settings::values.enable_audio_stretching.GetValue()); dsp_core->EnableStretching(Settings::values.enable_audio_stretching.GetValue());
telemetry_session = std::make_unique<Core::TelemetrySession>();
#ifdef ENABLE_SCRIPTING #ifdef ENABLE_SCRIPTING
rpc_server = std::make_unique<RPC::Server>(*this); rpc_server = std::make_unique<RPC::Server>(*this);
#endif #endif
@ -580,14 +576,6 @@ void System::RegisterImageInterface(std::shared_ptr<Frontend::ImageInterface> im
void System::Shutdown(bool is_deserializing) { void System::Shutdown(bool is_deserializing) {
// Log last frame performance stats // Log last frame performance stats
const auto perf_results = GetAndResetPerfStats(); const auto perf_results = GetAndResetPerfStats();
constexpr auto performance = Common::Telemetry::FieldType::Performance;
telemetry_session->AddField(performance, "Shutdown_EmulationSpeed",
perf_results.emulation_speed * 100.0);
telemetry_session->AddField(performance, "Shutdown_Framerate", perf_results.game_fps);
telemetry_session->AddField(performance, "Shutdown_Frametime", perf_results.frametime * 1000.0);
telemetry_session->AddField(performance, "Mean_Frametime_MS",
perf_stats ? perf_stats->GetMeanFrametime() : 0);
// Shutdown emulation session // Shutdown emulation session
is_powered_on = false; is_powered_on = false;
@ -599,7 +587,6 @@ void System::Shutdown(bool is_deserializing) {
app_loader.reset(); app_loader.reset();
} }
custom_tex_manager.reset(); custom_tex_manager.reset();
telemetry_session.reset();
#ifdef ENABLE_SCRIPTING #ifdef ENABLE_SCRIPTING
rpc_server.reset(); rpc_server.reset();
#endif #endif

View file

@ -72,7 +72,6 @@ class AppLoader;
namespace Core { namespace Core {
class ARM_Interface; class ARM_Interface;
class TelemetrySession;
class ExclusiveMonitor; class ExclusiveMonitor;
class Timing; class Timing;
@ -165,14 +164,6 @@ public:
return is_powered_on; return is_powered_on;
} }
/**
* Returns a reference to the telemetry session for this emulation session.
* @returns Reference to the telemetry session.
*/
[[nodiscard]] Core::TelemetrySession& TelemetrySession() const {
return *telemetry_session;
}
/// Prepare the core emulation for a reschedule /// Prepare the core emulation for a reschedule
void PrepareReschedule(); void PrepareReschedule();
@ -385,9 +376,6 @@ private:
/// When true, signals that a reschedule should happen /// When true, signals that a reschedule should happen
bool reschedule_pending{}; bool reschedule_pending{};
/// Telemetry session for this emulation session
std::unique_ptr<Core::TelemetrySession> telemetry_session;
std::unique_ptr<VideoCore::GPU> gpu; std::unique_ptr<VideoCore::GPU> gpu;
/// Service manager /// Service manager
@ -470,3 +458,4 @@ private:
} // namespace Core } // namespace Core
BOOST_CLASS_VERSION(Core::System, 1) BOOST_CLASS_VERSION(Core::System, 1)

View file

@ -34,7 +34,6 @@
#include "core/hw/aes/ccm.h" #include "core/hw/aes/ccm.h"
#include "core/hw/aes/key.h" #include "core/hw/aes/key.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "core/telemetry_session.h"
SERVICE_CONSTRUCT_IMPL(Service::APT::Module) SERVICE_CONSTRUCT_IMPL(Service::APT::Module)
@ -274,10 +273,6 @@ void Module::APTInterface::GetSharedFont(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
// Log in telemetry if the game uses the shared font
apt->system.TelemetrySession().AddField(Common::Telemetry::FieldType::Session,
"RequiresSharedFont", true);
if (!apt->shared_font_loaded) { if (!apt->shared_font_loaded) {
// On real 3DS, font loading happens on booting. However, we load it on demand to coordinate // On real 3DS, font loading happens on booting. However, we load it on demand to coordinate
// with CFG region auto configuration, which happens later than APT initialization. // with CFG region auto configuration, which happens later than APT initialization.

View file

@ -26,7 +26,6 @@
#include "core/loader/smdh.h" #include "core/loader/smdh.h"
#include "core/memory.h" #include "core/memory.h"
#include "core/system_titles.h" #include "core/system_titles.h"
#include "core/telemetry_session.h"
#include "network/network.h" #include "network/network.h"
namespace Loader { namespace Loader {
@ -277,9 +276,6 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) {
overlay_ncch = &update_ncch; overlay_ncch = &update_ncch;
} }
system.TelemetrySession().AddField(Common::Telemetry::FieldType::Session, "ProgramId",
program_id);
if (auto room_member = Network::GetRoomMember().lock()) { if (auto room_member = Network::GetRoomMember().lock()) {
Network::GameInfo game_info; Network::GameInfo game_info;
ReadTitle(game_info.name); ReadTitle(game_info.name);

View file

@ -1,176 +1 @@
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <cryptopp/osrng.h>
#include "common/assert.h"
#include "common/common_types.h"
#include "common/file_util.h"
#include "common/logging/log.h"
#include "common/scm_rev.h"
#include "common/settings.h"
#include "core/core.h"
#include "core/loader/loader.h"
#include "core/telemetry_session.h"
#include "network/network_settings.h"
#ifdef ENABLE_WEB_SERVICE
#include "web_service/telemetry_json.h"
#include "web_service/verify_login.h"
#endif
namespace Core {
namespace Telemetry = Common::Telemetry;
static u64 GenerateTelemetryId() {
u64 telemetry_id{};
CryptoPP::AutoSeededRandomPool rng;
rng.GenerateBlock(reinterpret_cast<CryptoPP::byte*>(&telemetry_id), sizeof(u64));
return telemetry_id;
}
u64 GetTelemetryId() {
u64 telemetry_id{};
const std::string filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) +
"telemetry_id"};
if (FileUtil::Exists(filename)) {
FileUtil::IOFile file(filename, "rb");
if (!file.IsOpen()) {
LOG_ERROR(Core, "failed to open telemetry_id: {}", filename);
return {};
}
file.ReadBytes(&telemetry_id, sizeof(u64));
} else {
FileUtil::IOFile file(filename, "wb");
if (!file.IsOpen()) {
LOG_ERROR(Core, "failed to open telemetry_id: {}", filename);
return {};
}
telemetry_id = GenerateTelemetryId();
file.WriteBytes(&telemetry_id, sizeof(u64));
}
return telemetry_id;
}
u64 RegenerateTelemetryId() {
const u64 new_telemetry_id{GenerateTelemetryId()};
const std::string filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) +
"telemetry_id"};
FileUtil::IOFile file(filename, "wb");
if (!file.IsOpen()) {
LOG_ERROR(Core, "failed to open telemetry_id: {}", filename);
return {};
}
file.WriteBytes(&new_telemetry_id, sizeof(u64));
return new_telemetry_id;
}
bool VerifyLogin(const std::string& username, const std::string& token) {
#ifdef ENABLE_WEB_SERVICE
return WebService::VerifyLogin(NetSettings::values.web_api_url, username, token);
#else
return false;
#endif
}
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>(NetSettings::values.web_api_url,
NetSettings::values.citra_username,
NetSettings::values.citra_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 (NetSettings::values.enable_telemetry) {
backend->Complete();
}
}
void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) {
// Log one-time top-level information
AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId());
// Log one-time session start information
const s64 init_time{std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count()};
AddField(Telemetry::FieldType::Session, "Init_Time", init_time);
std::string program_name;
const Loader::ResultStatus res{app_loader.ReadTitle(program_name)};
if (res == Loader::ResultStatus::Success) {
AddField(Telemetry::FieldType::Session, "ProgramName", program_name);
}
// Log application information
Telemetry::AppendBuildInfo(field_collection);
// Log user system information
Telemetry::AppendCPUInfo(field_collection);
Telemetry::AppendOSInfo(field_collection);
// Log user configuration information
AddField(Telemetry::FieldType::UserConfig, "Audio_SinkId",
static_cast<int>(Settings::values.output_type.GetValue()));
AddField(Telemetry::FieldType::UserConfig, "Audio_EnableAudioStretching",
Settings::values.enable_audio_stretching.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Core_UseCpuJit",
Settings::values.use_cpu_jit.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_ResolutionFactor",
Settings::values.resolution_factor.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_FrameLimit",
Settings::values.frame_limit.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_Backend",
static_cast<int>(Settings::values.graphics_api.GetValue()));
AddField(Telemetry::FieldType::UserConfig, "Renderer_UseHwShader",
Settings::values.use_hw_shader.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_ShadersAccurateMul",
Settings::values.shaders_accurate_mul.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_UseShaderJit",
Settings::values.use_shader_jit.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_UseVsync",
Settings::values.use_vsync_new.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_FilterMode",
Settings::values.filter_mode.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_Render3d",
static_cast<int>(Settings::values.render_3d.GetValue()));
AddField(Telemetry::FieldType::UserConfig, "Renderer_Factor3d",
Settings::values.factor_3d.GetValue());
AddField(Telemetry::FieldType::UserConfig, "Renderer_MonoRenderOption",
static_cast<int>(Settings::values.mono_render_option.GetValue()));
AddField(Telemetry::FieldType::UserConfig, "System_IsNew3ds",
Settings::values.is_new_3ds.GetValue());
AddField(Telemetry::FieldType::UserConfig, "System_LLEApplets",
Settings::values.lle_applets.GetValue());
AddField(Telemetry::FieldType::UserConfig, "System_RegionValue",
Settings::values.region_value.GetValue());
}
bool TelemetrySession::SubmitTestcase() {
#ifdef ENABLE_WEB_SERVICE
auto backend = std::make_unique<WebService::TelemetryJson>(NetSettings::values.web_api_url,
NetSettings::values.citra_username,
NetSettings::values.citra_token);
field_collection.Accept(*backend);
return backend->SubmitTestcase();
#else
return false;
#endif
}
} // namespace Core

View file

@ -1,91 +1 @@
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <string>
#include "common/telemetry.h"
namespace Loader {
class AppLoader;
}
namespace Core {
/**
* Instruments telemetry for this emulation session. Creates a new set of telemetry fields on each
* session, logging any one-time fields. Interfaces with the telemetry backend used for submitting
* data to the web service. Submits session data on close.
*/
class TelemetrySession {
public:
explicit TelemetrySession();
~TelemetrySession();
TelemetrySession(const TelemetrySession&) = delete;
TelemetrySession& operator=(const TelemetrySession&) = delete;
TelemetrySession(TelemetrySession&&) = delete;
TelemetrySession& operator=(TelemetrySession&&) = delete;
/**
* Adds the initial telemetry info necessary when starting up a title.
*
* This includes information such as:
* - Telemetry ID
* - Initialization time
* - Title ID
* - Title name
* - Title file format
* - Miscellaneous settings values.
*
* @param app_loader The application loader to use to retrieve
* title-specific information.
*/
void AddInitialInfo(Loader::AppLoader& app_loader);
/**
* Wrapper around the Telemetry::FieldCollection::AddField method.
* @param type Type of the field to add.
* @param name Name of the field to add.
* @param value Value for the field to add.
*/
template <typename T>
void AddField(Common::Telemetry::FieldType type, const char* name, T value) {
field_collection.AddField(type, name, std::move(value));
}
/**
* Submits a Testcase.
* @returns A bool indicating whether the submission succeeded
*/
bool SubmitTestcase();
private:
/// Tracks all added fields for the session
Common::Telemetry::FieldCollection field_collection;
};
/**
* 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();
/**
* Verifies the username and token.
* @param username Citra username to use for authentication.
* @param token Citra token to use for authentication.
* @returns Future with bool indicating whether the verification succeeded
*/
bool VerifyLogin(const std::string& username, const std::string& token);
} // namespace Core

View file

@ -2,8 +2,6 @@ add_library(web_service STATIC
announce_room_json.cpp announce_room_json.cpp
announce_room_json.h announce_room_json.h
precompiled_headers.h precompiled_headers.h
telemetry_json.cpp
telemetry_json.h
verify_login.cpp verify_login.cpp
verify_login.h verify_login.h
verify_user_jwt.cpp verify_user_jwt.cpp

View file

@ -1,130 +1 @@
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <json.hpp>
#include "common/detached_tasks.h"
#include "common/web_result.h"
#include "web_service/telemetry_json.h"
#include "web_service/web_backend.h"
namespace WebService {
namespace Telemetry = Common::Telemetry;
struct TelemetryJson::Impl {
Impl(std::string host, std::string username, std::string token)
: host{std::move(host)}, username{std::move(username)}, token{std::move(token)} {}
nlohmann::json& TopSection() {
return sections[static_cast<u8>(Telemetry::FieldType::None)];
}
const nlohmann::json& TopSection() const {
return sections[static_cast<u8>(Telemetry::FieldType::None)];
}
template <class T>
void Serialize(Telemetry::FieldType type, const std::string& name, T value) {
sections[static_cast<u8>(type)][name] = value;
}
void SerializeSection(Telemetry::FieldType type, const std::string& name) {
TopSection()[name] = sections[static_cast<unsigned>(type)];
}
nlohmann::json output;
std::array<nlohmann::json, 7> sections;
std::string host;
std::string username;
std::string token;
};
TelemetryJson::TelemetryJson(std::string host, std::string username, std::string token)
: impl{std::make_unique<Impl>(std::move(host), std::move(username), std::move(token))} {}
TelemetryJson::~TelemetryJson() = default;
void TelemetryJson::Visit(const Telemetry::Field<bool>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<double>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<float>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<u8>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<u16>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<u32>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<u64>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<s8>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<s16>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<s32>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<s64>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<std::string>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue());
}
void TelemetryJson::Visit(const Telemetry::Field<const char*>& field) {
impl->Serialize(field.GetType(), field.GetName(), std::string(field.GetValue()));
}
void TelemetryJson::Visit(const Telemetry::Field<std::chrono::microseconds>& field) {
impl->Serialize(field.GetType(), field.GetName(), field.GetValue().count());
}
void TelemetryJson::Complete() {
impl->SerializeSection(Telemetry::FieldType::App, "App");
impl->SerializeSection(Telemetry::FieldType::Session, "Session");
impl->SerializeSection(Telemetry::FieldType::Performance, "Performance");
impl->SerializeSection(Telemetry::FieldType::UserConfig, "UserConfig");
impl->SerializeSection(Telemetry::FieldType::UserSystem, "UserSystem");
auto content = impl->TopSection().dump();
// Send the telemetry async but don't handle the errors since they were written to the log
Common::DetachedTasks::AddTask([host{impl->host}, content]() {
Client{host, "", ""}.PostJson("/telemetry", content, true);
});
}
bool TelemetryJson::SubmitTestcase() {
impl->SerializeSection(Telemetry::FieldType::App, "App");
impl->SerializeSection(Telemetry::FieldType::Session, "Session");
impl->SerializeSection(Telemetry::FieldType::UserFeedback, "UserFeedback");
impl->SerializeSection(Telemetry::FieldType::UserSystem, "UserSystem");
auto content = impl->TopSection().dump();
Client client(impl->host, impl->username, impl->token);
auto value = client.PostJson("/gamedb/testcase", content, false);
return value.result_code == Common::WebResult::Code::Success;
}
} // namespace WebService

View file

@ -1,46 +1 @@
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <chrono>
#include <string>
#include "common/announce_multiplayer_room.h"
#include "common/telemetry.h"
namespace WebService {
/**
* Implementation of VisitorInterface that serialized telemetry into JSON, and submits it to the
* Citra web service
*/
class TelemetryJson : public Common::Telemetry::VisitorInterface {
public:
TelemetryJson(std::string host, std::string username, std::string token);
~TelemetryJson() override;
void Visit(const Common::Telemetry::Field<bool>& field) override;
void Visit(const Common::Telemetry::Field<double>& field) override;
void Visit(const Common::Telemetry::Field<float>& field) override;
void Visit(const Common::Telemetry::Field<u8>& field) override;
void Visit(const Common::Telemetry::Field<u16>& field) override;
void Visit(const Common::Telemetry::Field<u32>& field) override;
void Visit(const Common::Telemetry::Field<u64>& field) override;
void Visit(const Common::Telemetry::Field<s8>& field) override;
void Visit(const Common::Telemetry::Field<s16>& field) override;
void Visit(const Common::Telemetry::Field<s32>& field) override;
void Visit(const Common::Telemetry::Field<s64>& field) override;
void Visit(const Common::Telemetry::Field<std::string>& field) override;
void Visit(const Common::Telemetry::Field<const char*>& field) override;
void Visit(const Common::Telemetry::Field<std::chrono::microseconds>& field) override;
void Complete() override;
bool SubmitTestcase() override;
private:
struct Impl;
std::unique_ptr<Impl> impl;
};
} // namespace WebService