Class: CodeSunset::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/code_sunset/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/code_sunset/configuration.rb', line 24

def initialize
  @enabled = true
  @environment = defined?(Rails) ? Rails.env : ENV.fetch("RAILS_ENV", ENV.fetch("RACK_ENV", "development"))
  @async = true
  @sample_rate = 1.0
  @app_version = ENV["CODE_SUNSET_APP_VERSION"] || ENV["APP_VERSION"] || ENV["GIT_SHA"]
  @identity_fields = i[user_id org_id]
  @hash_identity = false
  @dashboard_authorizer = nil
  @org_resolver = nil
  @user_resolver = nil
  @plan_resolver = nil
  @internal_org_resolver = nil
  @paid_org_resolver = nil
  @alert_webhook_url = nil
  @alert_webhook_proc = nil
  @slack_webhook_url = nil
  @event_retention_days = 90
  @enqueue_failure_policy = :drop
  @enqueue_buffer_size = 1000
  @alert_cooldown = 24.hours
  @custom_filters = {}
end

Instance Attribute Details

#alert_cooldown ⇒ Object

Returns the value of attribute alert_cooldown.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def alert_cooldown
  @alert_cooldown
end

#alert_webhook_proc ⇒ Object

Returns the value of attribute alert_webhook_proc.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def alert_webhook_proc
  @alert_webhook_proc
end

#alert_webhook_url ⇒ Object

Returns the value of attribute alert_webhook_url.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def alert_webhook_url
  @alert_webhook_url
end

#app_version ⇒ Object

Returns the value of attribute app_version.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def app_version
  @app_version
end

#async ⇒ Object

Returns the value of attribute async.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def async
  @async
end

#dashboard_authorizer ⇒ Object

Returns the value of attribute dashboard_authorizer.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def dashboard_authorizer
  @dashboard_authorizer
end

#enabled ⇒ Object

Returns the value of attribute enabled.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def enabled
  @enabled
end

#enqueue_buffer_size ⇒ Object

Returns the value of attribute enqueue_buffer_size.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def enqueue_buffer_size
  @enqueue_buffer_size
end

#enqueue_failure_policy ⇒ Object

Returns the value of attribute enqueue_failure_policy.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def enqueue_failure_policy
  @enqueue_failure_policy
end

#environment ⇒ Object

Returns the value of attribute environment.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def environment
  @environment
end

#event_retention_days ⇒ Object

Returns the value of attribute event_retention_days.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def event_retention_days
  @event_retention_days
end

#hash_identity ⇒ Object

Returns the value of attribute hash_identity.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def hash_identity
  @hash_identity
end

#identity_fields ⇒ Object

Returns the value of attribute identity_fields.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def identity_fields
  @identity_fields
end

#internal_org_resolver ⇒ Object

Returns the value of attribute internal_org_resolver.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def internal_org_resolver
  @internal_org_resolver
end

#org_resolver ⇒ Object

Returns the value of attribute org_resolver.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def org_resolver
  @org_resolver
end

Returns the value of attribute paid_org_resolver.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def paid_org_resolver
  @paid_org_resolver
end

#plan_resolver ⇒ Object

Returns the value of attribute plan_resolver.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def plan_resolver
  @plan_resolver
end

#sample_rate ⇒ Object

Returns the value of attribute sample_rate.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def sample_rate
  @sample_rate
end

#slack_webhook_url ⇒ Object

Returns the value of attribute slack_webhook_url.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def slack_webhook_url
  @slack_webhook_url
end

#user_resolver ⇒ Object

Returns the value of attribute user_resolver.



3
4
5
# File 'lib/code_sunset/configuration.rb', line 3

def user_resolver
  @user_resolver
end

Instance Method Details

#custom_filters ⇒ Object



69
70
71
# File 'lib/code_sunset/configuration.rb', line 69

def custom_filters
  @custom_filters ||= {}
end

#custom_filters=(value) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/code_sunset/configuration.rb', line 73

def custom_filters=(value)
  @custom_filters = value.to_h.each_with_object({}) do |(key, definition), memo|
    next if definition.blank?

    normalized = definition.to_h.symbolize_keys
    memo[key.to_sym] = {
      label: normalized[:label].presence || key.to_s.humanize,
      type: (normalized[:type] || :string).to_sym,
      metadata_key: (normalized[:metadata_key] || key).to_s,
      options: normalize_filter_options(normalized[:options]),
      placeholder: normalized[:placeholder].presence
    }.compact
  end
end