Class: StatsigOptions

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/statsig_options.rb

Overview

Configuration options for the Statsig SDK.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment = nil, api_url_base = nil, api_url_download_config_specs: nil, rulesets_sync_interval: 10, idlists_sync_interval: 60, disable_rulesets_sync: false, disable_idlists_sync: false, logging_interval_seconds: 60, logging_max_buffer_size: 1000, local_mode: false, bootstrap_values: nil, rules_updated_callback: nil, data_store: nil, idlist_threadpool_size: 3, logger_threadpool_size: 3, disable_diagnostics_logging: false, disable_sorbet_logging_handlers: false, network_timeout: nil, post_logs_retry_limit: 3, post_logs_retry_backoff: nil, user_persistent_storage: nil) ⇒ StatsigOptions

Returns a new instance of StatsigOptions.



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/statsig_options.rb', line 140

def initialize(
  environment = nil,
  api_url_base = nil,
  api_url_download_config_specs: nil,
  rulesets_sync_interval: 10,
  idlists_sync_interval: 60,
  disable_rulesets_sync: false,
  disable_idlists_sync: false,
  logging_interval_seconds: 60,
  logging_max_buffer_size: 1000,
  local_mode: false,
  bootstrap_values: nil,
  rules_updated_callback: nil,
  data_store: nil,
  idlist_threadpool_size: 3,
  logger_threadpool_size: 3,
  disable_diagnostics_logging: false,
  disable_sorbet_logging_handlers: false,
  network_timeout: nil,
  post_logs_retry_limit: 3,
  post_logs_retry_backoff: nil,
  user_persistent_storage: nil
)
  @environment = environment.is_a?(Hash) ? environment : nil
  @api_url_base = api_url_base || 'https://statsigapi.net/v1'
  @api_url_download_config_specs = api_url_download_config_specs || api_url_base || 'https://api.statsigcdn.com/v1'
  @rulesets_sync_interval = rulesets_sync_interval
  @idlists_sync_interval = idlists_sync_interval
  @disable_rulesets_sync = disable_rulesets_sync
  @disable_idlists_sync = disable_idlists_sync
  @logging_interval_seconds = logging_interval_seconds
  @logging_max_buffer_size = [logging_max_buffer_size, 1000].min
  @local_mode = local_mode
  @bootstrap_values = bootstrap_values
  @rules_updated_callback = rules_updated_callback
  @data_store = data_store
  @idlist_threadpool_size = idlist_threadpool_size
  @logger_threadpool_size = logger_threadpool_size
  @disable_diagnostics_logging = disable_diagnostics_logging
  @disable_sorbet_logging_handlers = disable_sorbet_logging_handlers
  @network_timeout = network_timeout
  @post_logs_retry_limit = post_logs_retry_limit
  @post_logs_retry_backoff = post_logs_retry_backoff
  @user_persistent_storage = user_persistent_storage

end

Instance Attribute Details

#api_url_baseObject

The base url used to make network calls to Statsig. default: statsigapi.net/v1



21
22
23
# File 'lib/statsig_options.rb', line 21

def api_url_base
  @api_url_base
end

#api_url_download_config_specsObject

Returns the value of attribute api_url_download_config_specs.



26
27
28
# File 'lib/statsig_options.rb', line 26

def api_url_download_config_specs
  @api_url_download_config_specs
end

#bootstrap_valuesObject

A string that represents all rules for all feature gates, dynamic configs and experiments. It can be provided to bootstrap the Statsig server SDK at initialization in case your server runs into network issue or Statsig is down temporarily.



65
66
67
# File 'lib/statsig_options.rb', line 65

def bootstrap_values
  @bootstrap_values
end

#data_storeObject

A class that extends IDataStore. Can be used to provide values from a common data store (like Redis) to initialize the Statsig SDK.



74
75
76
# File 'lib/statsig_options.rb', line 74

def data_store
  @data_store
end

#disable_diagnostics_loggingObject

Should diagnostics be logged. These include performance metrics for initialize. default: false



89
90
91
# File 'lib/statsig_options.rb', line 89

def disable_diagnostics_logging
  @disable_diagnostics_logging
end

#disable_idlists_syncObject

Returns the value of attribute disable_idlists_sync.



44
45
46
# File 'lib/statsig_options.rb', line 44

def disable_idlists_sync
  @disable_idlists_sync
end

#disable_rulesets_syncObject

Returns the value of attribute disable_rulesets_sync.



40
41
42
# File 'lib/statsig_options.rb', line 40

def disable_rulesets_sync
  @disable_rulesets_sync
end

#disable_sorbet_logging_handlersObject

Statsig utilizes Sorbet (sorbet.org) to ensure type safety of the SDK. This includes logging to console when errors are detected. You can disable this logging by setting this flag to true. default: false



95
96
97
# File 'lib/statsig_options.rb', line 95

def disable_sorbet_logging_handlers
  @disable_sorbet_logging_handlers
end

#environmentObject

Hash you can use to set environment variables that apply to all of your users in the same session and will be used for targeting purposes. eg. { “tier” => “development” }



16
17
18
# File 'lib/statsig_options.rb', line 16

def environment
  @environment
end

#idlist_threadpool_sizeObject

The number of threads allocated to syncing IDLists. default: 3



79
80
81
# File 'lib/statsig_options.rb', line 79

def idlist_threadpool_size
  @idlist_threadpool_size
end

#idlists_sync_intervalObject

The interval (in seconds) to poll for changes to your id lists default: 60s



36
37
38
# File 'lib/statsig_options.rb', line 36

def idlists_sync_interval
  @idlists_sync_interval
end

#local_modeObject

Restricts the SDK to not issue any network requests and only respond with default values (or local overrides) default: false



59
60
61
# File 'lib/statsig_options.rb', line 59

def local_mode
  @local_mode
end

#logger_threadpool_sizeObject

The number of threads allocated to posting event logs. default: 3



84
85
86
# File 'lib/statsig_options.rb', line 84

def logger_threadpool_size
  @logger_threadpool_size
end

#logging_interval_secondsObject

How often to flush logs to Statsig default: 60s



49
50
51
# File 'lib/statsig_options.rb', line 49

def logging_interval_seconds
  @logging_interval_seconds
end

#logging_max_buffer_sizeObject

The maximum number of events to batch before flushing logs to the server default: 1000



54
55
56
# File 'lib/statsig_options.rb', line 54

def logging_max_buffer_size
  @logging_max_buffer_size
end

#network_timeoutObject

Number of seconds before a network call is timed out



99
100
101
# File 'lib/statsig_options.rb', line 99

def network_timeout
  @network_timeout
end

#post_logs_retry_backoffObject

The number of seconds, or a function that returns the number of seconds based on the number of retries remaining which overrides the default backoff time between retries



108
109
110
# File 'lib/statsig_options.rb', line 108

def post_logs_retry_backoff
  @post_logs_retry_backoff
end

#post_logs_retry_limitObject

Number of times to retry sending a batch of failed log events



103
104
105
# File 'lib/statsig_options.rb', line 103

def post_logs_retry_limit
  @post_logs_retry_limit
end

#rules_updated_callbackObject

A callback function that will be called anytime the rulesets are updated.



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

def rules_updated_callback
  @rules_updated_callback
end

#rulesets_sync_intervalObject

The interval (in seconds) to poll for changes to your Statsig configuration default: 10s



31
32
33
# File 'lib/statsig_options.rb', line 31

def rulesets_sync_interval
  @rulesets_sync_interval
end

#user_persistent_storageObject

A storage adapter for persisted values. Can be used for sticky bucketing users in experiments. Implements Statsig::Interfaces::IUserPersistentStorage.



113
114
115
# File 'lib/statsig_options.rb', line 113

def user_persistent_storage
  @user_persistent_storage
end