Class: Totango::Client
- Inherits:
-
Object
- Object
- Totango::Client
- Defined in:
- lib/totango/client.rb
Instance Method Summary collapse
- #build_url(data) ⇒ Object
-
#initialize(srv_id) ⇒ Client
constructor
A new instance of Client.
- #make_request(url) ⇒ Object
- #track(data = {}) ⇒ Object
Constructor Details
#initialize(srv_id) ⇒ Client
Returns a new instance of Client.
28 29 30 |
# File 'lib/totango/client.rb', line 28 def initialize(srv_id) @srv_id = srv_id end |
Instance Method Details
#build_url(data) ⇒ Object
48 49 50 |
# File 'lib/totango/client.rb', line 48 def build_url(data) [BASE_URI, @srv_id, "&", ArgParser.parse(data).to_params].join end |
#make_request(url) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/totango/client.rb', line 52 def make_request(url) begin open(url) true rescue => e $stderr.puts "[Totango] ERROR making call to Totango: #{e.class} ~> #{e.}" false end end |
#track(data = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/totango/client.rb', line 32 def track(data={}) url = build_url(data) if Totango.on? if Config[:synchronous] make_request(url) else Thread.new { make_request(url) } end else unless Config[:suppress_output] puts "[Totango] Fake call to #{url}. To make a real call, run Totango.on!" end end end |