mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 23:50:19 -05:00
#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.
This commit is contained in:
1 parent
5e29dc0d55
commit
a21ddc5709
1 file changed
+32
-21
@@ -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<std::string, std::string>& 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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user