Class: Gosquared::Tracking

Inherits:
Object
  • Object
show all
Defined in:
lib/gosquared/tracking.rb

Constant Summary collapse

BASEURL =
'https://api.gosquared.com/tracking/v1/'.freeze
DIMENSIONS =
%w[event identify pageview ping properties timeout transaction].freeze

Instance Method Summary collapse

Constructor Details

#initialize(api_key, site_token, client = Gosquared::Client.new) ⇒ Tracking

Returns a new instance of Tracking.



8
9
10
11
12
# File 'lib/gosquared/tracking.rb', line 8

def initialize(api_key, site_token, client = Gosquared::Client.new)
  @site_token = site_token
  @api_key = api_key
  @client = client
end

Instance Method Details

#postObject



22
23
24
25
26
27
# File 'lib/gosquared/tracking.rb', line 22

def post
  check_for_nil_user
  response = @client.post(url, @data)
  @data = nil if response.code === '200'
  response
end

#urlObject



29
30
31
# File 'lib/gosquared/tracking.rb', line 29

def url
  url = BASEURL + @dimension + "?api_key=#{@api_key}" + "&site_token=#{@site_token}"
end