Module: Bolt::Analytics
- Defined in:
- lib/bolt/analytics.rb
Defined Under Namespace
Classes: Client, NoopClient
Constant Summary
collapse
- PROTOCOL_VERSION =
1
- APPLICATION_NAME =
'bolt'
- TRACKING_ID =
'UA-120367942-1'
- TRACKING_URL =
'https://google-analytics.com/collect'
- CUSTOM_DIMENSIONS =
{
operating_system: :cd1,
inventory_nodes: :cd2,
inventory_groups: :cd3,
target_nodes: :cd4,
output_format: :cd5,
statement_count: :cd6,
resource_mean: :cd7,
plan_steps: :cd8,
return_type: :cd9,
inventory_version: :cd10,
boltdir_type: :cd11
}.freeze
Class Method Summary
collapse
Class Method Details
.build_client ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/bolt/analytics.rb', line 29
def self.build_client
logger = Logging.logger[self]
config_file = File.expand_path('~/.puppetlabs/bolt/analytics.yaml')
config = load_config(config_file, logger)
if config['disabled'] || ENV['BOLT_DISABLE_ANALYTICS']
logger.debug "Analytics opt-out is set, analytics will be disabled"
NoopClient.new
else
unless config.key?('user-id')
config['user-id'] = SecureRandom.uuid
write_config(config_file, config)
end
Client.new(config['user-id'])
end
rescue StandardError => e
logger.debug "Failed to initialize analytics client, analytics will be disabled: #{e}"
NoopClient.new
end
|
.load_config(filename, logger) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/bolt/analytics.rb', line 50
def self.load_config(filename, logger)
if File.exist?(filename)
YAML.load_file(filename)
else
unless ENV['BOLT_DISABLE_ANALYTICS']
logger.warn <<~ANALYTICS
Bolt collects data about how you use it. You can opt out of providing this data.
To disable analytics data collection, add this line to ~/.puppetlabs/bolt/analytics.yaml :
disabled: true
Read more about what data Bolt collects and why here:
https://puppet.com/docs/bolt/latest/bolt_installing.html#concept-8242
ANALYTICS
end
{}
end
end
|
.write_config(filename, config) ⇒ Object
70
71
72
73
|
# File 'lib/bolt/analytics.rb', line 70
def self.write_config(filename, config)
FileUtils.mkdir_p(File.dirname(filename))
File.write(filename, config.to_yaml)
end
|