[tracking] Step 1 of getting the install-tracking URL
- document substitutions - build URL when creating jobs
This commit is contained in:
parent
a0e8f76348
commit
7311204572
@ -20,6 +20,7 @@
|
|||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/CalamaresUtils.h"
|
#include "utils/CalamaresUtils.h"
|
||||||
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
|
|
||||||
#include "TrackingViewStep.h"
|
#include "TrackingViewStep.h"
|
||||||
#include "TrackingPage.h"
|
#include "TrackingPage.h"
|
||||||
@ -113,6 +114,22 @@ QList< Calamares::job_ptr >
|
|||||||
TrackingViewStep::jobs() const
|
TrackingViewStep::jobs() const
|
||||||
{
|
{
|
||||||
cDebug() << "Tracking jobs ..";
|
cDebug() << "Tracking jobs ..";
|
||||||
|
if ( m_installTracking.enabled() )
|
||||||
|
{
|
||||||
|
QString installUrl = m_installTrackingUrl;
|
||||||
|
const auto s = CalamaresUtils::System::instance();
|
||||||
|
|
||||||
|
QString memory, disk;
|
||||||
|
memory.setNum( s->getTotalMemoryB().first );
|
||||||
|
disk.setNum( s->getTotalDiskB() );
|
||||||
|
|
||||||
|
installUrl
|
||||||
|
.replace( "$CPU", s->getCpuDescription() )
|
||||||
|
.replace( "$MEMORY", memory )
|
||||||
|
.replace( "$DISK", disk );
|
||||||
|
|
||||||
|
cDebug() << " .. install-tracking URL" << installUrl;
|
||||||
|
}
|
||||||
return QList< Calamares::job_ptr >();
|
return QList< Calamares::job_ptr >();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +149,7 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration
|
|||||||
settingEnabled = CalamaresUtils::getBool( config, "enabled", false );
|
settingEnabled = CalamaresUtils::getBool( config, "enabled", false );
|
||||||
userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false );
|
userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false );
|
||||||
}
|
}
|
||||||
cDebug() << " .. Install tracking: enabled=" << settingEnabled << "default=" << userEnabled;
|
cDebug() << " .. settable=" << settingEnabled << "default=" << userEnabled;
|
||||||
|
|
||||||
auto trackingConfiguration = tracking( t );
|
auto trackingConfiguration = tracking( t );
|
||||||
trackingConfiguration.settingEnabled = settingEnabled;
|
trackingConfiguration.settingEnabled = settingEnabled;
|
||||||
@ -148,7 +165,11 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration
|
|||||||
void
|
void
|
||||||
TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
setTrackingOption( configurationMap, "install", TrackingType::InstallTracking );
|
QVariantMap config;
|
||||||
|
|
||||||
|
config = setTrackingOption( configurationMap, "install", TrackingType::InstallTracking );
|
||||||
|
m_installTrackingUrl = CalamaresUtils::getString( config, "url" );
|
||||||
|
|
||||||
setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking );
|
setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking );
|
||||||
setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
|
setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
QVariantMap setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t );
|
QVariantMap setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t );
|
||||||
|
|
||||||
|
TrackingPage* m_widget;
|
||||||
|
QString m_installTrackingUrl;
|
||||||
|
|
||||||
struct TrackingEnabled
|
struct TrackingEnabled
|
||||||
{
|
{
|
||||||
bool settingEnabled; // Enabled in config file
|
bool settingEnabled; // Enabled in config file
|
||||||
@ -70,11 +73,11 @@ private:
|
|||||||
: settingEnabled( false )
|
: settingEnabled( false )
|
||||||
, userEnabled( false )
|
, userEnabled( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
bool enabled() const { return settingEnabled && userEnabled; }
|
||||||
};
|
};
|
||||||
TrackingEnabled m_installTracking, m_machineTracking, m_userTracking;
|
TrackingEnabled m_installTracking, m_machineTracking, m_userTracking;
|
||||||
|
|
||||||
TrackingPage* m_widget;
|
|
||||||
|
|
||||||
inline TrackingEnabled& tracking( TrackingType t )
|
inline TrackingEnabled& tracking( TrackingType t )
|
||||||
{
|
{
|
||||||
if (t == TrackingType::UserTracking)
|
if (t == TrackingType::UserTracking)
|
||||||
|
@ -46,10 +46,12 @@
|
|||||||
# The install area has one specific configuration key:
|
# The install area has one specific configuration key:
|
||||||
# url: this URL (remember to include the protocol, and prefer https)
|
# url: this URL (remember to include the protocol, and prefer https)
|
||||||
# is fetched (with a GET request, and the data discarded) at
|
# is fetched (with a GET request, and the data discarded) at
|
||||||
# the end of the installation process. The token $MACHINE
|
# the end of the installation process. The following tokens
|
||||||
# in the URL is replaced by the machine-id of the installed
|
# are replaced in the url (possibly by blank strings, or by 0).
|
||||||
# system, if it is available, and otherwise blank. Typically
|
# - $CPU (cpu make and model)
|
||||||
# you would add `?id=$MACHINE` as a GET parameter.
|
# - $MEMORY (amount of main memory available)
|
||||||
|
# - $DISK (total amount of disk attached)
|
||||||
|
# Typically these are used as GET parameters, as in the example.
|
||||||
#
|
#
|
||||||
# Note that phone-home only works if the system has an internet
|
# Note that phone-home only works if the system has an internet
|
||||||
# connection; it is a good idea to require internet in the welcome
|
# connection; it is a good idea to require internet in the welcome
|
||||||
@ -58,7 +60,7 @@ install:
|
|||||||
enabled: false
|
enabled: false
|
||||||
default: false
|
default: false
|
||||||
policy: "https://github.com/calamares/calamares/wiki/Users-Guide#installation-tracking"
|
policy: "https://github.com/calamares/calamares/wiki/Users-Guide#installation-tracking"
|
||||||
# url: "https://example.com/install.php"
|
# url: "https://example.com/install.php?c=$CPU&m=$MEMORY"
|
||||||
|
|
||||||
# The machine area has one specific configuration key:
|
# The machine area has one specific configuration key:
|
||||||
# style: This string specifies what kind of tracking configuration
|
# style: This string specifies what kind of tracking configuration
|
||||||
|
Loading…
Reference in New Issue
Block a user