vwo-fme-ruby-sdk 1.50.0 → 1.55.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: 3d76a694880edd0c5a2fa5b892193eef8f601c95d3d0a140c28681450196e2ee
4
- data.tar.gz: 95ff81d4b0e38159a57e7d22a603d7f81df3319ad2fb43bb7395691c46b24a79
3
+ metadata.gz: 15f3001a8b2112b59b1f97dc24f09735e4cb4c28de642f62f18c76a7f7d67d08
4
+ data.tar.gz: d14170568fbcfcc5677488737641e50f1949240a2788d5345d640516881eef83
5
5
  SHA512:
6
- metadata.gz: '051825ffb285e02b0db70c7b869dedc2508946e199cec12bcdb402d4ff9f499028df3d8f4da46e24eeb28e45dfc42f2af937130c4118a43b5fd2ccca2abf57f9'
7
- data.tar.gz: 42ce7d1946c602b1c73e182677feaee8a78c3a6ccbc9ed5ba5063788e4af45d827cbdba78586a5f37e9f193ce4eb226b0769aa02784ca165b3e684a71e1df5de
6
+ metadata.gz: 78d65f005620ce3c1b285f356255e992176d546e9b0518a22f37d740760c6abcbe99a0acfc8e5558372a58b50d6e9dfcb996d17795193210d1dea060a161a10c
7
+ data.tar.gz: bf913d055a768cf1bb36e3608fc8b86f1e22fbd96aa107bff99a327b4c643b38d3d30031587bdc05fd7dfd3ecfd0e803b6594c8f4a7fbc0426d625214b8c2035
@@ -11,6 +11,7 @@
11
11
  "IMPRESSION_FOR_TRACK_USER": "Impression built for vwo_variationShown({brand} standard event for tracking user) event haivng Account ID:{accountId}, User ID:{userId}, and experiment ID:{campaignId}",
12
12
  "IMPRESSION_FOR_TRACK_GOAL": "Impression built for event:{eventName} event having Account ID:{accountId}, and user ID:{userId}",
13
13
  "IMPRESSION_FOR_SYNC_VISITOR_PROP": "Impression built for {eventName}({brand} internal event) event for Account ID:{accountId}, and user ID:{userId}",
14
+ "IMPRESSION_FOR_USAGE_TRACKING": "Impression built for vwo_feTrackUsage({brand} standard event for usage tracking call) event having Account ID:{accountId}, and user ID:{userId}",
14
15
 
15
16
  "CONFIG_BATCH_EVENT_LIMIT_EXCEEDED": "Impression event - {endPoint} failed due to exceeding payload size. Parameter eventsPerRequest in batchEvents config in init API has value:{eventsPerRequest} for account ID:{accountId}. Please read the official documentation for knowing the size limits",
16
17
 
@@ -30,6 +30,7 @@
30
30
  "MEG_WINNER_CAMPAIGN": "MEG: Campaign {campaignKey} is the winner for group {groupId} for user ID:{userId} {algo}",
31
31
  "SETTINGS_UPDATED": "Settings fetched and updated successfully on the current {brand} client instance when API: {apiName} got called having isViaWebhook param as {isViaWebhook}",
32
32
  "NETWORK_CALL_SUCCESS": "Impression for {event} - {endPoint} was successfully received by {brand} having Account ID:{accountId}, UUID: {uuid}",
33
+ "USAGE_TRACKING_DISPATCHED": "FE track usage call dispatched for Account ID:{accountId}, User ID:{userId}, and feature key:{featureKey}",
33
34
 
34
35
  "EVENT_BATCH_DEFAULTS": "{parameter} in SDK configuration is missing or invalid (should be greater than {minLimit}). Using default value: {defaultValue}",
35
36
  "EVENT_QUEUE": "Event with payload:{event} pushed to the {queueType} queue",
@@ -40,6 +40,10 @@ class FlagApi
40
40
  rollout_variation_to_return = nil
41
41
  experiment_variation_to_return = nil
42
42
  should_check_for_experiments_rules = false
43
+ # Flag to check if variation shown event has been fired
44
+ is_variation_shown_fired = false
45
+ # Flag to check if tracking usage is enabled
46
+ is_tracking_usage_enabled = settings.get_is_tracking_usage_enabled
43
47
 
44
48
  passed_rules_information = {} # for storing integration callback
45
49
  evaluated_feature_map = {}
@@ -65,6 +69,8 @@ class FlagApi
65
69
 
66
70
  if variation
67
71
  LoggerService.log(LogLevelEnum::INFO, "STORED_VARIATION_FOUND", {variationKey: variation.get_key, userId: context.get_id, experimentKey: stored_data[:experiment_key], experimentType: "experiment"})
72
+ # Send usage tracking call when user is served from storage
73
+ send_tracking_usage(settings, context, is_tracking_usage_enabled, feature_key)
68
74
  return GetFlagResponse.new(true, variation.get_variables, context.get_uuid, context.get_session_id)
69
75
  end
70
76
  end
@@ -91,6 +97,8 @@ class FlagApi
91
97
 
92
98
  if feature.nil?
93
99
  LoggerService.log(LogLevelEnum::ERROR, "FEATURE_NOT_FOUND", {featureKey: feature_key, an: ApiEnum::GET_FLAG, sId: context.get_session_id, uuid: context.get_uuid})
100
+ # Send usage tracking call when feature is not found
101
+ send_tracking_usage(settings, context, is_tracking_usage_enabled, feature_key)
94
102
  return GetFlagResponse.new(false, [], context.get_uuid, context.get_session_id)
95
103
  end
96
104
 
@@ -106,6 +114,12 @@ class FlagApi
106
114
  rollout_rules.each do |rule|
107
115
  result = evaluate_rule(settings, feature, rule, context, evaluated_feature_map, nil, storage_service, decision)
108
116
  pre_segmentation_result = result[:pre_segmentation_result]
117
+ whitelisted_object = result[:whitelisted_object]
118
+
119
+ if whitelisted_object.is_a?(Hash) && !whitelisted_object.empty?
120
+ is_variation_shown_fired = true
121
+ end
122
+
109
123
  updated_decision = result[:updated_decision]
110
124
  decision.merge!(updated_decision) if updated_decision
111
125
 
@@ -131,6 +145,8 @@ class FlagApi
131
145
  update_integrations_decision_object(passed_rollout_campaign, variation, passed_rules_information, decision)
132
146
 
133
147
  create_and_send_impression_for_variation_shown(settings, passed_rollout_campaign.get_id, variation.get_id, context, feature_key)
148
+ # set is_variation_shown_fired to true since we already sent variation shown call for rollout
149
+ is_variation_shown_fired = true
134
150
  end
135
151
  end
136
152
  elsif rollout_rules.empty?
@@ -147,11 +163,16 @@ class FlagApi
147
163
  result = evaluate_rule(settings, feature, rule, context, evaluated_feature_map, meg_group_winner_campaigns, storage_service, decision)
148
164
  pre_segmentation_result = result[:pre_segmentation_result]
149
165
  whitelisted_object = result[:whitelisted_object]
166
+
167
+ if whitelisted_object.is_a?(Hash) && !whitelisted_object.empty?
168
+ is_variation_shown_fired = true
169
+ end
170
+
150
171
  updated_decision = result[:updated_decision]
151
172
  decision.merge!(updated_decision) if updated_decision
152
173
 
153
174
  if pre_segmentation_result
154
- if whitelisted_object.nil?
175
+ if whitelisted_object.nil? || whitelisted_object.empty?
155
176
  experiment_rules_to_evaluate << rule
156
177
  else
157
178
  is_enabled = true
@@ -176,6 +197,8 @@ class FlagApi
176
197
  update_integrations_decision_object(campaign, variation, passed_rules_information, decision)
177
198
 
178
199
  create_and_send_impression_for_variation_shown(settings, campaign.get_id, variation.get_id, context, feature_key)
200
+ # set is_variation_shown_fired to true since we already sent variation shown call for experiment
201
+ is_variation_shown_fired = true
179
202
  end
180
203
  end
181
204
  end
@@ -216,8 +239,15 @@ class FlagApi
216
239
  context,
217
240
  feature_key
218
241
  )
242
+ # set is_variation_shown_fired to true since we already sent variation shown call for impact analysis
243
+ is_variation_shown_fired = true
244
+ end
245
+
246
+ # Send usage tracking call when no primary variation_shown event was dispatched.
247
+ # If a primary variation_shown event was fired, the server already has the usage tracking signal.
248
+ if !is_variation_shown_fired
249
+ send_tracking_usage(settings, context, is_tracking_usage_enabled, feature_key)
219
250
  end
220
-
221
251
  # Return final evaluated feature flag
222
252
  return GetFlagResponse.new(is_enabled, experiment_variation_to_return&.get_variables || rollout_variation_to_return&.get_variables || [], context.get_uuid, context.get_session_id)
223
253
  end
@@ -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.50.0'.freeze
20
+ SDK_VERSION = '1.55.0'.freeze
21
21
 
22
22
  # --- Brand-specific constants ---
23
23
 
@@ -19,4 +19,5 @@ module EventEnum
19
19
  DEBUGGER_EVENT = 'vwo_sdkDebug'
20
20
  INIT_CALLED = 'vwo_fmeSdkInit'
21
21
  USAGE_STATS = 'vwo_sdkUsageStats'
22
+ USER_EVALUATED = 'vwo_feTrackUsage'
22
23
  end
@@ -18,7 +18,7 @@ require_relative '../../constants/constants'
18
18
 
19
19
  class SettingsModel
20
20
  attr_reader :sdk_key, :account_id, :usage_stats_account_id, :version, :collection_prefix,
21
- :features, :campaigns, :campaign_groups, :groups, :poll_interval, :is_web_connectivity_enabled
21
+ :features, :campaigns, :campaign_groups, :groups, :poll_interval, :is_web_connectivity_enabled, :is_tracking_usage_enabled
22
22
 
23
23
  def initialize(settings)
24
24
  @sdk_key = settings["sdkKey"]
@@ -32,6 +32,7 @@ class SettingsModel
32
32
  @campaign_groups = settings["campaignGroups"] || {}
33
33
  @groups = settings["groups"] || {}
34
34
  @is_web_connectivity_enabled = settings.fetch("isWebConnectivityEnabled", true)
35
+ @is_tracking_usage_enabled = settings.fetch("isMAU", false)
35
36
 
36
37
  process_features(settings)
37
38
  process_campaigns(settings)
@@ -98,4 +99,8 @@ class SettingsModel
98
99
  def get_is_web_connectivity_enabled
99
100
  @is_web_connectivity_enabled
100
101
  end
102
+
103
+ def get_is_tracking_usage_enabled
104
+ @is_tracking_usage_enabled
105
+ end
101
106
  end
@@ -64,3 +64,38 @@ def create_and_send_impression_for_variation_shown(settings, campaign_id, variat
64
64
  NetworkUtil.send_post_api_request(properties, payload, { campaign_type: campaign_type, feature_key: feature_key, campaign_key: campaign_key, variation_name: variation_name })
65
65
  end
66
66
  end
67
+
68
+ # Sends the usage tracking payload to the server.
69
+ # Called whenever a user is evaluated via get_flag() but no variation_shown event is dispatched.
70
+ #
71
+ # @param settings [SettingsModel] The settings model containing configuration.
72
+ # @param context [ContextModel] The user context model.
73
+ # @param is_tracking_usage_enabled [Boolean] Whether usage tracking is active.
74
+ # @param feature_key [String] The key of the evaluated feature.
75
+ def send_tracking_usage(settings, context, is_tracking_usage_enabled, feature_key)
76
+ return unless is_tracking_usage_enabled
77
+
78
+ # Construct payload data for tracking usage
79
+ payload = NetworkUtil.get_tracking_usage_payload_data(context)
80
+
81
+ # Get base properties for the event
82
+ properties = NetworkUtil.get_events_base_properties(
83
+ EventEnum::USER_EVALUATED,
84
+ URI.encode_www_form_component(context.get_user_agent), # Encode user agent for URL safety
85
+ context.get_ip_address
86
+ )
87
+ LoggerService.log(LogLevelEnum::INFO, "USAGE_TRACKING_DISPATCHED", {
88
+ accountId: settings.account_id,
89
+ userId: context.get_id,
90
+ featureKey: feature_key
91
+ })
92
+
93
+ # check if batching is enabled
94
+ if BatchEventsQueue.instance
95
+ # add the payload to the batch events queue
96
+ BatchEventsQueue.instance.enqueue(payload)
97
+ else
98
+ # Send the constructed payload via POST request
99
+ NetworkUtil.send_post_api_request(properties, payload)
100
+ end
101
+ end
@@ -293,6 +293,33 @@ class NetworkUtil
293
293
  properties
294
294
  end
295
295
 
296
+ # Constructs the payload data for usage tracking call.
297
+ # Sent to server when a user is evaluated via get_flag() but no variation_shown
298
+ # event is dispatched by the SDK.
299
+ # @param context [ContextModel] The context model instance.
300
+ # @returns [Hash] The constructed payload.
301
+ def get_tracking_usage_payload_data(context)
302
+ properties = _get_event_base_payload(context.get_id, EventEnum::USER_EVALUATED, context.get_user_agent, context.get_ip_address)
303
+
304
+ # use sessionId from context if present
305
+ if context.get_session_id
306
+ properties[:d][:sessionId] = context.get_session_id
307
+ end
308
+
309
+ # use uuid from context if present
310
+ if context.get_uuid && !context.get_uuid.empty?
311
+ properties[:d][:visId] = context.get_uuid
312
+ properties[:d][:msgId] = "#{context.get_uuid}-#{get_current_unix_timestamp_in_millis}"
313
+ end
314
+
315
+ LoggerService.log(LogLevelEnum::DEBUG, "IMPRESSION_FOR_USAGE_TRACKING", {
316
+ accountId: SettingsService.instance.account_id,
317
+ userId: context.get_id
318
+ })
319
+
320
+ properties
321
+ end
322
+
296
323
  # Sends a POST API request with given properties and payload
297
324
  def send_post_api_request(properties, payload, campaign_info = {})
298
325
  network_instance = NetworkManager.instance
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.50.0
4
+ version: 1.55.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-06-03 00:00:00.000000000 Z
11
+ date: 2026-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuidtools