| 
									
										
										
										
											2023-08-08 13:54:59 -07:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 16:13:34 -07:00
										 |  |  | require "abstract_command" | 
					
						
							| 
									
										
										
										
											2019-01-20 20:04:19 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-01 22:04:46 +08:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2024-03-29 16:13:34 -07:00
										 |  |  |   module Cmd | 
					
						
							|  |  |  |     class Analytics < AbstractCommand | 
					
						
							|  |  |  |       cmd_args do | 
					
						
							|  |  |  |         description <<~EOS | 
					
						
							|  |  |  |           Control Homebrew's anonymous aggregate user behaviour analytics. | 
					
						
							|  |  |  |           Read more at <https://docs.brew.sh/Analytics>. | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 16:13:34 -07:00
										 |  |  |           `brew analytics` [`state`]: | 
					
						
							|  |  |  |           Display the current state of Homebrew's analytics. | 
					
						
							| 
									
										
										
										
											2019-01-20 20:04:19 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 16:13:34 -07:00
										 |  |  |           `brew analytics` (`on`|`off`): | 
					
						
							|  |  |  |           Turn Homebrew's analytics on or off respectively. | 
					
						
							|  |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2020-04-18 12:09:30 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 16:13:34 -07:00
										 |  |  |         named_args %w[state on off regenerate-uuid], max: 1
 | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-05-01 22:04:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 16:13:34 -07:00
										 |  |  |       sig { override.void } | 
					
						
							|  |  |  |       def run | 
					
						
							|  |  |  |         case args.named.first | 
					
						
							|  |  |  |         when nil, "state" | 
					
						
							|  |  |  |           if Utils::Analytics.disabled? | 
					
						
							|  |  |  |             puts "InfluxDB analytics are disabled." | 
					
						
							|  |  |  |           else | 
					
						
							|  |  |  |             puts "InfluxDB analytics are enabled." | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |           puts "Google Analytics were destroyed." | 
					
						
							|  |  |  |         when "on" | 
					
						
							|  |  |  |           Utils::Analytics.enable! | 
					
						
							|  |  |  |         when "off" | 
					
						
							|  |  |  |           Utils::Analytics.disable! | 
					
						
							|  |  |  |         when "regenerate-uuid" | 
					
						
							|  |  |  |           Utils::Analytics.delete_uuid! | 
					
						
							|  |  |  |           opoo "Homebrew no longer uses an analytics UUID so this has been deleted!" | 
					
						
							|  |  |  |           puts "brew analytics regenerate-uuid is no longer necessary." | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           raise UsageError, "unknown subcommand: #{args.named.first}" | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2016-05-01 22:04:46 +08:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |