From ef8ad107418c9b66547c1f5f2eea59d22f080ec7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 16 Feb 2023 12:59:46 +0000 Subject: [PATCH 1/2] utils/analytics: fix BuildError reporting. Need to ensure we call the correct methods to avoid duplicates. --- Library/Homebrew/utils/analytics.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 42fcd98003..9c3907e159 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -161,7 +161,7 @@ module Utils else formula_full_name end - report_event("BuildError", package_and_options) + report_google_event("BuildError", package_and_options) end sig { params(exception: Exception).void } @@ -177,7 +177,7 @@ module Utils else formula_full_name end - report_event(:build_error, package_and_options) + report_influx_event(:build_error, package_and_options) end def messages_displayed? From a83fef7b417c415ab6bd90f9f1ab073f931d1307 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 16 Feb 2023 13:15:04 +0000 Subject: [PATCH 2/2] utils/analytics: cleanup data. Based on reviewing InfluxDB buckets. --- Library/Homebrew/utils/analytics.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 9c3907e159..5accb78790 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -78,7 +78,7 @@ module Utils def report_influx(measurement, package_and_options, on_request, additional_tags = {}) # Append general information to device information tags = additional_tags.merge(package_and_options: package_and_options, on_request: !on_request.nil?) - .compact_blank + .compact .map { |k, v| "#{k}=#{v.to_s.sub(" ", "\\ ")}" } # convert to key/value parameters .join(",") @@ -346,6 +346,10 @@ module Utils version = "#{version}-dev" if HOMEBREW_VERSION.include?("-") prefix = Homebrew.default_prefix? ? HOMEBREW_PREFIX.to_s : "custom-prefix" + # Cleanup quotes and patch/patchset versions to reduce cardinality. + os_version = OS_VERSION.tr('"', "") + .gsub(/(\d+\.\d+)(\.\d+)?(-\d)?/, '\1') + { version: version, prefix: prefix, @@ -354,7 +358,7 @@ module Utils developer: Homebrew::EnvConfig.developer?, arch: HOMEBREW_PHYSICAL_PROCESSOR, os: HOMEBREW_SYSTEM, - os_name_and_version: OS_VERSION, + os_name_and_version: os_version, } end end