wingify-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 +4 -4
- data/lib/resources/debug_messages.json +1 -0
- data/lib/resources/info_messages.json +1 -0
- data/lib/wingify/api/get_flag.rb +32 -2
- data/lib/wingify/constants/constants.rb +1 -1
- data/lib/wingify/enums/event_enum.rb +1 -0
- data/lib/wingify/models/settings/settings_model.rb +6 -1
- data/lib/wingify/utils/impression_util.rb +35 -0
- data/lib/wingify/utils/network_util.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0a073ce2ab36cb95b76047665658a4d4bb4e894f9f4bca5f909b3ae449479c48
|
|
4
|
+
data.tar.gz: 63e231332dda090e3df7ec30a2823678215eb6ca6a310340497a6aa32c868c86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3b5dc171ebbaf2166e009debef850ef92bc6b705f1953fcf38102c90f1dbf5b2b4d2576c61f1eee9f13896aa81fae03e71f51367065c158090ba947364a2f2b9
|
|
7
|
+
data.tar.gz: 4494ffd33b81c50c4c907797f436f86a3bbadff4f5c7648c358d3b33e56153cb40188709f11c0ae272f8357329725bd853d68d4e1313cfae90b54720c7a4cdc5
|
|
@@ -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",
|
data/lib/wingify/api/get_flag.rb
CHANGED
|
@@ -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
|
|
@@ -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: wingify-fme-ruby-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.55.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wingify
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: uuidtools
|