QInsightConfiguration Class

Configuration class for the Qt Insight Tracker. 更多...

头: #include <QInsightConfiguration>
qmake: QT += insighttracker
实例化: InsightConfiguration
继承: QObject

公共函数

virtual QString appBuild () const = 0
virtual int batchSize () const = 0
virtual QStringList categories () = 0
virtual QString deviceModel () const = 0
virtual QString deviceScreenType () const = 0
virtual QString deviceVariant () const = 0
virtual QStringList events () = 0
virtual bool isValid () = 0
virtual QString platform () const = 0
virtual bool remoteConfig () const = 0
virtual int remoteConfigInterval () const = 0
virtual QString server () const = 0
virtual void setAppBuild (const QString & appBuild ) = 0
virtual void setBatchSize (int batchSize ) = 0
virtual void setCategories (const QStringList & categories ) = 0
virtual void setDeviceModel (const QString & deviceModel ) = 0
virtual void setDeviceScreenType (const QString & deviceScreenType ) = 0
virtual void setDeviceVariant (const QString & deviceVariant ) = 0
virtual void setEvents (const QStringList & events ) = 0
virtual void setPlatform (const QString & platform ) = 0
virtual void setRemoteConfig (bool enabled ) = 0
virtual void setRemoteConfigInterval (int syncInterval ) = 0
virtual void setServer (const QString & server ) = 0
virtual void setStoragePath (const QString & storagePath ) = 0
virtual void setStorageSize (int storageSize ) = 0
virtual void setStorageType (const QString & storageType ) = 0
virtual void setSyncInterval (int syncInterval ) = 0
virtual void setToken (const QString & token ) = 0
virtual void setUserId (const QString & userId ) = 0
virtual QString storagePath () const = 0
virtual int storageSize () const = 0
virtual QString storageType () const = 0
virtual int syncInterval () const = 0
virtual QString token () const = 0
virtual QString userId () = 0

信号

void appBuildChanged (const QString & appBuild )
void batchSizeChanged (int batchSize )
void categoriesChanged (const QStringList & categories )
void deviceModelChanged (const QString & deviceModel )
void deviceScreenTypeChanged (const QString & deviceScreenType )
void deviceVariantChanged (const QString & deviceVariant )
void eventsChanged (const QStringList & events )
void platformChanged (const QString & platform )
void remoteConfigChanged (bool enabled )
void remoteConfigIntervalChanged (int syncInterval )
void serverChanged (const QString & server )
void storagePathChanged (const QString & storagePath )
void storageSizeChanged (int storageSize )
void storageTypeChanged (const QString & storageType )
void syncIntervalChanged (int syncInterval )
void tokenChanged (const QString & token )
void userIdChanged (const QString & userId )

详细描述

Use QInsightConfiguration to configure the tracker. The tracker reads initial 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" : "",
    "storage_size" : 0,
    "sync" : {
        "interval" : {
            "seconds" : 0
            "minutes" : 0
            "hours" : 1
            "days" : 0
            "months" : 0
        },
        "max_batch_size" : 100
    },
    "config_sync" : {
        "enabled" : true
        "interval" : {
            "seconds" : 0
            "minutes" : 0
            "hours" : 0
            "days" : 1
            "months" : 0
        },
    },
    "categories" : [
        "debug"
    ],
    "events" : [
        "KeyPress",
        "KeyRelease",
        "MouseButtonPress",
        "MouseButtonRelease",
        "Quit",
        "Resize"
    ]
}
					

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 () 和 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.

Two additional storage types are supported: SQLITE-ZLIB and SQLITE-ZSTD . These provide sqlite storage but compress the event data to save disk space. Both zlib and zstd algorithms are used with a dictionary-based compression where the dictionary is created from the first collected events. In general, zstd offers faster compression with higher compression ratio, but requires more memory to train the dictionary.

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::setStorageSize () can be used to limit the number of events that can be cached. When using SQLITE storage type, the oldest events are removed if storage size is exceeded. The default size (0) sets no limits to the storage size.

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 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.

QInsightConfiguration::setRemoteConfig and QInsightConfiguration::setRemoteConfigInterval () can be used to enable the use of remote configurations and configure how often the remote configurations are synced from the back-end server. The API takes the value in seconds, while the json configuration file can be configured also with minutes, hours, days, and months. If QInsightConfiguration::setRemoteConfigInterval () is not set, the interval from QInsightConfiguration::SyncInterval() is used.

QInsightConfiguration::setCategories () allows filtering of tracked events based on the category used in the API calls for QInsightTracker::interaction () 和 QInsightTracker::transition () events or the attached property InsightCategory::category for the automatic QEvent::type 事件。

QInsightConfiguration::setEvents () can be used to enable tracking of automatic events from Qt's 事件系统 . All valid event types in QEvent::Type 可以使用。

成员函数文档编制

[pure virtual] QString QInsightConfiguration:: appBuild () const

Returns current application's build version.

注意: Getter function for property appBuild.

另请参阅 setAppBuild ().

[pure virtual] int QInsightConfiguration:: batchSize () const

Returns current sync batch size.

注意: Getter function for property batchSize.

另请参阅 setBatchSize ().

[pure virtual] QStringList QInsightConfiguration:: categories ()

Returns currently enabled categories.

注意: Getter function for property categories.

另请参阅 setCategories ().

[pure virtual] QString QInsightConfiguration:: deviceModel () const

Returns current device model.

注意: Getter function for property deviceModel.

另请参阅 setDeviceModel ().

[pure virtual] QString QInsightConfiguration:: deviceScreenType () const

Returns current screen type.

注意: Getter function for property deviceScreenType.

另请参阅 setDeviceScreenType ().

[pure virtual] QString QInsightConfiguration:: deviceVariant () const

Returns current device variant.

注意: Getter function for property deviceVariant.

另请参阅 setDeviceVariant ().

[pure virtual] QStringList QInsightConfiguration:: events ()

Returns currently tracked events types.

注意: getter 函数对于特性 event .

另请参阅 setEvents ().

[pure virtual] bool QInsightConfiguration:: isValid ()

Returns true if configuration is valid.

注意: Getter function for property valid.

[pure virtual] QString QInsightConfiguration:: platform () const

Returns current platform.

注意: Getter function for property platform.

另请参阅 setPlatform ().

[pure virtual] bool QInsightConfiguration:: remoteConfig () const

Returns true if remote configuration sync is enabled.

注意: Getter function for property remoteConfig.

另请参阅 setRemoteConfig ().

[pure virtual] int QInsightConfiguration:: remoteConfigInterval () const

Returns current remote configuration sync interval in seconds.

注意: Getter function for property remoteConfigInterval.

另请参阅 setRemoteConfigInterval ().

[pure virtual] QString QInsightConfiguration:: server () const

Returns current back-end server address.

注意: Getter function for property server.

另请参阅 setServer ().

[pure virtual] void QInsightConfiguration:: setAppBuild (const QString & appBuild )

Set application's build version appBuild .

注意: setter 函数对于特性 appBuild .

另请参阅 appBuild ().

[pure virtual] void QInsightConfiguration:: setBatchSize ( int batchSize )

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

注意: setter 函数对于特性 batchSize .

另请参阅 batchSize ().

[pure virtual] void QInsightConfiguration:: setCategories (const QStringList & categories )

Set list of enabled categories to categories .

注意: setter 函数对于特性 categories .

另请参阅 categories ().

[pure virtual] void QInsightConfiguration:: setDeviceModel (const QString & deviceModel )

Set device model to deviceModel .

注意: setter 函数对于特性 deviceModel .

另请参阅 deviceModel ().

[pure virtual] void QInsightConfiguration:: setDeviceScreenType (const QString & deviceScreenType )

Set device screen type to deviceScreenType .

注意: setter 函数对于特性 deviceScreenType .

另请参阅 deviceScreenType ().

[pure virtual] void QInsightConfiguration:: setDeviceVariant (const QString & deviceVariant )

Set device variant to deviceVariant .

注意: setter 函数对于特性 deviceVariant .

另请参阅 deviceVariant ().

[pure virtual] void QInsightConfiguration:: setEvents (const QStringList & events )

Set list of tracked event types to events . All valid event types in QEvent::Type 可以使用。

注意: setter 函数对于特性 event .

另请参阅 events ().

[pure virtual] void QInsightConfiguration:: setPlatform (const QString & platform )

Set platform to platform

注意: setter 函数对于特性 platform .

另请参阅 platform ().

[pure virtual] void QInsightConfiguration:: setRemoteConfig ( bool enabled )

Set remote configuration sync state to enabled .

注意: setter 函数对于特性 remoteConfig .

另请参阅 remoteConfig ().

[pure virtual] void QInsightConfiguration:: setRemoteConfigInterval ( int syncInterval )

Set remote configuration sync interval to syncInterval 秒。

注意: setter 函数对于特性 remoteConfigInterval .

另请参阅 remoteConfigInterval ().

[pure virtual] void QInsightConfiguration:: setServer (const QString & server )

Set server address to server .

注意: setter 函数对于特性 server .

另请参阅 server ().

[pure virtual] void QInsightConfiguration:: setStoragePath (const QString & storagePath )

Set storage path to storagePath .

注意: setter 函数对于特性 storagePath .

另请参阅 storagePath ().

[pure virtual] void QInsightConfiguration:: setStorageSize ( int storageSize )

Set storage size to storageSize .

注意: setter 函数对于特性 storageSize .

另请参阅 storageSize ().

[pure virtual] void QInsightConfiguration:: setStorageType (const QString & storageType )

Set storage type to storageType .

注意: setter 函数对于特性 storageType .

另请参阅 storageType ().

[pure virtual] void QInsightConfiguration:: setSyncInterval ( int syncInterval )

Set sync interval to syncInterval 秒。

注意: setter 函数对于特性 syncInterval .

另请参阅 syncInterval ().

[pure virtual] void QInsightConfiguration:: setToken (const QString & token )

Set server token to token .

注意: setter 函数对于特性 token .

另请参阅 token ().

[pure virtual] void QInsightConfiguration:: setUserId (const QString & userId )

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

注意: setter 函数对于特性 userId .

另请参阅 userId ().

[pure virtual] QString QInsightConfiguration:: storagePath () const

Returns current storage path.

注意: Getter function for property storagePath.

另请参阅 setStoragePath ().

[pure virtual] int QInsightConfiguration:: storageSize () const

Returns current storage size.

注意: Getter function for property storageSize.

另请参阅 setStorageSize ().

[pure virtual] QString QInsightConfiguration:: storageType () const

Returns current storage type.

注意: Getter function for property storageType.

另请参阅 setStorageType ().

[pure virtual] int QInsightConfiguration:: syncInterval () const

Returns current sync interval in seconds.

注意: Getter function for property syncInterval.

另请参阅 setSyncInterval ().

[pure virtual] QString QInsightConfiguration:: token () const

Returns current server token.

注意: Getter function for property token.

另请参阅 setToken ().

[pure virtual] QString QInsightConfiguration:: userId ()

Returns current user identifier used in the tracked events.

注意: Getter function for property userId.

另请参阅 setUserId ().