Merge pull request #14635 from Bo98/api-analytics

This commit is contained in:
Mike McQuaid 2023-02-15 07:21:16 +00:00 committed by GitHub
commit 56adf8cd3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 4 deletions

View File

@ -110,7 +110,9 @@ module Cask
install_artifacts install_artifacts
::Utils::Analytics.report_event("cask_install", @cask.token, on_request: true) unless @cask.tap&.private? if @cask.tap&.should_report_analytics?
::Utils::Analytics.report_event("cask_install", @cask.token, on_request: true)
end
purge_backed_up_versioned_files purge_backed_up_versioned_files

View File

@ -414,7 +414,7 @@ class FormulaInstaller
options = display_options(formula).join(" ") options = display_options(formula).join(" ")
oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header? oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header?
if formula.tap&.installed? && !formula.tap&.private? if formula.tap&.should_report_analytics?
action = "#{formula.full_name} #{options}".strip action = "#{formula.full_name} #{options}".strip
Utils::Analytics.report_event("install", action, on_request: installed_on_request?) Utils::Analytics.report_event("install", action, on_request: installed_on_request?)
end end

View File

@ -670,6 +670,13 @@ class Tap
@pypi_formula_mappings = read_formula_list path/HOMEBREW_TAP_PYPI_FORMULA_MAPPINGS @pypi_formula_mappings = read_formula_list path/HOMEBREW_TAP_PYPI_FORMULA_MAPPINGS
end end
# @private
def should_report_analytics?
return Homebrew::EnvConfig.install_from_api? && official? unless installed?
!private?
end
def ==(other) def ==(other)
other = Tap.fetch(other) if other.is_a?(String) other = Tap.fetch(other) if other.is_a?(String)
self.class == other.class && name == other.name self.class == other.class && name == other.name

View File

@ -144,8 +144,7 @@ module Utils
def report_build_error(exception) def report_build_error(exception)
return unless exception.formula.tap return unless exception.formula.tap
return unless exception.formula.tap.installed? return unless exception.formula.tap.should_report_analytics?
return if exception.formula.tap.private?
action = exception.formula.full_name action = exception.formula.full_name
if (options = exception.options.to_a.map(&:to_s).join(" ").presence) if (options = exception.options.to_a.map(&:to_s).join(" ").presence)