11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/pact/support/metrics.rb', line 11
def self.report_metric(event, category, action, value = 1)
do_once_per_thread(:pact_metrics_message_shown) do
if track_events?
Pact.configuration.output_stream.puts "mock WARN: Please note: we are tracking events anonymously to gather important usage statistics like Pact-Ruby version and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment variable to 'true'."
end
end
in_thread do
begin
if track_events?
uri = URI('https://www.google-analytics.com/collect')
req = Net::HTTP::Post.new(uri)
req.set_form_data(create_tracking_event(event, category, action, value))
Net::HTTP.start(uri.hostname, uri.port, read_timeout:2, open_timeout:2, :use_ssl => true ) do |http|
http.request(req)
end
end
rescue StandardError => e
handle_error(e)
end
end
end
|