refine user track logics

This commit is contained in:
Le Tan 2019-04-27 11:45:31 +08:00
parent 14617a4172
commit 3c05e9b27b
3 changed files with 37 additions and 8 deletions

View File

@ -1734,3 +1734,19 @@ void VConfigManager::setWindowsOpenGL(int p_openGL)
QString fullKey("global/windows_opengl"); QString fullKey("global/windows_opengl");
userSet->setValue(fullKey, p_openGL); userSet->setValue(fullKey, p_openGL);
} }
QDate VConfigManager::getLastUserTrackDate() const
{
auto dateStr = getConfigFromSessionSettings("global",
"last_user_track_date").toString();
return QDate::fromString(dateStr, Qt::ISODate);
}
void VConfigManager::updateLastUserTrackDate()
{
auto date = QDate::currentDate();
setConfigToSessionSettings("global",
"last_user_track_date",
date.toString(Qt::ISODate));
}

View File

@ -637,6 +637,9 @@ public:
bool getSyncNoteListToTab() const; bool getSyncNoteListToTab() const;
void setSyncNoteListToTab(bool p_enabled); void setSyncNoteListToTab(bool p_enabled);
QDate getLastUserTrackDate() const;
void updateLastUserTrackDate();
private: private:
void initEditorConfigs(); void initEditorConfigs();

View File

@ -3477,7 +3477,7 @@ void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
} }
if (g_config->getAllowUserTrack()) { if (g_config->getAllowUserTrack()) {
QTimer::singleShot(60000, this, SLOT(collectUserStat())); QTimer::singleShot(30 * 1000, this, SLOT(collectUserStat()));
} }
m_syncNoteListToCurrentTab = true; m_syncNoteListToCurrentTab = true;
@ -3585,6 +3585,13 @@ void VMainWindow::setupFileListSplitOut(bool p_enabled)
void VMainWindow::collectUserStat() const void VMainWindow::collectUserStat() const
{ {
// One request per day.
auto lastCheckDate = g_config->getLastUserTrackDate();
if (lastCheckDate != QDate::currentDate()) {
g_config->updateLastUserTrackDate();
qDebug() << "send user track" << QDate::currentDate();
QWebEnginePage *page = new QWebEnginePage; QWebEnginePage *page = new QWebEnginePage;
page->load(QUrl("https://tamlok.github.io/user_track/vnote.html")); page->load(QUrl("https://tamlok.github.io/user_track/vnote.html"));
connect(page, &QWebEnginePage::loadFinished, connect(page, &QWebEnginePage::loadFinished,
@ -3592,6 +3599,9 @@ void VMainWindow::collectUserStat() const
VUtils::sleepWait(2000); VUtils::sleepWait(2000);
page->deleteLater(); page->deleteLater();
}); });
}
QTimer::singleShot(30 * 60 * 1000, this, SLOT(collectUserStat()));
} }
void VMainWindow::promptForVNoteRestart() void VMainWindow::promptForVNoteRestart()