diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index fe1770c0a9df5..56eba82fc1053 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -144,10 +144,23 @@ def report_test_bot_test(step_command_short, passed) 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: }