utils/analytics: cleanup test-bot analytics.

Sort options to ensure consistent ordering and improve readability.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
This commit is contained in:
Mike McQuaid 2024-04-26 09:37:48 +01:00
parent f5cde8ad0d
commit 414e221990
No known key found for this signature in database

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(/=.*/, "=") }
# 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: }