mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Extend telemetry to include OS Imager is being run on
This commit is contained in:
parent
3ac4ee7326
commit
538cf8c9dd
5 changed files with 39 additions and 7 deletions
|
@ -3,18 +3,44 @@
|
|||
#include <QSettings>
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
#include <QSysInfo>
|
||||
#include <QLocale>
|
||||
#include <QFile>
|
||||
#include <QRegularExpression>
|
||||
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright (C) 2020 Raspberry Pi (Trading) Limited
|
||||
*/
|
||||
|
||||
DownloadStatsTelemetry::DownloadStatsTelemetry(const QByteArray &url, const QByteArray &parentcategory, const QByteArray &osname, QObject *parent)
|
||||
DownloadStatsTelemetry::DownloadStatsTelemetry(const QByteArray &url, const QByteArray &parentcategory, const QByteArray &osname, bool embedded, const QString &imagerLang, QObject *parent)
|
||||
: QThread(parent), _url(TELEMETRY_URL)
|
||||
{
|
||||
QLocale locale;
|
||||
_postfields = "url="+QUrl::toPercentEncoding(url)
|
||||
+"&os="+QUrl::toPercentEncoding(parentcategory)
|
||||
+"&image="+QUrl::toPercentEncoding(osname);
|
||||
+"&image="+QUrl::toPercentEncoding(osname)
|
||||
+"&imagerVersion=" IMAGER_VERSION_STR
|
||||
+"&imagerOsType="+(embedded ? "embedded" : QUrl::toPercentEncoding(QSysInfo::productType()))
|
||||
+"&imagerOsVersion="+QUrl::toPercentEncoding(QSysInfo::productVersion())
|
||||
+"&imagerOsArch="+QUrl::toPercentEncoding(QSysInfo::currentCpuArchitecture())
|
||||
+"&imagerLocale="+QUrl::toPercentEncoding(embedded ? imagerLang : locale.name());
|
||||
#ifdef Q_OS_LINUX
|
||||
QFile f("/proc/cpuinfo");
|
||||
f.open(f.ReadOnly);
|
||||
QByteArray cpuinfo = f.readAll();
|
||||
f.close();
|
||||
|
||||
if (cpuinfo.contains("Raspberry Pi")) {
|
||||
QRegularExpression rx("Revision[ \t]*: ([0-9a-f]+)");
|
||||
QRegularExpressionMatch m = rx.match(cpuinfo);
|
||||
if (m.hasMatch())
|
||||
{
|
||||
_postfields += "&imagerPiRevision="+QUrl::toPercentEncoding(m.captured(1));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_useragent = "Mozilla/5.0 rpi-imager/" IMAGER_VERSION_STR;
|
||||
}
|
||||
|
||||
|
@ -39,7 +65,7 @@ void DownloadStatsTelemetry::run()
|
|||
CURLcode ret = curl_easy_perform(_c);
|
||||
curl_easy_cleanup(_c);
|
||||
|
||||
qDebug() << "Telemetry done. cURL status code =" << ret;
|
||||
qDebug() << "Telemetry done. cURL status code =" << ret << "info sent =" << _postfields;
|
||||
}
|
||||
|
||||
/* /dev/null write handler */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue