Merge pull request #4620 from brianmorton/hbc_analytics

Add analytics to cask installs
This commit is contained in:
Mike McQuaid 2018-08-18 09:33:36 +01:00 committed by GitHub
commit bab5b02293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -90,6 +90,10 @@ module Hbc
install_artifacts install_artifacts
enable_accessibility_access enable_accessibility_access
unless @cask.tap&.private?
::Utils::Analytics.report_event("cask_install", @cask.token)
end
puts summary puts summary
end end

View File

@ -22,18 +22,22 @@ module Homebrew
HOMEBREW_REPOSITORY.cd do HOMEBREW_REPOSITORY.cd do
analytics_message_displayed = analytics_message_displayed =
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chuzzle Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chuzzle
cask_analytics_message_displayed =
Utils.popen_read("git", "config", "--local", "--get", "homebrew.caskanalyticsmessage").chuzzle
analytics_disabled = analytics_disabled =
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle
if analytics_message_displayed != "true" && if analytics_message_displayed != "true" &&
cask_analytics_message_displayed != "true" &&
analytics_disabled != "true" && analytics_disabled != "true" &&
!ENV["HOMEBREW_NO_ANALYTICS"] && !ENV["HOMEBREW_NO_ANALYTICS"] &&
!ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"] !ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"]
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
# Use the shell's audible bell. # Use the shell's audible bell.
print "\a" print "\a"
# Use an extra newline and bold to avoid this being missed. # Use an extra newline and bold to avoid this being missed.
ohai "Homebrew has enabled anonymous aggregate user behaviour analytics." ohai "Homebrew has enabled anonymous aggregate formulae and cask analytics."
puts <<~EOS puts <<~EOS
#{Tty.bold}Read the analytics documentation (and how to opt-out) here: #{Tty.bold}Read the analytics documentation (and how to opt-out) here:
#{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset} #{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset}
@ -43,6 +47,7 @@ module Homebrew
# Consider the message possibly missed if not a TTY. # Consider the message possibly missed if not a TTY.
if $stdout.tty? if $stdout.tty?
safe_system "git", "config", "--local", "--replace-all", "homebrew.analyticsmessage", "true" safe_system "git", "config", "--local", "--replace-all", "homebrew.analyticsmessage", "true"
safe_system "git", "config", "--local", "--replace-all", "homebrew.caskanalyticsmessage", "true"
end end
end end

View File

@ -25,7 +25,9 @@ Homebrew's analytics record some shared information for every event:
Homebrew's analytics records the following different events: Homebrew's analytics records the following different events:
- an `event` hit type with the `install` event category and the Homebrew formula from a non-private GitHub tap you have requested to install plus any used options, e.g. `wget --with-pcre` as the action and an event label e.g. `macOS 10.12, non-/usr/local, CI` to indicate the OS version, non-standard installation location and invocation as part of CI. This allows us to identify the formulae that need fixing and where more easily. - an `event` hit type with the `install` event category and the Homebrew formula from a non-private GitHub tap you install plus any used options, e.g. `wget --with-pcre` as the action and an event label e.g. `macOS 10.12, non-/usr/local, CI` to indicate the OS version, non-standard installation location and invocation as part of CI. This allows us to identify the formulae that need fixing and where more easily.
- an `event` hit type with the `install_on_request` event category and the Homebrew formula from a non-private GitHub tap you have requested to install (e.g. explicitly named it with a `brew install`) plus options and an event label as above. This allows us to differentiate the formulae that users intend to install from those pulled in as dependencies.
- an `event` hit type with the `cask_install` event category and the Homebrew cask from a non-private GitHub tap you install as the action and an event label as above. This allows us to identify the casks that need fixing and where more easily.
- an `event` hit type with the `BuildError` event category and the Homebrew formula that failed to install, e.g. `wget` as the action and an event label e.g. `macOS 10.12` - an `event` hit type with the `BuildError` event category and the Homebrew formula that failed to install, e.g. `wget` as the action and an event label e.g. `macOS 10.12`
You can also view all the information that is sent by Homebrew's analytics by setting `HOMEBREW_ANALYTICS_DEBUG=1` in your environment. Please note this will also stop any analytics from being sent. You can also view all the information that is sent by Homebrew's analytics by setting `HOMEBREW_ANALYTICS_DEBUG=1` in your environment. Please note this will also stop any analytics from being sent.