9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/aptible/cli/helpers/telemetry.rb', line 9
def telemetry(cmd, options = {})
token_hash = decode_token
format = Renderer.format
format = 'text' if format.nil?
sub = token_hash[0]['sub']
parsed_url = URI.parse(sub)
path_components = parsed_url.path.split('/')
user_or_org_id = path_components.last
client = HTTPClient.new.tap do |c|
c.cookie_manager = nil
c.connect_timeout = 30
c.send_timeout = 45
c.keep_alive_timeout = 15
c.ssl_config.set_default_paths
end
opts = options.dup
opts.delete(:private_registry_password)
opts.delete(:private_registry_username)
opts.delete(:private_registry_email)
value = {
'email' => token_hash[0]['email'],
'format' => format,
'cmd' => cmd,
'options' => opts,
'version' => version_string,
'os' => RUBY_PLATFORM,
'github' => ENV['GITHUB_ACTIONS'],
'gitlab' => ENV['GITLAB_CI'],
'travis' => ENV['TRAVIS'],
'circleci' => ENV['CIRCLECI'],
'ci' => ENV['CI']
}
begin
uri = URI('https://tuna.aptible.com/www/e')
client.get(
uri,
'id' => SecureRandom.uuid,
'user_id' => user_or_org_id,
'type' => 'cli_telemetry',
'url' => sub,
'value' => value.to_json
)
rescue
end
end
|