aboutsummaryrefslogtreecommitdiffstats
path: root/src/usagestatisticplugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/usagestatisticplugin.cpp')
-rw-r--r--src/usagestatisticplugin.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/usagestatisticplugin.cpp b/src/usagestatisticplugin.cpp
index b30f387..380083f 100644
--- a/src/usagestatisticplugin.cpp
+++ b/src/usagestatisticplugin.cpp
@@ -54,6 +54,17 @@ namespace UsageStatistic::Internal {
static UsageStatisticPlugin *m_instance = nullptr;
+#define QT_WITH_CONTEXTDATA QT_VERSION_CHECK(6, 9, 2)
+
+static void addEvent(QInsightTracker *tracker, const QString &key, const QString &data)
+{
+#if QT_VERSION >= QT_WITH_CONTEXTDATA
+ tracker->contextData(key, data);
+#else
+ tracker->interaction(key, data, 0);
+#endif
+}
+
static QString hashed(const QString &path)
{
return QString::fromLatin1(
@@ -88,11 +99,11 @@ class UILanguage : public QObject
public:
UILanguage(QInsightTracker *tracker)
{
- tracker->interaction(":CONFIG:UILanguage", ICore::userInterfaceLanguage(), 0);
+ addEvent(tracker, ":CONFIG:UILanguage", ICore::userInterfaceLanguage());
const QStringList languages = QLocale::system().uiLanguages();
- tracker->interaction(":CONFIG:SystemLanguage",
- languages.isEmpty() ? QString("Unknown") : languages.first(),
- 0);
+ addEvent(tracker,
+ ":CONFIG:SystemLanguage",
+ languages.isEmpty() ? QString("Unknown") : languages.first());
}
};
@@ -102,13 +113,11 @@ class Theme : public QObject
public:
Theme(QInsightTracker *tracker)
{
- tracker->interaction(":CONFIG:Theme",
- creatorTheme() ? creatorTheme()->id() : QString("Unknown"),
- 0);
+ addEvent(tracker, ":CONFIG:Theme", creatorTheme() ? creatorTheme()->id() : QString("Unknown"));
const QString systemTheme = QString::fromUtf8(QMetaEnum::fromType<Qt::ColorScheme>().valueToKey(
int(Utils::Theme::systemColorScheme())))
.toLower();
- tracker->interaction(":CONFIG:SystemTheme", systemTheme, 0);
+ addEvent(tracker, ":CONFIG:SystemTheme", systemTheme);
}
};
@@ -152,7 +161,7 @@ public:
+ "\"],\"qtversion\":\""
+ qtVersion->qtVersion().toString() + "\"}";
qCDebug(qtmodulesLog) << qPrintable(json);
- tracker->interaction("QtModules", json, 0);
+ addEvent(tracker, "QtModules", json);
});
});
}
@@ -185,7 +194,7 @@ public:
+ "\",\"qtversion\":\""
+ qtVersion->qtVersion().toString() + "\"}";
qCDebug(qtexampleLog) << qPrintable(json);
- tracker->interaction("QtExample", json, 0);
+ addEvent(tracker, "QtExample", json);
return;
}
});
@@ -423,8 +432,12 @@ void UsageStatisticPlugin::createProviders()
{
// startup configs first, otherwise they will be attributed to the UI state
m_providers.push_back(std::make_unique<Theme>(m_tracker.get()));
+ // module and example telemetry require QInsightTracker::contextData to
+ // work reliably, because the key of QInsightTracker::interaction is limited to 255 characters.
+#if QT_VERSION >= QT_WITH_CONTEXTDATA
m_providers.push_back(std::make_unique<QtModules>(m_tracker.get()));
m_providers.push_back(std::make_unique<QtExample>(m_tracker.get()));
+#endif
// not needed for QDS
if (!ICore::isQtDesignStudio()) {