QInsightConfiguration Class

Configuration class for the Qt Insight Tracker. More...

Header: #include <QInsightConfiguration>
CMake: find_package(Qt6 REQUIRED COMPONENTS InsightTracker)
target_link_libraries(mytarget PRIVATE Qt6::InsightTracker)
qmake: QT += insighttracker
Instantiated By: InsightConfiguration
Inherits: QObject

Public Functions

QInsightConfiguration(QObject *parent = nullptr)
QString appBuild() const
int batchSize() const
QStringList categories()
QString deviceModel() const
QString deviceScreenType() const
QString deviceVariant() const
QStringList events()
bool isValid()
bool load()
QString platform() const
QString server() const
void setAppBuild(const QString &appBuild)
void setBatchSize(int batchSize)
void setCategories(const QStringList &categories)
void setDeviceModel(const QString &deviceModel)
void setDeviceScreenType(const QString &deviceScreenType)
void setDeviceVariant(const QString &deviceVariant)
void setEvents(const QStringList &events)
void setPlatform(const QString &platform)
void setServer(const QString &server)
void setStoragePath(const QString &storagePath)
void setStorageSize(int storageSize)
void setStorageType(const QString &storageType)
void setSyncInterval(int syncInterval)
void setToken(const QString &token)
void setUserId(const QString &userId)
QString storagePath() const
int storageSize() const
QString storageType() const
int syncInterval() const
QString token() const
QString userId()

Detailed Description

Use QInsightConfiguration to configure the tracker. You must make all configuration changes before enabling the tracking. The tracker reads default values from a configuration file (qtinsight.conf), which is searched from following the locations in a decending order:

  1. Application's resources file.
  2. Application's directory.
  3. Current working directory.
  4. System configuration directories as defined by QStandardPaths::GenericConfigLocation.

Use an environment variable QT_INSIGHT_CONFIG to override the used configuration file.

Example of a JSON configuration file:

{
    "server" : "collect-insight.qt.io",
    "token" : "00000000-0000-0000-0000-000000000000",
    "device_model" :  "model 1",
    "device_variant" : "a",
    "device_screen_type" : "NON_TOUCH",
    "platform" : "app",
    "app_build" : "1.2.3",
    "storage" : "SQLITE",
    "storage_path" : "",
    "sync" : {
        "interval" : {
            "seconds" : 0
            "minutes" : 0
            "hours" : 1
            "days" : 0
            "months" : 0
        },
        "max_batch_size" : 100
    }
}

A token is used to match the data your application sends to your Qt Insight Organization and you can find your token from the Qt Insight Console.

Some of the configuration items are directly linked to the Snowblow Tracker Protocol, which defines the allowed values. These include QInsightConfiguration::setPlatform() and QInsightConfiguration::setDeviceScreenType().

QInsightConfiguration::setStorageType() can be used to configure the storage type, where SQLITE is the default value and use SQLite database to store the events before they are sent to the back-end server. If an unknown storage type is specified or it is explicitly set to an empty string, caching will be disabled. In that case the tracked data will be lost if the back-end server isn't available.

QInsightConfiguration::setStoragePath() can be used to configure the location of the storage. By default, the SQLite database is created in the application's directory.

QInsightConfiguration::setSyncInterval() can be used to configure how often the tracked events are sent to the back-end server. The API takes the value in seconds, while the json configuration file can be configured also with more natural minutes, hours, days, and months. If sync interval is not set, events will never be sent to the backend and cached only in the local storage.

QInsightConfiguration::setBatchSize is used to minimize the overhead when sending, reading and writing to the storage. When synchronizing the cached data to back-end server, at most QInsightConfiguration::batchSize() items will be fetched at once from the storage and sent to back-end server. This is more optimal, than fetching the data one by one. The sent data will be removed from the storage also in batches. The process repeats, until all data is sent. If one batch fails, the synchronization will stop, as the next batches will likely also fail.

Member Function Documentation

QInsightConfiguration::QInsightConfiguration(QObject *parent = nullptr)

Construct a new configuration object with the given parent.

QString QInsightConfiguration::appBuild() const

Returns current application's build version.

Note: Getter function for property appBuild.

See also setAppBuild().

int QInsightConfiguration::batchSize() const

Returns current sync batch size.

Note: Getter function for property batchSize.

See also setBatchSize().

QStringList QInsightConfiguration::categories()

Returns currently enabled categories.

Note: Getter function for property categories.

See also setCategories().

QString QInsightConfiguration::deviceModel() const

Returns current device model.

Note: Getter function for property deviceModel.

See also setDeviceModel().

QString QInsightConfiguration::deviceScreenType() const

Returns current screen type.

Note: Getter function for property deviceScreenType.

See also setDeviceScreenType().

QString QInsightConfiguration::deviceVariant() const

Returns current device variant.

Note: Getter function for property deviceVariant.

See also setDeviceVariant().

QStringList QInsightConfiguration::events()

Returns currently enabled events.

Note: Getter function for property event.

See also setEvents().

bool QInsightConfiguration::isValid()

Returns true if configuratio is valid.

bool QInsightConfiguration::load()

Load existing configurations from a file. Returns true is configuration was successfully loaded.

QString QInsightConfiguration::platform() const

Returns current platform.

Note: Getter function for property platform.

See also setPlatform().

QString QInsightConfiguration::server() const

Returns current server address.

Note: Getter function for property server.

See also setServer().

void QInsightConfiguration::setAppBuild(const QString &appBuild)

Set application's build version appBuild.

Note: Setter function for property appBuild.

See also appBuild().

void QInsightConfiguration::setBatchSize(int batchSize)

Set sync batch size to batchSize. Defines how many events are sent to network in one go.

Note: Setter function for property batchSize.

See also batchSize().

void QInsightConfiguration::setCategories(const QStringList &categories)

Set list of enabled categories to categories.

Note: Setter function for property categories.

See also categories().

void QInsightConfiguration::setDeviceModel(const QString &deviceModel)

Set device model to deviceModel.

Note: Setter function for property deviceModel.

See also deviceModel().

void QInsightConfiguration::setDeviceScreenType(const QString &deviceScreenType)

Set device screen type to deviceScreenType.

Note: Setter function for property deviceScreenType.

See also deviceScreenType().

void QInsightConfiguration::setDeviceVariant(const QString &deviceVariant)

Set device variant to deviceVariant.

Note: Setter function for property deviceVariant.

See also deviceVariant().

void QInsightConfiguration::setEvents(const QStringList &events)

Set list of enabled events to events.

Note: Setter function for property event.

See also events().

void QInsightConfiguration::setPlatform(const QString &platform)

Set platform to platform

Note: Setter function for property platform.

See also platform().

void QInsightConfiguration::setServer(const QString &server)

Set server address to server.

Note: Setter function for property server.

See also server().

void QInsightConfiguration::setStoragePath(const QString &storagePath)

Set storage path to storagePath.

Note: Setter function for property storagePath.

See also storagePath().

void QInsightConfiguration::setStorageSize(int storageSize)

Set storage size to storageSize.

Note: Setter function for property storageSize.

See also storageSize().

void QInsightConfiguration::setStorageType(const QString &storageType)

Set storage type to storageType.

Note: Setter function for property storageType.

See also storageType().

void QInsightConfiguration::setSyncInterval(int syncInterval)

Set sync interval to syncInterval seconds.

Note: Setter function for property syncInterval.

See also syncInterval().

void QInsightConfiguration::setToken(const QString &token)

Set server token to token.

Note: Setter function for property token.

See also token().

void QInsightConfiguration::setUserId(const QString &userId)

Set user identifier to userId. If userId is empty, a generated random UUID will be used.

Note: Setter function for property userId.

See also userId().

QString QInsightConfiguration::storagePath() const

Returns current storage path.

Note: Getter function for property storagePath.

See also setStoragePath().

int QInsightConfiguration::storageSize() const

Returns current storage size.

Note: Getter function for property storageSize.

See also setStorageSize().

QString QInsightConfiguration::storageType() const

Returns current storage type.

Note: Getter function for property storageType.

See also setStorageType().

int QInsightConfiguration::syncInterval() const

Returns current sync interval in seconds.

Note: Getter function for property syncInterval.

See also setSyncInterval().

QString QInsightConfiguration::token() const

Returns current server token.

Note: Getter function for property token.

See also setToken().

QString QInsightConfiguration::userId()

Returns current user identifier used in the tracked events.

Note: Getter function for property userId.

See also setUserId().

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.