[tracking] Step 1 of getting the install-tracking URL

- document substitutions
 - build URL when creating jobs
main
Adriaan de Groot 7 years ago
parent a0e8f76348
commit 7311204572

@ -20,6 +20,7 @@
#include "GlobalStorage.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtils.h"
#include "utils/CalamaresUtilsSystem.h"
#include "TrackingViewStep.h"
#include "TrackingPage.h"
@ -113,6 +114,22 @@ QList< Calamares::job_ptr >
TrackingViewStep::jobs() const
{
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 >();
}
@ -132,7 +149,7 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration
settingEnabled = CalamaresUtils::getBool( config, "enabled", false );
userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false );
}
cDebug() << " .. Install tracking: enabled=" << settingEnabled << "default=" << userEnabled;
cDebug() << " .. settable=" << settingEnabled << "default=" << userEnabled;
auto trackingConfiguration = tracking( t );
trackingConfiguration.settingEnabled = settingEnabled;
@ -148,7 +165,11 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration
void
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, "user", TrackingType::UserTracking );
}

@ -61,6 +61,9 @@ public:
private:
QVariantMap setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t );
TrackingPage* m_widget;
QString m_installTrackingUrl;
struct TrackingEnabled
{
bool settingEnabled; // Enabled in config file
@ -70,11 +73,11 @@ private:
: settingEnabled( false )
, userEnabled( false )
{}
bool enabled() const { return settingEnabled && userEnabled; }
};
TrackingEnabled m_installTracking, m_machineTracking, m_userTracking;
TrackingPage* m_widget;
inline TrackingEnabled& tracking( TrackingType t )
{
if (t == TrackingType::UserTracking)

@ -46,10 +46,12 @@
# The install area has one specific configuration key:
# url: this URL (remember to include the protocol, and prefer https)
# is fetched (with a GET request, and the data discarded) at
# the end of the installation process. The token $MACHINE
# in the URL is replaced by the machine-id of the installed
# system, if it is available, and otherwise blank. Typically
# you would add `?id=$MACHINE` as a GET parameter.
# the end of the installation process. The following tokens
# are replaced in the url (possibly by blank strings, or by 0).
# - $CPU (cpu make and model)
# - $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
# connection; it is a good idea to require internet in the welcome
@ -58,7 +60,7 @@ install:
enabled: false
default: false
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:
# style: This string specifies what kind of tracking configuration

Loading…
Cancel
Save