From 6701c207e0d30b16eb6cba24f9da5cb4edf91395 Mon Sep 17 00:00:00 2001 From: Brian Morton Date: Mon, 6 Aug 2018 12:21:48 -0700 Subject: [PATCH 1/9] add anlytics to cask installs --- Library/Homebrew/cask/lib/hbc/installer.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 722e30cd3f..7382ac488a 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -90,6 +90,8 @@ module Hbc install_artifacts enable_accessibility_access + Utils::Analytics.report_event("cask_install", @cask.token) + puts summary end From 37f1ae61b2b7479ba85e56eaf267ea9ea1bfdad1 Mon Sep 17 00:00:00 2001 From: Brian Morton Date: Tue, 14 Aug 2018 10:39:23 -0700 Subject: [PATCH 2/9] add cask analytics msg on brew update --- Library/Homebrew/cmd/update-report.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 43d9d31bc2..9dcf30e73a 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -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.cask.analyticsmessage").chuzzle analytics_disabled = Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle if analytics_message_displayed != "true" && - analytics_disabled != "true" && - !ENV["HOMEBREW_NO_ANALYTICS"] && - !ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"] + 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 and Homebrew Cask have enabled anonymous aggregate user behaviour 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.cask.analyticsmessage", "true" end end From 77c242548eab3df72f4905ffb29b896073ee11d2 Mon Sep 17 00:00:00 2001 From: Brian Morton Date: Wed, 15 Aug 2018 09:13:03 -0700 Subject: [PATCH 3/9] update variable name and msg string per comments --- Library/Homebrew/cmd/update-report.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 9dcf30e73a..594f10593a 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -22,12 +22,12 @@ module Homebrew HOMEBREW_REPOSITORY.cd do analytics_message_displayed = Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chuzzle - cask_analytics_message_displayed = + caskanalyticsmessage = Utils.popen_read("git", "config", "--local", "--get", "homebrew.cask.analyticsmessage").chuzzle analytics_disabled = Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle if analytics_message_displayed != "true" && - cask_analytics_message_displayed != "true" && + caskanalyticsmessage != "true" && analytics_disabled != "true" && !ENV["HOMEBREW_NO_ANALYTICS"] && !ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"] @@ -37,7 +37,7 @@ module Homebrew print "\a" # Use an extra newline and bold to avoid this being missed. - ohai "Homebrew and Homebrew Cask have enabled anonymous aggregate user behaviour analytics." + ohai "Homebrew (and Cask) have enabled anonymous aggregate user behaviour analytics." puts <<~EOS #{Tty.bold}Read the analytics documentation (and how to opt-out) here: #{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset} From 1b51456b4c49c85ef63e91a857296a16b6b902ca Mon Sep 17 00:00:00 2001 From: Brian Morton Date: Wed, 15 Aug 2018 14:22:31 -0700 Subject: [PATCH 4/9] fix module path to ::Utils::Anlytics --- Library/Homebrew/cask/lib/hbc/installer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 7382ac488a..cbe62e1961 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -90,7 +90,7 @@ module Hbc install_artifacts enable_accessibility_access - Utils::Analytics.report_event("cask_install", @cask.token) + ::Utils::Analytics.report_event("cask_install", @cask.token) puts summary end From ea29158a4d0a9f1e4a8da519012833f3d54c9ed5 Mon Sep 17 00:00:00 2001 From: Brian Morton Date: Wed, 15 Aug 2018 14:23:31 -0700 Subject: [PATCH 5/9] update git config key for analytics bool --- Library/Homebrew/cmd/update-report.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 594f10593a..dbd42137bc 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -23,7 +23,7 @@ module Homebrew analytics_message_displayed = Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chuzzle caskanalyticsmessage = - Utils.popen_read("git", "config", "--local", "--get", "homebrew.cask.analyticsmessage").chuzzle + 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" && @@ -47,7 +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.cask.analyticsmessage", "true" + safe_system "git", "config", "--local", "--replace-all", "homebrew.caskanalyticsmessage", "true" end end From 61db35f77d621c9624ef62b9b15381d86a93b958 Mon Sep 17 00:00:00 2001 From: Claudia Date: Thu, 16 Aug 2018 08:56:46 +0200 Subject: [PATCH 6/9] brew style --- Library/Homebrew/cmd/update-report.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index dbd42137bc..e89fe6f790 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -27,10 +27,10 @@ module Homebrew analytics_disabled = Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle if analytics_message_displayed != "true" && - caskanalyticsmessage != "true" && - analytics_disabled != "true" && - !ENV["HOMEBREW_NO_ANALYTICS"] && - !ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"] + caskanalyticsmessage != "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. From b068e4b92706ae5541ef38cdd40490b86471b990 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 18 Aug 2018 08:26:44 +0100 Subject: [PATCH 7/9] update-report: tweak cask analytics messaging. --- Library/Homebrew/cmd/update-report.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index e89fe6f790..13571da01e 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -22,12 +22,12 @@ module Homebrew HOMEBREW_REPOSITORY.cd do analytics_message_displayed = Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chuzzle - caskanalyticsmessage = + 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" && - caskanalyticsmessage != "true" && + cask_analytics_message_displayed != "true" && analytics_disabled != "true" && !ENV["HOMEBREW_NO_ANALYTICS"] && !ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"] @@ -37,7 +37,7 @@ module Homebrew print "\a" # Use an extra newline and bold to avoid this being missed. - ohai "Homebrew (and Cask) have 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} From 077e9f0c534136da14450eaf459afad6fd5217b7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 18 Aug 2018 08:48:49 +0100 Subject: [PATCH 8/9] hbc/installer: don't send analytics for private taps. --- Library/Homebrew/cask/lib/hbc/installer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index cbe62e1961..a0fe425141 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -90,7 +90,9 @@ module Hbc install_artifacts enable_accessibility_access - ::Utils::Analytics.report_event("cask_install", @cask.token) + unless @cask.tap&.private? + ::Utils::Analytics.report_event("cask_install", @cask.token) + end puts summary end From 86f27baea35275678725eac6110bd0f04ed609c5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 18 Aug 2018 08:49:07 +0100 Subject: [PATCH 9/9] docs/Analytics: note `install_on_request` and `cask_install`. --- docs/Analytics.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Analytics.md b/docs/Analytics.md index 12ded5bc31..b989d30b85 100644 --- a/docs/Analytics.md +++ b/docs/Analytics.md @@ -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.