Class: Metric::Track
- Inherits:
-
Object
- Object
- Metric::Track
- Defined in:
- lib/metric/track.rb
Overview
Used to track metrics
Class Method Summary collapse
-
.compose(metric, options = {}) ⇒ String
Generate the url with query strings.
-
.track(metric, options = {}) ⇒ nil
Track the metric.
Class Method Details
.compose(metric, options = {}) ⇒ String
Generate the url with query strings
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/metric/track.rb', line 14 def self.compose(metric, = {}) amount = [:amount] date = [:date] = [:meta] customer = [:customer] parameters = {"metric" => metric, "amount" => amount, "date" => date, "meta" => , "customer" => customer} api_key = Metric.configuration.api_key url = Metric.configuration.protocol + "://" + Metric.configuration.host url << "/v1/sites/#{api_key}/track?" url << Metric::Util.build_query_string(parameters) url end |
.track(metric, options = {}) ⇒ nil
Note:
curl is called in a seperate thread so this won’t block execution
Track the metric
35 36 37 38 39 40 41 |
# File 'lib/metric/track.rb', line 35 def self.track(metric, = {}) return if quit_early?() url = compose(metric, ) Thread.new do `curl "#{url}" 2>&1 ; ` end end |