Collect statistic about used file format versions.

Later it will be useful when we will decide which formats to support for backward compatibility.
This commit is contained in:
Roman Telezhynskyi 2023-10-06 10:01:35 +03:00
parent be88184f7c
commit 1ed8bf4a46
6 changed files with 234 additions and 2 deletions

View File

@ -29,6 +29,7 @@
#include <QCloseEvent>
#include <QFileDialog>
#include <QFileInfo>
#include <QFileSystemWatcher>
#include <QLoggingCategory>
#include <QPrintDialog>
@ -41,7 +42,6 @@
#include <QtMath>
#include <chrono>
#include <thread>
#include <QFileInfo>
#include "../ifc/exception/vexception.h"
#include "../ifc/xml/vlayoutconverter.h"
@ -465,6 +465,25 @@ auto VPMainWindow::LoadFile(const QString &path) -> bool
lock.reset();
return false;
}
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendLayoutFormatVersion(uptime, converter.GetFormatVersionStr());
}
}
catch (VException &e)
{

View File

@ -475,6 +475,25 @@ auto TMainWindow::LoadFile(const QString &path) -> bool
m_curFileFormatVersion = converter.GetCurrentFormatVersion();
m_curFileFormatVersionStr = converter.GetFormatVersionStr();
m_m->setXMLContent(converter.Convert()); // Read again after conversion
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendMultisizeMeasurementsFormatVersion(uptime, m_curFileFormatVersionStr);
}
}
else
{
@ -482,6 +501,25 @@ auto TMainWindow::LoadFile(const QString &path) -> bool
m_curFileFormatVersion = converter.GetCurrentFormatVersion();
m_curFileFormatVersionStr = converter.GetFormatVersionStr();
m_m->setXMLContent(converter.Convert()); // Read again after conversion
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendIndividualMeasurementsFormatVersion(uptime, m_curFileFormatVersionStr);
}
}
if (not m_m->IsDefinedKnownNamesValid())
@ -1635,6 +1673,25 @@ void TMainWindow::ImportFromPattern()
QScopedPointer<VLitePattern> doc(new VLitePattern());
doc->setXMLContent(converter.Convert());
measurements = doc->ListMeasurements();
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendPatternFormatVersion(uptime, converter.GetFormatVersionStr());
}
}
catch (VException &e)
{

View File

@ -33,6 +33,7 @@
#include <QDesktopServices>
#include <QDoubleSpinBox>
#include <QFileDialog>
#include <QFileInfo>
#include <QFileSystemWatcher>
#include <QFuture>
#include <QGlobalStatic>
@ -54,7 +55,6 @@
#include <chrono>
#include <memory>
#include <thread>
#include <QFileInfo>
#include "../ifc/exception/vexceptionconversionerror.h"
#include "../ifc/exception/vexceptionemptyparameter.h"
@ -6349,6 +6349,25 @@ auto MainWindow::LoadPattern(QString fileName, const QString &customMeasureFile)
m_curFileFormatVersion = converter->GetCurrentFormatVersion();
m_curFileFormatVersionStr = converter->GetFormatVersionStr();
doc->setXMLContent(converter->Convert());
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendPatternFormatVersion(uptime, m_curFileFormatVersionStr);
}
}
if (!customMeasureFile.isEmpty())
@ -6920,11 +6939,49 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri
{
VVSTConverter converter(mPath);
m->setXMLContent(converter.Convert()); // Read again after conversion
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendMultisizeMeasurementsFormatVersion(uptime, converter.GetFormatVersionStr());
}
}
else
{
VVITConverter converter(mPath);
m->setXMLContent(converter.Convert()); // Read again after conversion
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendIndividualMeasurementsFormatVersion(uptime, converter.GetFormatVersionStr());
}
}
if (not m->IsDefinedKnownNamesValid())

View File

@ -31,6 +31,7 @@
#include "../ifc/xml/vvstconverter.h"
#include "../vdxf/libdxfrw/drw_base.h"
#include "../vformat/vmeasurements.h"
#include "../vganalytics/vganalytics.h"
#include "../vlayout/vlayoutexporter.h"
#include "../vlayout/vlayoutgenerator.h"
#include "../vmisc/compatibility.h"
@ -1299,11 +1300,49 @@ auto MainWindowsNoGUI::OpenMeasurementFile(const QString &path) const -> QShared
{
VVSTConverter converter(path);
m->setXMLContent(converter.Convert()); // Read again after conversion
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendMultisizeMeasurementsFormatVersion(uptime, converter.GetFormatVersionStr());
}
}
else
{
VVITConverter converter(path);
m->setXMLContent(converter.Convert()); // Read again after conversion
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
if (settings->IsCollectStatistic())
{
auto *statistic = VGAnalytics::Instance();
QString clientID = settings->GetClientID();
if (clientID.isEmpty())
{
clientID = QUuid::createUuid().toString();
settings->SetClientID(clientID);
statistic->SetClientID(clientID);
}
statistic->Enable(true);
const qint64 uptime = VAbstractApplication::VApp()->AppUptime();
statistic->SendIndividualMeasurementsFormatVersion(uptime, converter.GetFormatVersionStr());
}
}
if (not m->IsDefinedKnownNamesValid())

View File

@ -305,6 +305,62 @@ void VGAnalytics::SendPatternToolUsedEvent(qint64 engagementTimeMsec, const QStr
SendEvent(QStringLiteral("vapp_pattern_tool_used"), params);
}
//---------------------------------------------------------------------------------------------------------------------
void VGAnalytics::SendPatternFormatVersion(qint64 engagementTimeMsec, const QString &version)
{
QHash<QString, QJsonValue> params{
// In order for user activity to display in standard reports like Realtime, engagement_time_msec and session_id
// must be supplied as part of the params for an event.
// https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag#optional_parameters_for_reports
{QStringLiteral("engagement_time_msec"), engagementTimeMsec},
{QStringLiteral("format_version"), version},
};
SendEvent(QStringLiteral("vapp_pattern_format_version"), params);
}
//---------------------------------------------------------------------------------------------------------------------
void VGAnalytics::SendIndividualMeasurementsFormatVersion(qint64 engagementTimeMsec, const QString &version)
{
QHash<QString, QJsonValue> params{
// In order for user activity to display in standard reports like Realtime, engagement_time_msec and session_id
// must be supplied as part of the params for an event.
// https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag#optional_parameters_for_reports
{QStringLiteral("engagement_time_msec"), engagementTimeMsec},
{QStringLiteral("format_version"), version},
};
SendEvent(QStringLiteral("vapp_individual_measurements_format_version"), params);
}
//---------------------------------------------------------------------------------------------------------------------
void VGAnalytics::SendMultisizeMeasurementsFormatVersion(qint64 engagementTimeMsec, const QString &version)
{
QHash<QString, QJsonValue> params{
// In order for user activity to display in standard reports like Realtime, engagement_time_msec and session_id
// must be supplied as part of the params for an event.
// https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag#optional_parameters_for_reports
{QStringLiteral("engagement_time_msec"), engagementTimeMsec},
{QStringLiteral("format_version"), version},
};
SendEvent(QStringLiteral("vapp_multisize_measurements_format_version"), params);
}
//---------------------------------------------------------------------------------------------------------------------
void VGAnalytics::SendLayoutFormatVersion(qint64 engagementTimeMsec, const QString &version)
{
QHash<QString, QJsonValue> params{
// In order for user activity to display in standard reports like Realtime, engagement_time_msec and session_id
// must be supplied as part of the params for an event.
// https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag#optional_parameters_for_reports
{QStringLiteral("engagement_time_msec"), engagementTimeMsec},
{QStringLiteral("format_version"), version},
};
SendEvent(QStringLiteral("vapp_layout_format_version"), params);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* A query for a POST message will be created to report this event. The

View File

@ -90,6 +90,10 @@ public slots:
void SendAppStartEvent(qint64 engagementTimeMsec);
void SendAppCloseEvent(qint64 engagementTimeMsec);
void SendPatternToolUsedEvent(qint64 engagementTimeMsec, const QString &toolName);
void SendPatternFormatVersion(qint64 engagementTimeMsec, const QString &version);
void SendIndividualMeasurementsFormatVersion(qint64 engagementTimeMsec, const QString &version);
void SendMultisizeMeasurementsFormatVersion(qint64 engagementTimeMsec, const QString &version);
void SendLayoutFormatVersion(qint64 engagementTimeMsec, const QString &version);
private:
Q_DISABLE_COPY_MOVE(VGAnalytics) // NOLINT