vwo-fme-ruby-sdk 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8935c2c79e2fc5cd17d450d4a21fdf48fda27343455ad939bb2a7b66820ae2ec
4
- data.tar.gz: 3e0297e44ac33c862aad76b8e04ba7b944acc4c38b476582e931a53c14ffd483
3
+ metadata.gz: 6d45fa0809a1e1abfab41886fb30f9987d6e7910dc146d3f9c389d833870480c
4
+ data.tar.gz: af6be7b298827b5cfb5facac2b4227bdc74afc21d55da7d30b4652d57a708b4e
5
5
  SHA512:
6
- metadata.gz: d05fef9ef3277e071c8cbf3f7582dc7845e1e99c63247b6db440975c46bbb685f8b5723bc67850fd2666bfd1d69e7fe17fafbdf1f711aa562bff013d7c65f48d
7
- data.tar.gz: e39b7eaf87dc0bb3540519649a96b85e4178775948d88f7a60aedf6e430aa977c7ff1f27b5f53860f86e37233544da21975a66e767683be3566fec3ec2f261ed
6
+ metadata.gz: e92a90c764fbdb5cba7417172079bc08480b71246028add35c098ef8700754b33bd736e3384444f7b3be2f36c0b2b2f93073a69b4622cbbd571b8d6530e6d237
7
+ data.tar.gz: 820f2d137b7506d3bdc4eb629c0d383d9d3e04ecb99cd99f47a473977ef0f4ca92bb23df3b0f23aceefee98964d97dc57a3244a32bc996f190f3e5abc4eee596
@@ -38,5 +38,6 @@
38
38
  "IMPRESSION_BATCH_FAILED": "Batch events couldn\"t be received by VWO. Calling Flush Callback with error and data",
39
39
  "EVENT_BATCH_MAX_LIMIT": "{parameter} passed in SDK configuration is greater than the maximum limit of {maxLimit}. Setting it to the maximum limit",
40
40
  "GATEWAY_AND_BATCH_EVENTS_CONFIG_MISMATCH": "Batch Events config passed in SDK configuration will not work as the gatewayService is already configured. Please check the documentation for more details",
41
- "NETWORK_CALL_SUCCESS_WITH_RETRIES": "Network call for {extraData} succeeded after {attempts} retry attempt(s). Previous attempts failed with error: {err}"
41
+ "NETWORK_CALL_SUCCESS_WITH_RETRIES": "Network call for {extraData} succeeded after {attempts} retry attempt(s). Previous attempts failed with error: {err}",
42
+ "PROXY_AND_GATEWAY_SERVICE_PROVIDED": "Both proxy URL and gateway service are provided. Gateway service will be used and proxy URL will be ignored"
42
43
  }
@@ -17,7 +17,7 @@
17
17
  # Define the Constants module
18
18
  module Constants
19
19
  SDK_NAME = 'vwo-fme-ruby-sdk'.freeze
20
- SDK_VERSION = '1.7.0'.freeze
20
+ SDK_VERSION = '1.8.0'.freeze
21
21
 
22
22
  MAX_TRAFFIC_PERCENT = 100
23
23
  MAX_TRAFFIC_VALUE = 10_000
@@ -16,7 +16,7 @@ class VWOOptionsModel
16
16
  attr_accessor :account_id, :sdk_key, :is_development_mode, :storage, :gateway_service,
17
17
  :poll_interval, :logger, :segmentation, :integrations, :network,
18
18
  :should_wait_for_tracking_calls, :settings, :vwo_builder, :is_usage_stats_disabled, :_vwo_meta,
19
- :retry_config
19
+ :retry_config, :proxy_url
20
20
 
21
21
  def initialize(options = {})
22
22
  @account_id = options[:account_id]
@@ -35,6 +35,7 @@ class VWOOptionsModel
35
35
  @is_usage_stats_disabled = options[:is_usage_stats_disabled]
36
36
  @_vwo_meta = options[:_vwo_meta]
37
37
  @retry_config = options[:retry_config]
38
+ @proxy_url = options[:proxy_url]
38
39
  end
39
40
 
40
41
  # Creates a model instance from a hash (dictionary)
@@ -54,7 +55,7 @@ class VWOOptionsModel
54
55
  @network = options[:network] if options.key?(:network)
55
56
  @settings = options[:settings] if options.key?(:settings)
56
57
  @retry_config = options[:retry_config] if options.key?(:retry_config)
57
-
58
+ @proxy_url = options[:proxy_url] if options.key?(:proxy_url)
58
59
  self
59
60
  end
60
61
 
@@ -121,5 +122,8 @@ class VWOOptionsModel
121
122
  def get_retry_config
122
123
  @retry_config
123
124
  end
124
-
125
+
126
+ def get_proxy_url
127
+ @proxy_url
128
+ end
125
129
  end
@@ -25,7 +25,7 @@ require_relative '../enums/api_enum'
25
25
  require_relative '../utils/debugger_service_util'
26
26
 
27
27
  class SettingsService
28
- attr_accessor :sdk_key, :account_id, :expiry, :network_timeout, :hostname, :port, :protocol, :is_gateway_service_provided, :is_settings_valid, :settings_fetch_time
28
+ attr_accessor :sdk_key, :account_id, :expiry, :network_timeout, :hostname, :port, :protocol, :is_gateway_service_provided, :is_settings_valid, :settings_fetch_time, :proxy_url, :is_proxy_url_provided, :collection_prefix
29
29
 
30
30
  class << self
31
31
  attr_accessor :instance
@@ -55,6 +55,15 @@ class SettingsService
55
55
  @protocol = parsed_url.scheme
56
56
  @port = parsed_url.port || options.dig(:gateway_service, :port)
57
57
  @is_gateway_service_provided = true
58
+ if options[:proxy_url] && !options[:proxy_url].nil? && !options[:proxy_url].empty?
59
+ LoggerService.log(LogLevelEnum::INFO, "PROXY_AND_GATEWAY_SERVICE_PROVIDED")
60
+ end
61
+ elsif options[:proxy_url] && !options[:proxy_url].nil? && !options[:proxy_url].empty?
62
+ parsed_url = URI.parse(options[:proxy_url])
63
+ @hostname = parsed_url.hostname
64
+ @protocol = parsed_url.scheme
65
+ @port = parsed_url.port
66
+ @is_proxy_url_provided = true
58
67
  else
59
68
  @hostname = Constants::HOST_NAME
60
69
  @protocol = Constants::HTTPS_PROTOCOL
@@ -64,6 +73,13 @@ class SettingsService
64
73
  SettingsService.instance = self
65
74
  end
66
75
 
76
+ def get_updated_endpoint_with_collection_prefix(endpoint)
77
+ if @collection_prefix && !@collection_prefix.empty?
78
+ return "/#{@collection_prefix}#{endpoint}"
79
+ end
80
+ return endpoint
81
+ end
82
+
67
83
  # Fetch settings and cache them in storage.
68
84
  # @return [SettingsModel] The fetched settings
69
85
  def fetch_settings_and_cache_in_storage
@@ -124,7 +140,7 @@ class SettingsService
124
140
  end
125
141
  # Deep duplicate the settings to avoid modifying the original object
126
142
  normalized_settings = SettingsService.normalize_settings(settings)
127
-
143
+ @collection_prefix = normalized_settings['collectionPrefix'] if normalized_settings['collectionPrefix'] && !normalized_settings['collectionPrefix'].empty?
128
144
  normalized_settings
129
145
  rescue => e
130
146
  LoggerService.log(LogLevelEnum::ERROR, "ERROR_FETCHING_SETTINGS", { err: e.message, an: ApiEnum::INIT})
@@ -44,9 +44,9 @@ class BatchEventDispatcherUtil
44
44
  headers['Authorization'] = "#{SettingsService.instance.sdk_key}"
45
45
 
46
46
  request = RequestModel.new(
47
- UrlUtil.get_base_url,
47
+ SettingsService.instance.hostname,
48
48
  HttpMethodEnum::POST,
49
- UrlEnum::BATCH_EVENTS,
49
+ SettingsService.instance.get_updated_endpoint_with_collection_prefix(UrlEnum::BATCH_EVENTS),
50
50
  properties,
51
51
  payload,
52
52
  headers,
@@ -44,6 +44,12 @@ def send_sdk_usage_stats_event(usage_stats_account_id)
44
44
  # create payload
45
45
  payload = NetworkUtil.get_sdk_usage_stats_payload_data(EventEnum::VWO_USAGE_STATS, usage_stats_account_id)
46
46
 
47
- # send event
48
- NetworkUtil.send_event(properties, payload)
47
+ # check if batching is enabled
48
+ if BatchEventsQueue.instance
49
+ # add the payload to the batch events queue
50
+ BatchEventsQueue.instance.enqueue(payload)
51
+ else
52
+ # send event
53
+ NetworkUtil.send_event(properties, payload)
54
+ end
49
55
  end
@@ -17,7 +17,6 @@ require_relative '../packages/network_layer/manager/network_manager'
17
17
  require_relative '../packages/network_layer/models/request_model'
18
18
  require_relative '../enums/http_method_enum'
19
19
  require_relative '../services/settings_service'
20
- require_relative 'url_util'
21
20
  require_relative '../enums/campaign_type_enum'
22
21
  require_relative '../services/logger_service'
23
22
  require_relative '../enums/log_level_enum'
@@ -37,9 +36,9 @@ def get_from_gateway_service(query_params, endpoint)
37
36
 
38
37
  begin
39
38
  request = RequestModel.new(
40
- UrlUtil.get_base_url,
39
+ SettingsService.instance.hostname,
41
40
  HttpMethodEnum::GET,
42
- endpoint,
41
+ SettingsService.instance.get_updated_endpoint_with_collection_prefix(endpoint),
43
42
  query_params,
44
43
  nil,
45
44
  nil,
@@ -21,7 +21,6 @@ require_relative '../constants/constants'
21
21
  require_relative '../packages/network_layer/manager/network_manager'
22
22
  require_relative '../packages/network_layer/models/request_model'
23
23
  require_relative '../packages/network_layer/models/response_model'
24
- require_relative '../utils/url_util'
25
24
  require_relative '../utils/uuid_util'
26
25
  require_relative '../utils/usage_stats_util'
27
26
  require_relative '../models/user/context_model'
@@ -92,8 +91,7 @@ class NetworkUtil
92
91
  random: get_random_number,
93
92
  p: 'FS',
94
93
  visitor_ua: visitor_user_agent || '',
95
- visitor_ip: ip_address || '',
96
- url: "#{UrlUtil.get_base_url}#{UrlEnum::EVENTS}"
94
+ visitor_ip: ip_address || ''
97
95
  }
98
96
 
99
97
  if !is_usage_stats_event
@@ -270,9 +268,9 @@ class NetworkUtil
270
268
  headers[HeadersEnum::IP] = payload[:d][:visitor_ip] if payload[:d][:visitor_ip]
271
269
 
272
270
  request = RequestModel.new(
273
- UrlUtil.get_base_url,
271
+ SettingsService.instance.hostname,
274
272
  HttpMethodEnum::POST,
275
- UrlEnum::EVENTS,
273
+ SettingsService.instance.get_updated_endpoint_with_collection_prefix(UrlEnum::EVENTS),
276
274
  properties,
277
275
  payload,
278
276
  headers,
@@ -347,20 +345,15 @@ class NetworkUtil
347
345
  headers[HeadersEnum::USER_AGENT] = payload[:d][:visitor_ua] if payload[:d][:visitor_ua]
348
346
  headers[HeadersEnum::IP] = payload[:d][:visitor_ip] if payload[:d][:visitor_ip]
349
347
 
350
- url = Constants::HOST_NAME
351
- if UrlUtil.get_collection_prefix && !UrlUtil.get_collection_prefix.empty?
352
- url = "#{url}/#{UrlUtil.get_collection_prefix}"
353
- end
354
-
355
348
  request = RequestModel.new(
356
- url,
349
+ SettingsService.instance.hostname,
357
350
  HttpMethodEnum::POST,
358
- UrlEnum::EVENTS,
351
+ SettingsService.instance.get_updated_endpoint_with_collection_prefix(UrlEnum::EVENTS),
359
352
  properties,
360
353
  payload,
361
354
  headers,
362
- Constants::HTTPS_PROTOCOL,
363
- nil
355
+ SettingsService.instance.protocol,
356
+ SettingsService.instance.port,
364
357
  )
365
358
 
366
359
  begin
@@ -17,7 +17,6 @@ require_relative 'models/user/context_model'
17
17
  require_relative 'api/get_flag'
18
18
  require_relative 'api/set_attribute'
19
19
  require_relative 'api/track_event'
20
- require_relative 'utils/url_util'
21
20
  require_relative 'utils/settings_util'
22
21
  require_relative 'services/logger_service'
23
22
  require_relative 'enums/log_level_enum'
@@ -37,7 +36,6 @@ class VWOClient
37
36
 
38
37
  begin
39
38
  set_settings_and_add_campaigns_to_rules(settings, self)
40
- UrlUtil.init(collection_prefix: @settings.get_collection_prefix)
41
39
  rescue StandardError => e
42
40
  LoggerService.log(LogLevelEnum::ERROR, "ERROR_ADDING_CAMPAIGNS_TO_RULES", { err: e.message, an: ApiEnum::INIT})
43
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vwo-fme-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VWO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-13 00:00:00.000000000 Z
11
+ date: 2026-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuidtools
@@ -222,7 +222,6 @@ files:
222
222
  - lib/vwo/utils/network_util.rb
223
223
  - lib/vwo/utils/rule_evaluation_util.rb
224
224
  - lib/vwo/utils/settings_util.rb
225
- - lib/vwo/utils/url_util.rb
226
225
  - lib/vwo/utils/usage_stats_util.rb
227
226
  - lib/vwo/utils/uuid_util.rb
228
227
  - lib/vwo/vwo_builder.rb
@@ -1,53 +0,0 @@
1
- # Copyright 2024-2025 Wingify Software Pvt. Ltd.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require_relative '../services/settings_service'
16
-
17
- class UrlUtil
18
- @collection_prefix = nil
19
-
20
- class << self
21
- attr_accessor :collection_prefix
22
-
23
- # Initializes the UrlUtil with an optional collection prefix.
24
- #
25
- # @param collection_prefix [String] Optional prefix for URL collections.
26
- # @return [UrlUtil] The singleton instance of UrlUtil with updated properties.
27
- def init(collection_prefix: nil)
28
- @collection_prefix = collection_prefix if collection_prefix.is_a?(String)
29
- self
30
- end
31
-
32
- # Retrieves the base URL.
33
- #
34
- # @return [String] The base URL.
35
- def get_base_url
36
- base_url = SettingsService.instance.hostname
37
-
38
- return base_url if SettingsService.instance.is_gateway_service_provided
39
-
40
- # Construct URL with collection_prefix if it exists
41
- return "#{base_url}/#{@collection_prefix}" if @collection_prefix
42
-
43
- base_url
44
- end
45
-
46
- # Retrieves the collection prefix.
47
- #
48
- # @return [String] The collection prefix.
49
- def get_collection_prefix
50
- @collection_prefix
51
- end
52
- end
53
- end