Merge pull request #4620 from brianmorton/hbc_analytics
Add analytics to cask installs
This commit is contained in:
		
						commit
						bab5b02293
					
				@ -90,6 +90,10 @@ module Hbc
 | 
			
		||||
      install_artifacts
 | 
			
		||||
      enable_accessibility_access
 | 
			
		||||
 | 
			
		||||
      unless @cask.tap&.private?
 | 
			
		||||
        ::Utils::Analytics.report_event("cask_install", @cask.token)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      puts summary
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -22,18 +22,22 @@ module Homebrew
 | 
			
		||||
    HOMEBREW_REPOSITORY.cd do
 | 
			
		||||
      analytics_message_displayed =
 | 
			
		||||
        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 =
 | 
			
		||||
        Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle
 | 
			
		||||
      if analytics_message_displayed != "true" &&
 | 
			
		||||
         cask_analytics_message_displayed != "true" &&
 | 
			
		||||
         analytics_disabled != "true" &&
 | 
			
		||||
         !ENV["HOMEBREW_NO_ANALYTICS"] &&
 | 
			
		||||
         !ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"]
 | 
			
		||||
 | 
			
		||||
        ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
 | 
			
		||||
        # Use the shell's audible bell.
 | 
			
		||||
        print "\a"
 | 
			
		||||
 | 
			
		||||
        # 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
 | 
			
		||||
          #{Tty.bold}Read the analytics documentation (and how to opt-out) here:
 | 
			
		||||
            #{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset}
 | 
			
		||||
@ -43,6 +47,7 @@ module Homebrew
 | 
			
		||||
        # Consider the message possibly missed if not a TTY.
 | 
			
		||||
        if $stdout.tty?
 | 
			
		||||
          safe_system "git", "config", "--local", "--replace-all", "homebrew.analyticsmessage", "true"
 | 
			
		||||
          safe_system "git", "config", "--local", "--replace-all", "homebrew.caskanalyticsmessage", "true"
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,9 @@ Homebrew's analytics record some shared information for every event:
 | 
			
		||||
 | 
			
		||||
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`
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user