Skip to content

Commit

Permalink
Merge pull request #27 from hjaltisan/journeyId
Browse files Browse the repository at this point in the history
JourneyId in the installer
  • Loading branch information
hjaltisan authored Dec 1, 2020
2 parents f58606e + 928def0 commit 186c985
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 19 deletions.
85 changes: 66 additions & 19 deletions src/libs/installer/eve_launcher/application.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions src/libs/installer/eve_launcher/application.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions src/libs/installer/eventlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QRandomGenerator>
#include <QUuid>
#include <QDebug>
#include <QRegularExpression>

EventLogger::EventLogger()
{
Expand Down Expand Up @@ -37,6 +38,32 @@ EventLogger::EventLogger()
m_session = QString(QLatin1String("ls")) + QString(QLatin1String(hasher.result().toHex()));

m_httpThreadController = new HttpThreadController();

// Get the journeyId from the installer filename
QUuid journeyId;
QString appName = QInstaller::getInstallerFileName().split(QLatin1String("/")).last();
if (appName.length() > 35)
{
QString pattern = QLatin1String("[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}");
QRegularExpression re(pattern, QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(appName);
if (match.hasMatch()) {
qDebug() << "framework | EventLogger::EventLogger | JourneyId found in filename:" << match.captured(0);
journeyId = QUuid::fromString(match.captured(0));
qDebug() << "framework | EventLogger::EventLogger | JourneyId:" << journeyId.toString(QUuid::WithoutBraces);
}
}

// If journey Id was found, or we weren't able to create a QUuid from it, we create a new one instead
if (journeyId.isNull())
{
qDebug() << "framework | EventLogger::EventLogger | No JourneyId provided, one will be created instead";
journeyId = QUuid::createUuid();
qDebug() << "framework | EventLogger::EventLogger | JourneyId:" << journeyId.toString(QUuid::WithoutBraces);
}

m_journeyId = journeyId.toRfc4122();
QInstaller::setJourneyId(m_journeyId);
}

EventLogger::~EventLogger()
Expand Down Expand Up @@ -235,6 +262,9 @@ eve_launcher::application::EventMetadata* EventLogger::getEventMetadata()
data->set_allocated_operating_system_uuid(new std::string(m_operatingSystemUuid.data(), size_t(m_operatingSystemUuid.size())));
}

// Set the journey
data->set_allocated_journey(new std::string(m_journeyId.data(), size_t(m_journeyId.size())));

return data;
}

Expand Down
1 change: 1 addition & 0 deletions src/libs/installer/eventlogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class EventLogger : QObject
QString m_session;
QByteArray m_sessionId;
QByteArray m_operatingSystemUuid;
QByteArray m_journeyId;
QPointer<HttpThreadController> m_httpThreadController;

explicit EventLogger();
Expand Down
10 changes: 10 additions & 0 deletions src/libs/installer/packagemanagergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "productkeycheck.h"
#include "repositorycategory.h"
#include "componentselectionpage_p.h"
#include "qsettingswrapper.h"

#include "sysinfo.h"

Expand Down Expand Up @@ -3530,6 +3531,15 @@ void PerformInstallationPage::installationStarted()
void PerformInstallationPage::installationFinished()
{
m_performInstallationForm->stopUpdateProgress();

// Store the journey Id in registry
qDebug() << "framework | PerformInstallationPage::installationFinished | Storing JourneyId to registry";
QByteArray journeyId = QInstaller::getJourneyId();
QString path = QLatin1String("HKEY_CURRENT_USER\\SOFTWARE\\CCP\\EVE\\");
QSettingsWrapper settings(path, QSettingsWrapper::NativeFormat);
settings.setValue(QLatin1String("InstallerJourneyId"), journeyId);
qDebug() << "framework | PerformInstallationPage::installationFinished | JourneyId stored to registry";

if (!isAutoSwitching()) {
m_performInstallationForm->scrollDetailsToTheEnd();
m_performInstallationForm->setDetailsButtonEnabled(false);
Expand Down
24 changes: 24 additions & 0 deletions src/libs/installer/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,30 @@ QString QInstaller::getProvidedTelemetryEndpoint()
return telemetryUrl;
}

static QString installerFileName;

void QInstaller::setInstallerFileName(const QString& fileName)
{
installerFileName = fileName;
}

QString QInstaller::getInstallerFileName()
{
return installerFileName;
}

static QByteArray journeyId;

void QInstaller::setJourneyId(const QByteArray& id)
{
journeyId = id;
}

QByteArray QInstaller::getJourneyId()
{
return journeyId;
}

std::ostream &QInstaller::operator<<(std::ostream &os, const QString &string)
{
return os << qPrintable(string);
Expand Down
Loading

0 comments on commit 186c985

Please sign in to comment.