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]
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.



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

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

Instance Method Details

#[](key) ⇒ Object



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

def [](key)
  send(key)
end

#keysObject



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

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

#to_hashObject



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

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