Class: StatsigOptions
- Inherits:
-
Object
- Object
- StatsigOptions
- Defined in:
- lib/statsig_options.rb
Overview
Configuration options for the Statsig SDK.
Instance Attribute Summary collapse
-
#bootstrap_values ⇒ Object
A string that represents all rules for all feature gates, dynamic configs and experiments.
-
#data_store ⇒ Object
A class that extends IDataStore.
-
#disable_diagnostics_logging ⇒ Object
Should diagnostics be logged.
-
#disable_idlists_sync ⇒ Object
Disable background syncing for id lists.
-
#disable_rulesets_sync ⇒ Object
Disable background syncing for rulesets.
-
#disable_sorbet_logging_handlers ⇒ Object
Statsig utilizes Sorbet (sorbet.org) to ensure type safety of the SDK.
-
#download_config_specs_url ⇒ Object
The url used specifically to call download_config_specs.
-
#environment ⇒ Object
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.
-
#get_id_lists_url ⇒ Object
The url used specifically to call get_id_lists.
-
#idlist_threadpool_size ⇒ Object
The number of threads allocated to syncing IDLists.
-
#idlists_sync_interval ⇒ Object
The interval (in seconds) to poll for changes to your id lists default: 60s.
-
#local_mode ⇒ Object
Restricts the SDK to not issue any network requests and only respond with default values (or local overrides) default: false.
-
#log_event_url ⇒ Object
The url used specifically to call log_event.
-
#logger_threadpool_size ⇒ Object
The number of threads allocated to posting event logs.
-
#logging_interval_seconds ⇒ Object
How often to flush logs to Statsig default: 60s.
-
#logging_max_buffer_size ⇒ Object
The maximum number of events to batch before flushing logs to the server default: 1000.
-
#network_timeout ⇒ Object
Number of seconds before a network call is timed out.
-
#post_logs_retry_backoff ⇒ Object
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.
-
#post_logs_retry_limit ⇒ Object
Number of times to retry sending a batch of failed log events.
-
#rules_updated_callback ⇒ Object
A callback function that will be called anytime the rulesets are updated.
-
#rulesets_sync_interval ⇒ Object
The interval (in seconds) to poll for changes to your Statsig configuration default: 10s.
-
#user_persistent_storage ⇒ Object
A storage adapter for persisted values.
Instance Method Summary collapse
Constructor Details
#initialize(environment = nil, download_config_specs_url: nil, log_event_url: nil, get_id_lists_url: 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.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/statsig_options.rb', line 91 def initialize( environment = nil, download_config_specs_url: nil, log_event_url: nil, get_id_lists_url: 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 dcs_url = download_config_specs_url || 'https://api.statsigcdn.com/v2/download_config_specs/' unless dcs_url.end_with?('/') dcs_url += '/' end @download_config_specs_url = dcs_url @log_event_url = log_event_url || 'https://statsigapi.net/v1/log_event' @get_id_lists_url = get_id_lists_url || 'https://statsigapi.net/v1/get_id_lists' @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
#bootstrap_values ⇒ Object
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.
51 52 53 |
# File 'lib/statsig_options.rb', line 51 def bootstrap_values @bootstrap_values end |
#data_store ⇒ Object
A class that extends IDataStore. Can be used to provide values from a common data store (like Redis) to initialize the Statsig SDK.
58 59 60 |
# File 'lib/statsig_options.rb', line 58 def data_store @data_store end |
#disable_diagnostics_logging ⇒ Object
Should diagnostics be logged. These include performance metrics for initialize. default: false
70 71 72 |
# File 'lib/statsig_options.rb', line 70 def disable_diagnostics_logging @disable_diagnostics_logging end |
#disable_idlists_sync ⇒ Object
Disable background syncing for id lists
34 35 36 |
# File 'lib/statsig_options.rb', line 34 def disable_idlists_sync @disable_idlists_sync end |
#disable_rulesets_sync ⇒ Object
Disable background syncing for rulesets
31 32 33 |
# File 'lib/statsig_options.rb', line 31 def disable_rulesets_sync @disable_rulesets_sync end |
#disable_sorbet_logging_handlers ⇒ Object
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
75 76 77 |
# File 'lib/statsig_options.rb', line 75 def disable_sorbet_logging_handlers @disable_sorbet_logging_handlers end |
#download_config_specs_url ⇒ Object
The url used specifically to call download_config_specs.
14 15 16 |
# File 'lib/statsig_options.rb', line 14 def download_config_specs_url @download_config_specs_url end |
#environment ⇒ Object
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” }
11 12 13 |
# File 'lib/statsig_options.rb', line 11 def environment @environment end |
#get_id_lists_url ⇒ Object
The url used specifically to call get_id_lists.
20 21 22 |
# File 'lib/statsig_options.rb', line 20 def get_id_lists_url @get_id_lists_url end |
#idlist_threadpool_size ⇒ Object
The number of threads allocated to syncing IDLists. default: 3
62 63 64 |
# File 'lib/statsig_options.rb', line 62 def idlist_threadpool_size @idlist_threadpool_size end |
#idlists_sync_interval ⇒ Object
The interval (in seconds) to poll for changes to your id lists default: 60s
28 29 30 |
# File 'lib/statsig_options.rb', line 28 def idlists_sync_interval @idlists_sync_interval end |
#local_mode ⇒ Object
Restricts the SDK to not issue any network requests and only respond with default values (or local overrides) default: false
46 47 48 |
# File 'lib/statsig_options.rb', line 46 def local_mode @local_mode end |
#log_event_url ⇒ Object
The url used specifically to call log_event.
17 18 19 |
# File 'lib/statsig_options.rb', line 17 def log_event_url @log_event_url end |
#logger_threadpool_size ⇒ Object
The number of threads allocated to posting event logs. default: 3
66 67 68 |
# File 'lib/statsig_options.rb', line 66 def logger_threadpool_size @logger_threadpool_size end |
#logging_interval_seconds ⇒ Object
How often to flush logs to Statsig default: 60s
38 39 40 |
# File 'lib/statsig_options.rb', line 38 def logging_interval_seconds @logging_interval_seconds end |
#logging_max_buffer_size ⇒ Object
The maximum number of events to batch before flushing logs to the server default: 1000
42 43 44 |
# File 'lib/statsig_options.rb', line 42 def logging_max_buffer_size @logging_max_buffer_size end |
#network_timeout ⇒ Object
Number of seconds before a network call is timed out
78 79 80 |
# File 'lib/statsig_options.rb', line 78 def network_timeout @network_timeout end |
#post_logs_retry_backoff ⇒ Object
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
85 86 87 |
# File 'lib/statsig_options.rb', line 85 def post_logs_retry_backoff @post_logs_retry_backoff end |
#post_logs_retry_limit ⇒ Object
Number of times to retry sending a batch of failed log events
81 82 83 |
# File 'lib/statsig_options.rb', line 81 def post_logs_retry_limit @post_logs_retry_limit end |
#rules_updated_callback ⇒ Object
A callback function that will be called anytime the rulesets are updated.
54 55 56 |
# File 'lib/statsig_options.rb', line 54 def rules_updated_callback @rules_updated_callback end |
#rulesets_sync_interval ⇒ Object
The interval (in seconds) to poll for changes to your Statsig configuration default: 10s
24 25 26 |
# File 'lib/statsig_options.rb', line 24 def rulesets_sync_interval @rulesets_sync_interval end |
#user_persistent_storage ⇒ Object
A storage adapter for persisted values. Can be used for sticky bucketing users in experiments. Implements Statsig::Interfaces::IUserPersistentStorage.
89 90 91 |
# File 'lib/statsig_options.rb', line 89 def user_persistent_storage @user_persistent_storage end |