1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Add anonymous telemtry. This will only used for basic statisitcs like how many people have screenplay open and which menu point is clicked the most.

This commit is contained in:
Elias 2019-12-05 12:42:04 +01:00
parent 31fe7a91ac
commit e0b1a6c529
5 changed files with 40 additions and 33 deletions

View File

@ -20,7 +20,6 @@ App::App()
QQuickWindow::setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
qRegisterMetaType<QQmlApplicationEngine*>();
qRegisterMetaType<GlobalVariables*>();
qRegisterMetaType<ScreenPlayManager*>();
@ -44,9 +43,13 @@ App::App()
m_profileListModel = make_shared<ProfileListModel>(m_globalVariables);
m_sdkConnector = make_shared<SDKConnector>();
m_settings = make_shared<Settings>(m_globalVariables);
m_tracker = make_unique<GAnalytics>("UA-152830367-3");
m_tracker->setNetworkAccessManager(nam);
m_tracker->setSendInterval(1000);
// Only create tracker if user did not disallow!
if (m_settings->anonymousTelemetry()) {
m_tracker = make_unique<GAnalytics>("UA-152830367-3");
m_tracker->setNetworkAccessManager(nam);
m_tracker->setSendInterval(1000);
m_tracker->startSession();
}
m_create = make_unique<Create>(m_globalVariables);
m_screenPlayManager = make_unique<ScreenPlayManager>(m_globalVariables, m_monitorListModel, m_sdkConnector);
@ -73,15 +76,17 @@ App::App()
m_mainWindowEngine->load(QUrl(QStringLiteral("qrc:/main.qml")));
#endif
m_tracker->startSession();
}
void App::exit()
{
// Workaround because we cannot force to send exit event
m_tracker->setSendInterval(5);
m_tracker->endSession();
QTimer::singleShot(150,[](){ QGuiApplication::instance()->quit();});
if (!m_tracker) {
QGuiApplication::instance()->quit();
return;
} else {
// Workaround because we cannot force to send exit event
m_tracker->setSendInterval(5);
m_tracker->endSession();
QTimer::singleShot(150, []() { QGuiApplication::instance()->quit(); });
}
}

View File

@ -140,7 +140,9 @@ public slots:
void exit();
void setTrackerSendEvent(const QString& page){
m_tracker->sendEvent("navigation",page);
if(m_tracker){
m_tracker->sendEvent("navigation",page);
}
}

View File

@ -2,6 +2,6 @@
"version":"1.0.0",
"autostart":true,
"highPriorityStart":false,
"sendStatistics":false,
"anonymousTelemetry":true,
"absoluteStoragePath":""
}

View File

@ -138,7 +138,7 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
m_autostart = configObj.value().value("autostart").toBool();
m_highPriorityStart = configObj.value().value("highPriorityStart").toBool();
m_sendStatistics = configObj.value().value("sendStatistics").toBool();
m_anonymousTelemetry = configObj.value().value("anonymousTelemetry").toBool();
setupWidgetAndWindowPaths();
}

View File

@ -45,10 +45,11 @@ class Settings : public QObject {
Q_OBJECT
Q_PROPERTY(QVersionNumber version READ version)
Q_PROPERTY(bool anonymousTelemetry READ anonymousTelemetry WRITE setAnonymousTelemetry NOTIFY anonymousTelemetryChanged)
Q_PROPERTY(bool silentStart READ silentStart WRITE setSilentStart NOTIFY silentStartChanged)
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged)
Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged)
Q_PROPERTY(bool pauseWallpaperWhenIngame READ pauseWallpaperWhenIngame WRITE setPauseWallpaperWhenIngame NOTIFY pauseWallpaperWhenIngameChanged)
Q_PROPERTY(bool offlineMode READ offlineMode WRITE setOfflineMode NOTIFY offlineModeChanged)
Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged)
@ -89,11 +90,6 @@ public:
return m_highPriorityStart;
}
bool sendStatistics() const
{
return m_sendStatistics;
}
QString decoder() const
{
return m_decoder;
@ -109,10 +105,14 @@ public:
return m_silentStart;
}
bool anonymousTelemetry() const
{
return m_anonymousTelemetry;
}
signals:
void autostartChanged(bool autostart);
void highPriorityStartChanged(bool highPriorityStart);
void sendStatisticsChanged(bool status);
void hasWorkshopBannerSeenChanged(bool hasWorkshopBannerSeen);
void decoderChanged(QString decoder);
void setMainWindowVisible(bool visible);
@ -122,6 +122,8 @@ signals:
void resetInstalledListmodel();
void silentStartChanged(bool silentStart);
void anonymousTelemetryChanged(bool anonymousTelemetry);
public slots:
bool writeSingleSettingConfig(QString name, QVariant value);
void setqSetting(const QString& key, const QString& value)
@ -164,17 +166,6 @@ public slots:
emit highPriorityStartChanged(m_highPriorityStart);
}
void setSendStatistics(bool sendStatistics)
{
if (m_sendStatistics == sendStatistics)
return;
m_sendStatistics = sendStatistics;
writeSingleSettingConfig("sendStatistics", sendStatistics);
emit sendStatisticsChanged(m_sendStatistics);
}
void setLocalStoragePath(QUrl localStoragePath)
{
@ -234,6 +225,15 @@ public slots:
}
void setupLanguage();
void setAnonymousTelemetry(bool anonymousTelemetry)
{
if (m_anonymousTelemetry == anonymousTelemetry)
return;
m_anonymousTelemetry = anonymousTelemetry;
emit anonymousTelemetryChanged(m_anonymousTelemetry);
}
private:
void writeJsonFileFromResource(const QString& filename);
void setupWidgetAndWindowPaths();
@ -248,11 +248,11 @@ private:
bool m_pauseWallpaperWhenIngame { false };
bool m_autostart { true };
bool m_highPriorityStart { true };
bool m_sendStatistics { false };
bool m_offlineMode { true };
QString m_decoder { "" };
QString m_gitBuildHash;
bool m_silentStart { false };
bool m_anonymousTelemetry { true };
};
}