Class: Analytics::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/api_analytics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(privacy_level = 0, server_url = 'https://www.apianalytics-server.com', get_path = ->(env) { env['REQUEST_PATH'] }, get_ip_address = lambda { |env| env['HTTP_CF_CONNECTING_IP'] || (env['HTTP_X_FORWARDED_FOR'] && env['HTTP_X_FORWARDED_FOR'].split(',').first&.strip) || env['HTTP_X_REAL_IP'] || env['REMOTE_ADDR'] }, get_hostname = ->(env) { env['HTTP_HOST'] }, get_user_agent = ->(env) { env['HTTP_USER_AGENT'] }, get_user_id = ->(_env) { nil }) ⇒ Config

Returns a new instance of Config.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/api_analytics.rb', line 87

def initialize(
  privacy_level = 0,
  server_url = 'https://www.apianalytics-server.com',
  get_path = ->(env) { env['REQUEST_PATH'] },
  get_ip_address = lambda { |env|
    env['HTTP_CF_CONNECTING_IP'] ||
      (env['HTTP_X_FORWARDED_FOR'] && env['HTTP_X_FORWARDED_FOR'].split(',').first&.strip) ||
      env['HTTP_X_REAL_IP'] ||
      env['REMOTE_ADDR']
  },
  get_hostname = ->(env) { env['HTTP_HOST'] },
  get_user_agent = ->(env) { env['HTTP_USER_AGENT'] },
  get_user_id = ->(_env) { nil }
)
  self.privacy_level = privacy_level
  self.server_url = server_url
  self.get_path = get_path
  self.get_ip_address = get_ip_address
  self.get_hostname = get_hostname
  self.get_user_agent = get_user_agent
  self.get_user_id = get_user_id
end

Instance Attribute Details

#get_hostnameObject

Returns the value of attribute get_hostname

Returns:

  • (Object)

    the current value of get_hostname



86
87
88
# File 'lib/api_analytics.rb', line 86

def get_hostname
  @get_hostname
end

#get_ip_addressObject

Returns the value of attribute get_ip_address

Returns:

  • (Object)

    the current value of get_ip_address



86
87
88
# File 'lib/api_analytics.rb', line 86

def get_ip_address
  @get_ip_address
end

#get_pathObject

Returns the value of attribute get_path

Returns:

  • (Object)

    the current value of get_path



86
87
88
# File 'lib/api_analytics.rb', line 86

def get_path
  @get_path
end

#get_user_agentObject

Returns the value of attribute get_user_agent

Returns:

  • (Object)

    the current value of get_user_agent



86
87
88
# File 'lib/api_analytics.rb', line 86

def get_user_agent
  @get_user_agent
end

#get_user_idObject

Returns the value of attribute get_user_id

Returns:

  • (Object)

    the current value of get_user_id



86
87
88
# File 'lib/api_analytics.rb', line 86

def get_user_id
  @get_user_id
end

#privacy_levelObject

Returns the value of attribute privacy_level

Returns:

  • (Object)

    the current value of privacy_level



86
87
88
# File 'lib/api_analytics.rb', line 86

def privacy_level
  @privacy_level
end

#server_urlObject

Returns the value of attribute server_url

Returns:

  • (Object)

    the current value of server_url



86
87
88
# File 'lib/api_analytics.rb', line 86

def server_url
  @server_url
end