1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-01 18:29:16 +01:00

OP-1777 Added caching of collected data hash to avoid sending duplicate redundant data.

Changed some text.
Changed nag-dialog text to use html for formatting to make it easier to
translate and maintain.
Removed timestamp from hash.
This commit is contained in:
m_thread 2015-03-16 14:53:26 +01:00
parent d948b1ca1c
commit 14f2bb6ce9
2 changed files with 49 additions and 25 deletions

View File

@ -38,6 +38,7 @@
#include <coreplugin/generalsettings.h> #include <coreplugin/generalsettings.h>
#include "version_info/version_info.h" #include "version_info/version_info.h"
#include "coreplugin/icore.h" #include "coreplugin/icore.h"
#include <uavtalk/telemetrymanager.h>
UsageTrackerPlugin::UsageTrackerPlugin() : UsageTrackerPlugin::UsageTrackerPlugin() :
m_telemetryManager(NULL) m_telemetryManager(NULL)
@ -82,27 +83,27 @@ void UsageTrackerPlugin::onAutopilotConnect()
message.addButton(tr("Yes, count me in"), QMessageBox::AcceptRole); message.addButton(tr("Yes, count me in"), QMessageBox::AcceptRole);
message.addButton(tr("No, I will not help"), QMessageBox::RejectRole); message.addButton(tr("No, I will not help"), QMessageBox::RejectRole);
message.setText(tr("Openpilot GCS has a function to collect limited anonymous information about " message.setText(tr("Openpilot GCS has a function to collect limited anonymous information about "
"the usage of the application itself and the OpenPilot hardware connected to it.\n\n" "the usage of the application itself and the OpenPilot hardware connected to it.<p>"
"The intention is to not include anything that can be considered sensitive " "The intention is to not include anything that can be considered sensitive "
"or a threat to the users integrity. The collected information will be sent " "or a threat to the users integrity. The collected information will be sent "
"using a secure protocol to an OpenPilot web service and stored in a database " "using a secure protocol to an OpenPilot web service and stored in a database "
"for later analysis and statistical purposes.\n" "for later analysis and statistical purposes.<br>"
"No information will be sold or given to any third party. The sole purpose is " "No information will be sold or given to any third party. The sole purpose is "
"to collect statistics about the usage of our software and hardware to enable us " "to collect statistics about the usage of our software and hardware to enable us "
"to make things better for you.\n\n" "to make things better for you.<p>"
"The following things are collected:\n" "The following things are collected:<ul>"
"- Bootloader version\n" "<li>Bootloader version</li>"
"- Firmware version, tag and git hash\n" "<li>Firmware version, tag and git hash</li>"
"- OP Hardware type, revision and mcu serial number\n" "<li>OP Hardware type, revision and mcu serial number</li>"
"- Selected configuration parameters\n" "<li>Selected configuration parameters</li>"
"- GCS version\n" "<li>GCS version</li>"
"- Operating system version and architecture\n" "<li>Operating system version and architecture</li>"
"- Current local time\n" "<li>Current local time</li></ul>"
"The information is collected only at the time when a board is connecting to GCS.\n\n" "The information is collected only at the time when a board is connecting to GCS.<p>"
"It is possible to enable or disable this functionality in the general " "It is possible to enable or disable this functionality in the general "
"settings part of the options for the GCS application at any time.\n\n" "settings part of the options for the GCS application at any time.<p>"
"We need your help, with your feedback we know where to improve things and what " "We need your help, with your feedback we know where to improve things and what "
"platforms are in use. This is a community project that depends on people being involved.\n" "platforms are in use. This is a community project that depends on people being involved.<br>"
"Thank You for helping us making things better and for supporting OpenPilot!")); "Thank You for helping us making things better and for supporting OpenPilot!"));
QCheckBox *disclaimerCb = new QCheckBox(tr("&Don't show this message again.")); QCheckBox *disclaimerCb = new QCheckBox(tr("&Don't show this message again."));
disclaimerCb->setChecked(true); disclaimerCb->setChecked(true);
@ -122,11 +123,6 @@ void UsageTrackerPlugin::onAutopilotConnect()
void UsageTrackerPlugin::trackUsage() void UsageTrackerPlugin::trackUsage()
{ {
QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager();
// This will delete the network access manager instance when we're done
connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), networkAccessManager, SLOT(deleteLater()));
QMap<QString, QString> parameters; QMap<QString, QString> parameters;
collectUsageParameters(parameters); collectUsageParameters(parameters);
@ -138,11 +134,24 @@ void UsageTrackerPlugin::trackUsage()
} }
// Add checksum // Add checksum
query.addQueryItem("hash", getQueryHash(query.toString())); QString hash = getQueryHash(query.toString());
QUrl url("https://www.openpilot.org/opver?" + query.toString(QUrl::FullyEncoded)); if (shouldSend(hash)) {
qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded); query.addQueryItem("hash", hash);
networkAccessManager->get(QNetworkRequest(QUrl(url.toEncoded(QUrl::FullyEncoded))));
// Add local timestamp
query.addQueryItem("localtime", QDateTime::currentDateTime().toString(Qt::ISODate));
QUrl url("https://www.openpilot.org/opver?" + query.toString(QUrl::FullyEncoded));
QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager();
// This will delete the network access manager instance when we're done
connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), networkAccessManager, SLOT(deleteLater()));
qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded);
networkAccessManager->get(QNetworkRequest(QUrl(url.toEncoded(QUrl::FullyEncoded))));
}
} }
void UsageTrackerPlugin::collectUsageParameters(QMap<QString, QString> &parameters) void UsageTrackerPlugin::collectUsageParameters(QMap<QString, QString> &parameters)
@ -163,7 +172,6 @@ void UsageTrackerPlugin::collectUsageParameters(QMap<QString, QString> &paramete
parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture();
parameters["os_threads"] = QString::number(QThread::idealThreadCount()); parameters["os_threads"] = QString::number(QThread::idealThreadCount());
parameters["gcs_version"] = VersionInfo::revision(); parameters["gcs_version"] = VersionInfo::revision();
parameters["localtime"] = QDateTime::currentDateTime().toString(Qt::ISODate);
// Configuration parameters // Configuration parameters
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
@ -213,3 +221,16 @@ QString UsageTrackerPlugin::getQueryHash(QString source) const
source += "OpenPilot Fuck Yeah!"; source += "OpenPilot Fuck Yeah!";
return QString(QCryptographicHash::hash(QByteArray(source.toStdString().c_str()), QCryptographicHash::Md5).toHex()); return QString(QCryptographicHash::hash(QByteArray(source.toStdString().c_str()), QCryptographicHash::Md5).toHex());
} }
bool UsageTrackerPlugin::shouldSend(const QString &hash)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
Core::Internal::GeneralSettings *settings = pm->getObject<Core::Internal::GeneralSettings>();
if (settings->lastUsageHash() == hash) {
return false;
} else {
settings->setLastUsageHash(hash);
return true;
}
}

View File

@ -28,7 +28,9 @@
#define USAGETRACKERPLUGIN_H #define USAGETRACKERPLUGIN_H
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <uavtalk/telemetrymanager.h>
class TelemetryManager;
class UAVObjectManager;
class UsageTrackerPlugin : public ExtensionSystem::IPlugin { class UsageTrackerPlugin : public ExtensionSystem::IPlugin {
Q_OBJECT Q_OBJECT
@ -50,6 +52,7 @@ private:
TelemetryManager *m_telemetryManager; TelemetryManager *m_telemetryManager;
QString getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index = 0) const; QString getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index = 0) const;
QString getQueryHash(QString source) const; QString getQueryHash(QString source) const;
bool shouldSend(const QString &hash);
}; };
#endif // USAGETRACKERPLUGIN_H #endif // USAGETRACKERPLUGIN_H