NOISSUE implement analytics IP anonymization

This commit is contained in:
Petr Mrázek 2016-11-21 21:18:30 +01:00
parent 95f961fb61
commit ee6f2f0a8e
5 changed files with 21 additions and 2 deletions

View File

@ -527,6 +527,7 @@ void MultiMC::initAnalytics()
} }
m_analytics = new GAnalytics(BuildConfig.ANALYTICS_ID, clientID, this); m_analytics = new GAnalytics(BuildConfig.ANALYTICS_ID, clientID, this);
m_analytics->setLogLevel(GAnalytics::Debug); m_analytics->setLogLevel(GAnalytics::Debug);
m_analytics->setAnonymizeIPs(true);
m_analytics->setNetworkAccessManager(&ENV.qnam()); m_analytics->setNetworkAccessManager(&ENV.qnam());
m_analytics->startSending(); m_analytics->startSending();
qDebug() << "Initialized analytics with tid" << BuildConfig.ANALYTICS_ID << "and cid" << clientID; qDebug() << "Initialized analytics with tid" << BuildConfig.ANALYTICS_ID << "and cid" << clientID;

View File

@ -33,6 +33,9 @@ public:
void setLanguage(const QString &language); void setLanguage(const QString &language);
QString language() const; QString language() const;
void setAnonymizeIPs(bool anonymize);
bool anonymizeIPs();
void setSendInterval(int milliseconds); void setSendInterval(int milliseconds);
int sendInterval() const; int sendInterval() const;

View File

@ -60,6 +60,16 @@ QString GAnalytics::language() const
return d->m_language; return d->m_language;
} }
void GAnalytics::setAnonymizeIPs(bool anonymize)
{
d->m_anonymizeIPs = anonymize;
}
bool GAnalytics::anonymizeIPs()
{
return d->m_anonymizeIPs;
}
void GAnalytics::setSendInterval(int milliseconds) void GAnalytics::setSendInterval(int milliseconds)
{ {
d->m_timer.setInterval(milliseconds); d->m_timer.setInterval(milliseconds);

View File

@ -12,7 +12,7 @@
const QLatin1String GAnalyticsWorker::dateTimeFormat("yyyy,MM,dd-hh:mm::ss:zzz"); const QLatin1String GAnalyticsWorker::dateTimeFormat("yyyy,MM,dd-hh:mm::ss:zzz");
GAnalyticsWorker::GAnalyticsWorker(GAnalytics *parent) GAnalyticsWorker::GAnalyticsWorker(GAnalytics *parent)
: QObject(parent), q(parent), m_logLevel(GAnalytics::Error), m_isSending(false) : QObject(parent), q(parent), m_logLevel(GAnalytics::Error)
{ {
m_appName = QCoreApplication::instance()->applicationName(); m_appName = QCoreApplication::instance()->applicationName();
m_appVersion = QCoreApplication::instance()->applicationVersion(); m_appVersion = QCoreApplication::instance()->applicationVersion();
@ -57,6 +57,10 @@ QUrlQuery GAnalyticsWorker::buildStandardPostQuery(const QString &type)
query.addQueryItem("ul", m_language); query.addQueryItem("ul", m_language);
query.addQueryItem("vp", m_viewportSize); query.addQueryItem("vp", m_viewportSize);
query.addQueryItem("sr", m_screenResolution); query.addQueryItem("sr", m_screenResolution);
if(m_anonymizeIPs)
{
query.addQueryItem("aip", "1");
}
return query; return query;
} }

View File

@ -37,7 +37,8 @@ public:
QString m_screenResolution; QString m_screenResolution;
QString m_viewportSize; QString m_viewportSize;
bool m_isSending; bool m_anonymizeIPs = false;
bool m_isSending = false;
const static int fourHours = 4 * 60 * 60 * 1000; const static int fourHours = 4 * 60 * 60 * 1000;
const static QLatin1String dateTimeFormat; const static QLatin1String dateTimeFormat;