Class: Amplitude::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/amplitude/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Config

Returns a new instance of Config.



10
11
12
# File 'lib/amplitude/config.rb', line 10

def initialize
  reset
end

Instance Attribute Details

#api_key ⇒ Object

Returns the value of attribute api_key.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def api_key
  @api_key
end

#env_var ⇒ Object

Returns the value of attribute env_var.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def env_var
  @env_var
end

#event_prop_formatter ⇒ Object

Returns the value of attribute event_prop_formatter.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def event_prop_formatter
  @event_prop_formatter
end

#iid_generator ⇒ Object

Returns the value of attribute iid_generator.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def iid_generator
  @iid_generator
end

#job_queue ⇒ Object

Returns the value of attribute job_queue.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def job_queue
  @job_queue
end

#secret_key ⇒ Object

Returns the value of attribute secret_key.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def secret_key
  @secret_key
end

#time_formatter ⇒ Object

Returns the value of attribute time_formatter.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def time_formatter
  @time_formatter
end

#user_prop_formatter ⇒ Object

Returns the value of attribute user_prop_formatter.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def user_prop_formatter
  @user_prop_formatter
end

#whitelist ⇒ Object

Returns the value of attribute whitelist.



7
8
9
# File 'lib/amplitude/config.rb', line 7

def whitelist
  @whitelist
end

Class Method Details

.defaults ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/amplitude/config.rb', line 23

def defaults
  {
    api_key: nil,
    secret_key: nil,
    env_var: 'AMPLITUDE_API_KEY',
    job_queue: :default,
    whitelist: i(
      user_id device_id event_type time groups app_version ip platform
      os_name os_version device_brand device_manufacturer device_model
      carrier country region city dma language price quantity revenue
      productId revenueType location_lat location_lng idfa idfv adid
      android_id event_properties user_properties insert_id session_id
      event_id
    ),
    time_formatter: Amplitude::Formatters::Time,
    event_prop_formatter: Amplitude::Formatters::Hash,
    user_prop_formatter: Amplitude::Formatters::Hash,
    iid_generator: ->() { SecureRandom.uuid }
  }
end

Instance Method Details

#reset ⇒ Object



14
15
16
# File 'lib/amplitude/config.rb', line 14

def reset
  self.class.defaults.each { |k, v| send("#{k}=", v) }
end