From a21ddc57090ddb366cc2dccc7b66f8dfe163e8f8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 10 Mar 2026 20:07:23 +0100 Subject: [PATCH] #13728 Telemetry: Include OS info for all events Add OS info (os.type, os.version, os.name) to all non-crash events in reportEventAsync. Consolidate OS info and hashUsername into an anonymous namespace with a shared addOsInfo helper function. --- .../Telemetry/RiaOpenTelemetryManager.cpp | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/Telemetry/RiaOpenTelemetryManager.cpp b/ApplicationLibCode/Application/Tools/Telemetry/RiaOpenTelemetryManager.cpp index 89612ea0ef..b82b25394a 100644 --- a/ApplicationLibCode/Application/Tools/Telemetry/RiaOpenTelemetryManager.cpp +++ b/ApplicationLibCode/Application/Tools/Telemetry/RiaOpenTelemetryManager.cpp @@ -206,24 +206,6 @@ bool RiaOpenTelemetryManager::reinitialize() return initialize(); } -//-------------------------------------------------------------------------------------------------- -/// Create a stable, anonymized hash of username for privacy-preserving telemetry -/// Uses SHA-256 to ensure consistent hashing across sessions while protecting user identity -//-------------------------------------------------------------------------------------------------- -static std::string hashUsername( const std::string& username ) -{ - if ( username.empty() ) - { - return ""; - } - - QByteArray usernameBytes = QString::fromStdString( username ).toUtf8(); - QByteArray hash = QCryptographicHash::hash( usernameBytes, QCryptographicHash::Sha256 ); - - // Convert to hex string for readability in telemetry - return hash.toHex().toStdString(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -254,6 +236,35 @@ bool RiaOpenTelemetryManager::isEventAllowed( const std::string& eventName ) con return denylist.isEmpty() || !matches( name, denylist ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +namespace +{ +// Create a stable, anonymized hash of username for privacy-preserving telemetry +// Uses SHA-256 to ensure consistent hashing across sessions while protecting user identity +std::string hashUsername( const std::string& username ) +{ + if ( username.empty() ) + { + return ""; + } + + QByteArray usernameBytes = QString::fromStdString( username ).toUtf8(); + QByteArray hash = QCryptographicHash::hash( usernameBytes, QCryptographicHash::Sha256 ); + + // Convert to hex string for readability in telemetry + return hash.toHex().toStdString(); +} + +void addOsInfo( std::map& attributes ) +{ + attributes["os.type"] = QSysInfo::productType().toStdString(); + attributes["os.version"] = QSysInfo::productVersion().toStdString(); + attributes["os.name"] = QSysInfo::prettyProductName().toStdString(); +} +} // namespace + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -291,6 +302,8 @@ void RiaOpenTelemetryManager::reportEventAsync( const std::string& eventName, co { enrichedAttributes["user.hash"] = hashUsername( m_username ); } + + addOsInfo( enrichedAttributes ); } m_eventQueue.emplace( eventName, enrichedAttributes ); @@ -366,9 +379,7 @@ void RiaOpenTelemetryManager::reportCrash( int signalCode, const std::stacktrace attributes["service.version"] = RiaPreferencesOpenTelemetry::current()->serviceVersion().toStdString(); // Add system information - attributes["os.type"] = QSysInfo::productType().toStdString(); - attributes["os.version"] = QSysInfo::productVersion().toStdString(); - attributes["os.name"] = QSysInfo::prettyProductName().toStdString(); + addOsInfo( attributes ); // Add real username for crash reports (not hashed - needed for debugging critical issues) {