Class: Ahoy::VisitProperties

Inherits:
Object
  • Object
show all
Defined in:
lib/ahoy/visit_properties.rb

Constant Summary collapse

REQUEST_KEYS =
[:ip, :user_agent, :referrer, :landing_page, :platform, :app_version, :os_version, :screen_height, :screen_width]
TRAFFIC_SOURCE_KEYS =
[:referring_domain, :search_keyword]
UTM_PARAMETER_KEYS =
[:utm_source, :utm_medium, :utm_term, :utm_content, :utm_campaign]
TECHNOLOGY_KEYS =
[:browser, :os, :device_type]
LOCATION_KEYS =
[:country, :region, :city, :postal_code, :latitude, :longitude]
KEYS =
REQUEST_KEYS + TRAFFIC_SOURCE_KEYS + UTM_PARAMETER_KEYS + TECHNOLOGY_KEYS + LOCATION_KEYS

Instance Method Summary collapse

Constructor Details

#initialize(request, options = {}) ⇒ VisitProperties

Returns a new instance of VisitProperties.



17
18
19
20
# File 'lib/ahoy/visit_properties.rb', line 17

def initialize(request, options = {})
  @request = request
  @options = options
end

Instance Method Details

#[](key) ⇒ Object



22
23
24
# File 'lib/ahoy/visit_properties.rb', line 22

def [](key)
  send(key)
end

#keysObject



26
27
28
29
30
31
32
# File 'lib/ahoy/visit_properties.rb', line 26

def keys
  if Ahoy.geocode == true # no location keys for :async
    KEYS
  else
    KEYS - LOCATION_KEYS
  end
end

#to_hashObject



34
35
36
# File 'lib/ahoy/visit_properties.rb', line 34

def to_hash
  keys.inject({}) { |memo, key| memo[key] = send(key); memo }
end