diff options
author | Eike Ziller <eike.ziller@qt.io> | 2025-06-27 09:40:39 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2025-08-11 12:11:56 +0000 |
commit | 80352e4d49092706fe87677369abe1cbe530a0f7 (patch) | |
tree | 9b4dae7b858474988f58db34a5d2401d980b34f7 | |
parent | 75573dd1352ce677fdc3fa27b5a06f7e2f33cdd1 (diff) |
Using the `key` of interactions for the actual data was a hack to begin
with, and since that is limited to 255 characters it results in
misleading data.
Fixes: QTCREATORBUG-33126
Change-Id: I3d699dd0a241636ef59fad2b890bed5e8badc494
Reviewed-by: hjk <hjk@qt.io>
-rw-r--r-- | src/usagestatisticplugin.cpp | 33 |
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()) { |