Merge pull request #17154 from Homebrew/cleanup_test_bot_analytics

utils/analytics: cleanup test-bot analytics.
This commit is contained in:
Mike McQuaid 2024-04-26 15:16:14 +01:00 committed by GitHub
commit af0f115a23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,10 +144,23 @@ module Utils
os: HOMEBREW_SYSTEM,
}
command_and_package, options =
step_command_short.split
.partition { |arg| !arg.start_with?("-") }
# Strip out any flag values to reduce cardinality and preserve privacy.
command = step_command_short.split
.map { |arg| arg.sub(/=.*/, "=") }
.join(" ")
# Sort options to ensure consistent ordering and improve readability.
options = options.join(" ")
.split
.join(" ")
.split(/(-+)/)
.map { |a| a.sub(/[ =].+/, " ") }
.join(" ")
.strip
.split
.sort
command = (command_and_package + options).join(" ")
# Fields can have high cardinality.
fields = { command: }