Class: UsageStatsUtil
- Inherits:
-
Object
- Object
- UsageStatsUtil
- Defined in:
- lib/wingify/utils/usage_stats_util.rb
Overview
Manages usage statistics for the SDK. Tracks various features and configurations being used by the client. Implements Singleton pattern to ensure a single instance.
Class Method Summary collapse
- .clear_usage_stats ⇒ Object
-
.get_usage_stats ⇒ Hash
Retrieves the current usage statistics.
-
.instance ⇒ UsageStatsUtil
Provides access to the singleton instance of UsageStatsUtil.
-
.set_usage_stats(options) ⇒ Object
Sets usage statistics based on provided options.
Instance Method Summary collapse
- #clear_usage_stats ⇒ Object
- #get_usage_stats ⇒ Object
-
#initialize ⇒ UsageStatsUtil
constructor
A new instance of UsageStatsUtil.
- #set_usage_stats(options) ⇒ Object
Constructor Details
#initialize ⇒ UsageStatsUtil
Returns a new instance of UsageStatsUtil.
56 57 58 |
# File 'lib/wingify/utils/usage_stats_util.rb', line 56 def initialize @usage_stats_data = {} end |
Class Method Details
.clear_usage_stats ⇒ Object
49 50 51 |
# File 'lib/wingify/utils/usage_stats_util.rb', line 49 def clear_usage_stats instance.clear_usage_stats end |
.get_usage_stats ⇒ Hash
Retrieves the current usage statistics.
45 46 47 |
# File 'lib/wingify/utils/usage_stats_util.rb', line 45 def get_usage_stats instance.get_usage_stats end |
.instance ⇒ UsageStatsUtil
Provides access to the singleton instance of UsageStatsUtil.
30 31 32 |
# File 'lib/wingify/utils/usage_stats_util.rb', line 30 def instance @instance ||= new end |
.set_usage_stats(options) ⇒ Object
Sets usage statistics based on provided options. Maps various SDK features and configurations to boolean flags.
38 39 40 |
# File 'lib/wingify/utils/usage_stats_util.rb', line 38 def set_usage_stats() instance.set_usage_stats() end |
Instance Method Details
#clear_usage_stats ⇒ Object
115 116 117 |
# File 'lib/wingify/utils/usage_stats_util.rb', line 115 def clear_usage_stats @usage_stats_data = {} end |
#get_usage_stats ⇒ Object
111 112 113 |
# File 'lib/wingify/utils/usage_stats_util.rb', line 111 def get_usage_stats @usage_stats_data end |
#set_usage_stats(options) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/wingify/utils/usage_stats_util.rb', line 60 def set_usage_stats() storage = [:storage] logger = [:logger] event_batching = [:batch_event_data] integrations = [:integrations] poll_interval = [:poll_interval] = [:_vwo_meta] gateway_service = [:gateway_service] threading = [:threading] data = {} data[:a] = SettingsService.instance.account_id data[:env] = SettingsService.instance.sdk_key data[:ig] = 1 if integrations data[:eb] = 1 if event_batching data[:gs] = 1 if gateway_service # if logger has transport or transports, then it is custom logger if logger && (logger.key?(:transport) || logger.key?(:transports)) data[:cl] = 1 end data[:ss] = 1 if storage if logger && logger.key?(:level) data[:ll] = LogLevelToNumber.to_number(logger[:level]) || -1 end data[:pi] = poll_interval if poll_interval if && .key?(:ea) data[:_ea] = 1 end # check if threading is not passed or is if passed then enabled should be true if !threading || (threading && threading[:enabled] == true) data[:th] = 1 # check if max_pool_size is passed if threading && threading[:max_pool_size] data[:th_mps] = threading[:max_pool_size] end end if defined?(RUBY_VERSION) data[:lv] = RUBY_VERSION end @usage_stats_data = data end |