vwo-sdk 1.14.0 → 1.22.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/abc.txt +28 -0
- data/lib/vwo/constants.rb +5 -2
- data/lib/vwo/core/bucketer.rb +33 -5
- data/lib/vwo/core/variation_decider.rb +420 -131
- data/lib/vwo/enums.rb +6 -1
- data/lib/vwo/logger.rb +4 -2
- data/lib/vwo/schemas/settings_file.rb +32 -1
- data/lib/vwo/services/segment_evaluator.rb +4 -2
- data/lib/vwo/utils/campaign.rb +60 -2
- data/lib/vwo/utils/feature.rb +2 -0
- data/lib/vwo.rb +193 -193
- metadata +29 -9
data/lib/vwo/enums.rb
CHANGED
@@ -113,6 +113,7 @@ class VWO
|
|
113
113
|
BULK_NOT_PROCESSED = "(%<file>s): Batch events couldn't be received by VWO. Calling Flush Callback with error and data."
|
114
114
|
BEFORE_FLUSHING = '(%<file>s): Flushing events queue %<manually>s having %<length>s events %<timer>s queue summary: %<queue_metadata>s'
|
115
115
|
EVENT_BATCHING_INSUFFICIENT = '(%<file>s): %<key>s not provided, assigning default value'
|
116
|
+
GOT_ELIGIBLE_CAMPAIGNS = "(%<file>s): Campaigns:%<eligible_campaigns_key>s are eligible, %<ineligible_campaigns_log_text>s are ineligible from the Group:%<group_name>s for the User ID:%<user_id>s"
|
116
117
|
end
|
117
118
|
|
118
119
|
# Info Messages
|
@@ -152,9 +153,13 @@ class VWO
|
|
152
153
|
CAMPAIGN_NOT_ACTIVATED = '(%<file>s): Activate the campaign:%<campaign_key>s for User ID:%<user_id>s to %<reason>s.'
|
153
154
|
GOAL_ALREADY_TRACKED = '(%<file>s): Goal:%<goal_identifier>s of Campaign:%<campaign_key>s for User ID:%<user_id>s has already been tracked earlier. Skipping now'
|
154
155
|
USER_ALREADY_TRACKED = '(%<file>s): User ID:%<user_id>s for Campaign:%<campaign_key>s has already been tracked earlier for "%<api_name>s" API. Skipping now'
|
155
|
-
API_CALLED = '(%<file>s): API:
|
156
|
+
API_CALLED = '(%<file>s): API: %<api_name>s called for UserId:%<user_id>s'
|
156
157
|
BULK_IMPRESSION_SUCCESS = '(%<file>s): Impression event - %<end_point>s was successfully received by VWO having accountId:%<a>s'
|
157
158
|
AFTER_FLUSHING = '(%<file>s): Events queue having %<length>s events has been flushed %<manually>s queue summary: %<queue_metadata>s'
|
159
|
+
GOT_WINNER_CAMPAIGN = "(%<file>s): Campaign:%<campaign_key>s is selected from the mutually exclusive group:%<group_name>s for the User ID:%<user_id>s"
|
160
|
+
GOT_ELIGIBLE_CAMPAIGNS = "(%<file>s): Got %<no_of_eligible_campaigns>s eligible winners out of %<no_of_group_campaigns>s from the Group:%<group_name>s and for User ID:%<user_id>s"
|
161
|
+
CALLED_CAMPAIGN_NOT_WINNER = "(%<file>s): Campaign:%<campaign_key>s does not qualify from the mutually exclusive group:%<group_name>s for User ID:%<user_id>s"
|
162
|
+
OTHER_CAMPAIGN_SATISFIES_WHITELISTING_OR_STORAGE = "(%<file>s): Campaign:%<campaign_key>s of Group:%<group_name>s satisfies %<type>s for User ID:%<user_id>s"
|
158
163
|
end
|
159
164
|
|
160
165
|
# Warning Messages
|
data/lib/vwo/logger.rb
CHANGED
@@ -28,8 +28,10 @@ class VWO
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Override this method to handle logs in a custom manner
|
31
|
-
def log(level, message)
|
32
|
-
|
31
|
+
def log(level, message, disable_logs = false)
|
32
|
+
unless disable_logs
|
33
|
+
@@logger_instance.log(level, message)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
def instance
|
@@ -54,7 +54,13 @@ class VWO
|
|
54
54
|
},
|
55
55
|
weight: {
|
56
56
|
type: %w[number string]
|
57
|
-
}
|
57
|
+
},
|
58
|
+
variables: {
|
59
|
+
type: 'array',
|
60
|
+
items: {
|
61
|
+
'$ref' => '#/definitions/variables_schema'
|
62
|
+
}
|
63
|
+
}
|
58
64
|
},
|
59
65
|
required: %w[id name weight]
|
60
66
|
},
|
@@ -79,9 +85,34 @@ class VWO
|
|
79
85
|
'$ref' => '#/definitions/campaign_variation_schema'
|
80
86
|
}
|
81
87
|
},
|
88
|
+
variables: {
|
89
|
+
type: 'array',
|
90
|
+
items: {
|
91
|
+
'$ref' => '#/definitions/variables_schema'
|
92
|
+
}
|
93
|
+
},
|
94
|
+
isBucketingSeedEnabled: ['boolean'],
|
82
95
|
minItems: 2
|
83
96
|
}
|
84
97
|
},
|
98
|
+
variables_schema: {
|
99
|
+
type: 'object',
|
100
|
+
properties: {
|
101
|
+
id: {
|
102
|
+
type: %w[number string]
|
103
|
+
},
|
104
|
+
key: {
|
105
|
+
type: ['string']
|
106
|
+
},
|
107
|
+
type: {
|
108
|
+
type: ['string']
|
109
|
+
},
|
110
|
+
value: {
|
111
|
+
type: %w[number string boolean double object]
|
112
|
+
}
|
113
|
+
},
|
114
|
+
required: %w[id key type value]
|
115
|
+
},
|
85
116
|
required: %w[
|
86
117
|
id
|
87
118
|
key
|
@@ -63,10 +63,11 @@ class VWO
|
|
63
63
|
# @param[String] :user_id Unique user identifier
|
64
64
|
# @param[Hash] :dsl Segments provided in the settings_file
|
65
65
|
# @param[Hash] :custom_variables Custom variables provided in the apis
|
66
|
+
# @param[Boolean] :disable_logs disable logs if True
|
66
67
|
#
|
67
68
|
# @return[Boolean] true if user passed pre-segmentation, else false
|
68
69
|
#
|
69
|
-
def evaluate(campaign_key, user_id, dsl, custom_variables)
|
70
|
+
def evaluate(campaign_key, user_id, dsl, custom_variables, disable_logs = false)
|
70
71
|
result = evaluate_util(dsl, custom_variables) if valid_value?(dsl)
|
71
72
|
result
|
72
73
|
rescue StandardError => e
|
@@ -79,7 +80,8 @@ class VWO
|
|
79
80
|
campaign_key: campaign_key,
|
80
81
|
custom_variables: custom_variables,
|
81
82
|
error_message: e
|
82
|
-
)
|
83
|
+
),
|
84
|
+
disable_logs
|
83
85
|
)
|
84
86
|
false
|
85
87
|
end
|
data/lib/vwo/utils/campaign.rb
CHANGED
@@ -57,6 +57,26 @@ class VWO
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
# Sets campaign allocation range in the provided campaigns list
|
61
|
+
#
|
62
|
+
# @param [Array]: Array of Campaigns
|
63
|
+
def set_campaign_allocation(campaigns)
|
64
|
+
current_allocation = 0
|
65
|
+
campaigns.each do |campaign|
|
66
|
+
step_factor = get_variation_bucketing_range(campaign['weight'])
|
67
|
+
if step_factor > 0
|
68
|
+
start_range = current_allocation + 1
|
69
|
+
end_range = current_allocation + step_factor
|
70
|
+
campaign['min_range'] = start_range
|
71
|
+
campaign['max_range'] = end_range
|
72
|
+
current_allocation += step_factor
|
73
|
+
else
|
74
|
+
campaign['min_range'] = -1
|
75
|
+
campaign['max_range'] = -1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
60
80
|
# Returns goal from given campaign_key and gaol_identifier.
|
61
81
|
# @param[String] :campaign Campaign object
|
62
82
|
# @param[String] :goal_identifier Goal identifier
|
@@ -190,7 +210,7 @@ class VWO
|
|
190
210
|
end
|
191
211
|
goal = get_campaign_goal(campaign, goal_identifier)
|
192
212
|
if validate_goal(goal, goal_type_to_track)
|
193
|
-
campaigns.
|
213
|
+
campaigns.push(campaign)
|
194
214
|
end
|
195
215
|
end
|
196
216
|
end
|
@@ -215,7 +235,7 @@ class VWO
|
|
215
235
|
|
216
236
|
campaign = get_campaign_for_campaign_key_and_goal(campaign_key, settings_file, goal_identifier, goal_type_to_track)
|
217
237
|
if campaign
|
218
|
-
campaigns.
|
238
|
+
campaigns.push(campaign)
|
219
239
|
end
|
220
240
|
end
|
221
241
|
campaigns
|
@@ -249,6 +269,44 @@ class VWO
|
|
249
269
|
return campaign
|
250
270
|
end
|
251
271
|
|
272
|
+
# Checks whether a campaign is part of a group.
|
273
|
+
#
|
274
|
+
# @param[Hash] :settings_file Settings file for the project
|
275
|
+
# @param[Integer] :campaign_id Id of campaign which is to be checked
|
276
|
+
# @return[Boolean]
|
277
|
+
def is_part_of_group(settings_file, campaign_id)
|
278
|
+
if settings_file["campaignGroups"] && (settings_file["campaignGroups"].has_key?(campaign_id.to_s))
|
279
|
+
return true
|
280
|
+
end
|
281
|
+
false
|
282
|
+
end
|
283
|
+
|
284
|
+
# Returns campaigns which are part of given group using group_id.
|
285
|
+
#
|
286
|
+
# @param[Hash] :settings_file Settings file for the project
|
287
|
+
# @param[Integer] :group_id id of group whose campaigns are to be return
|
288
|
+
# @return[Array]
|
289
|
+
def get_group_campaigns(settings_file, group_id)
|
290
|
+
group_campaign_ids = []
|
291
|
+
group_campaigns = []
|
292
|
+
groups = settings_file["groups"]
|
293
|
+
|
294
|
+
if groups && groups.has_key?(group_id.to_s)
|
295
|
+
group_campaign_ids = groups[group_id.to_s]["campaigns"]
|
296
|
+
end
|
297
|
+
|
298
|
+
if group_campaign_ids
|
299
|
+
group_campaign_ids.each do |campaign_id|
|
300
|
+
settings_file["campaigns"].each do |campaign|
|
301
|
+
if campaign["id"] == campaign_id && campaign["status"] == STATUS_RUNNING
|
302
|
+
group_campaigns.append(campaign)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
group_campaigns
|
308
|
+
end
|
309
|
+
|
252
310
|
end
|
253
311
|
end
|
254
312
|
end
|
data/lib/vwo/utils/feature.rb
CHANGED
@@ -38,6 +38,8 @@ class VWO
|
|
38
38
|
return value.to_f if variable_type == VariableTypes::DOUBLE
|
39
39
|
|
40
40
|
return !value || value == 0 ? false : true if variable_type == VariableTypes.BOOLEAN
|
41
|
+
|
42
|
+
return value if variable_type == VariableTypes::JSON
|
41
43
|
rescue StandardError => _e
|
42
44
|
VWO::Logger.get_instance.log(
|
43
45
|
LogLevelEnum::ERROR,
|
data/lib/vwo.rb
CHANGED
@@ -413,7 +413,6 @@ class VWO
|
|
413
413
|
)
|
414
414
|
end
|
415
415
|
end
|
416
|
-
variation['name']
|
417
416
|
else
|
418
417
|
@logger.log(
|
419
418
|
LogLevelEnum::INFO,
|
@@ -425,8 +424,8 @@ class VWO
|
|
425
424
|
api_name: ApiMethods::ACTIVATE
|
426
425
|
)
|
427
426
|
)
|
428
|
-
nil
|
429
427
|
end
|
428
|
+
variation['name']
|
430
429
|
rescue StandardError => e
|
431
430
|
@logger.log(
|
432
431
|
LogLevelEnum::ERROR,
|
@@ -437,7 +436,7 @@ class VWO
|
|
437
436
|
exception: e
|
438
437
|
)
|
439
438
|
)
|
440
|
-
|
439
|
+
e
|
441
440
|
end
|
442
441
|
|
443
442
|
# This API method: Gets the variation name assigned for the
|
@@ -563,10 +562,11 @@ class VWO
|
|
563
562
|
# @param[String] :campaign_key Unique campaign key
|
564
563
|
# @param[String] :user_id ID assigned to a user
|
565
564
|
# @param[String] :goal_identifier Unique campaign's goal identifier
|
566
|
-
# @param[
|
565
|
+
# @param[Hash] :options Contains revenue value and custom variables
|
567
566
|
# @param[Numeric|String] :revenue_value It is the revenue generated on triggering the goal
|
568
567
|
#
|
569
|
-
|
568
|
+
|
569
|
+
def track(campaign_key, user_id, goal_identifier, options = {})
|
570
570
|
unless @is_instance_valid
|
571
571
|
@logger.log(
|
572
572
|
LogLevelEnum::ERROR,
|
@@ -579,18 +579,11 @@ class VWO
|
|
579
579
|
return false
|
580
580
|
end
|
581
581
|
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
goal_type_to_track = get_goal_type_to_track(args[0])
|
588
|
-
elsif args.is_a?(Array)
|
589
|
-
revenue_value = args[0]
|
590
|
-
custom_variables = nil
|
591
|
-
should_track_returning_user = @should_track_returning_user
|
592
|
-
goal_type_to_track = @goal_type_to_track
|
593
|
-
end
|
582
|
+
revenue_value = options['revenue_value'] || options[:revenue_value]
|
583
|
+
custom_variables = options['custom_variables'] || options[:custom_variables]
|
584
|
+
variation_targeting_variables = options['variation_targeting_variables'] || options[:variation_targeting_variables]
|
585
|
+
should_track_returning_user = get_should_track_returning_user(options)
|
586
|
+
goal_type_to_track = get_goal_type_to_track(options)
|
594
587
|
|
595
588
|
# Check for valid args
|
596
589
|
unless (valid_string?(campaign_key) || campaign_key.is_a?(Array) || campaign_key.nil?) && valid_string?(user_id) && valid_string?(goal_identifier) && (custom_variables.nil? || valid_hash?(custom_variables)) &&
|
@@ -617,147 +610,149 @@ class VWO
|
|
617
610
|
|
618
611
|
result = {}
|
619
612
|
campaigns.each do |campaign|
|
620
|
-
|
613
|
+
begin
|
614
|
+
campaign_type = campaign['type']
|
621
615
|
|
622
|
-
|
623
|
-
@logger.log(
|
624
|
-
LogLevelEnum::ERROR,
|
625
|
-
format(
|
626
|
-
LogMessageEnum::ErrorMessages::INVALID_API,
|
627
|
-
file: FILE,
|
628
|
-
api_name: ApiMethods::TRACK,
|
629
|
-
user_id: user_id,
|
630
|
-
campaign_key: campaign['key'],
|
631
|
-
campaign_type: campaign_type
|
632
|
-
)
|
633
|
-
)
|
634
|
-
result[campaign['key']] = false
|
635
|
-
next
|
636
|
-
end
|
637
|
-
|
638
|
-
variation = @variation_decider.get_variation(user_id, campaign, ApiMethods::TRACK, campaign['key'], custom_variables, variation_targeting_variables, goal_identifier)
|
639
|
-
|
640
|
-
if variation
|
641
|
-
goal = get_campaign_goal(campaign, goal_identifier)
|
642
|
-
if goal.nil? || !goal["id"]
|
643
|
-
@logger.log(
|
644
|
-
LogLevelEnum::ERROR,
|
645
|
-
format(
|
646
|
-
LogMessageEnum::ErrorMessages::TRACK_API_GOAL_NOT_FOUND,
|
647
|
-
file: FILE,
|
648
|
-
goal_identifier: goal_identifier,
|
649
|
-
user_id: user_id,
|
650
|
-
campaign_key: campaign['key'],
|
651
|
-
api_name: ApiMethods::TRACK
|
652
|
-
)
|
653
|
-
)
|
654
|
-
result[campaign['key']] = false
|
655
|
-
next
|
656
|
-
elsif goal['type'] == GoalTypes::REVENUE && !valid_value?(revenue_value)
|
616
|
+
if campaign_type == CampaignTypes::FEATURE_ROLLOUT
|
657
617
|
@logger.log(
|
658
618
|
LogLevelEnum::ERROR,
|
659
619
|
format(
|
660
|
-
LogMessageEnum::ErrorMessages::
|
620
|
+
LogMessageEnum::ErrorMessages::INVALID_API,
|
661
621
|
file: FILE,
|
622
|
+
api_name: ApiMethods::TRACK,
|
662
623
|
user_id: user_id,
|
663
|
-
goal_identifier: goal_identifier,
|
664
624
|
campaign_key: campaign['key'],
|
665
|
-
|
625
|
+
campaign_type: campaign_type
|
666
626
|
)
|
667
627
|
)
|
668
628
|
result[campaign['key']] = false
|
669
629
|
next
|
670
|
-
elsif goal['type'] == GoalTypes::CUSTOM
|
671
|
-
revenue_value = nil
|
672
630
|
end
|
673
631
|
|
674
|
-
|
675
|
-
identifiers = variation['goal_identifier'].split(VWO_DELIMITER)
|
676
|
-
else
|
677
|
-
variation['goal_identifier'] = ''
|
678
|
-
identifiers = []
|
679
|
-
end
|
632
|
+
variation = @variation_decider.get_variation(user_id, campaign, ApiMethods::TRACK, campaign['key'], custom_variables, variation_targeting_variables, goal_identifier)
|
680
633
|
|
681
|
-
if
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
goal_identifier: goal_identifier,
|
695
|
-
api_name: ApiMethods::TRACK
|
634
|
+
if variation
|
635
|
+
goal = get_campaign_goal(campaign, goal_identifier)
|
636
|
+
if goal.nil? || !goal["id"]
|
637
|
+
@logger.log(
|
638
|
+
LogLevelEnum::ERROR,
|
639
|
+
format(
|
640
|
+
LogMessageEnum::ErrorMessages::TRACK_API_GOAL_NOT_FOUND,
|
641
|
+
file: FILE,
|
642
|
+
goal_identifier: goal_identifier,
|
643
|
+
user_id: user_id,
|
644
|
+
campaign_key: campaign['key'],
|
645
|
+
api_name: ApiMethods::TRACK
|
646
|
+
)
|
696
647
|
)
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
end
|
701
|
-
|
702
|
-
if defined?(@batch_events)
|
703
|
-
impression = create_bulk_event_impression(
|
704
|
-
@settings_file,
|
705
|
-
campaign['id'],
|
706
|
-
variation['id'],
|
707
|
-
user_id,
|
708
|
-
goal['id'],
|
709
|
-
revenue_value
|
710
|
-
)
|
711
|
-
@batch_events_queue.enqueue(impression)
|
712
|
-
else
|
713
|
-
impression = create_impression(
|
714
|
-
@settings_file,
|
715
|
-
campaign['id'],
|
716
|
-
variation['id'],
|
717
|
-
user_id,
|
718
|
-
@sdk_key,
|
719
|
-
goal['id'],
|
720
|
-
revenue_value
|
721
|
-
)
|
722
|
-
if @event_dispatcher.dispatch(impression)
|
648
|
+
result[campaign['key']] = false
|
649
|
+
next
|
650
|
+
elsif goal['type'] == GoalTypes::REVENUE && !valid_value?(revenue_value)
|
723
651
|
@logger.log(
|
724
|
-
LogLevelEnum::
|
652
|
+
LogLevelEnum::ERROR,
|
725
653
|
format(
|
726
|
-
LogMessageEnum::
|
654
|
+
LogMessageEnum::ErrorMessages::TRACK_API_REVENUE_NOT_PASSED_FOR_REVENUE_GOAL,
|
727
655
|
file: FILE,
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
end_point: EVENTS::TRACK_GOAL
|
656
|
+
user_id: user_id,
|
657
|
+
goal_identifier: goal_identifier,
|
658
|
+
campaign_key: campaign['key'],
|
659
|
+
api_name: ApiMethods::TRACK
|
733
660
|
)
|
734
661
|
)
|
662
|
+
result[campaign['key']] = false
|
663
|
+
next
|
664
|
+
elsif goal['type'] == GoalTypes::CUSTOM
|
665
|
+
revenue_value = nil
|
666
|
+
end
|
667
|
+
|
668
|
+
if variation['goal_identifier']
|
669
|
+
identifiers = variation['goal_identifier'].split(VWO_DELIMITER)
|
670
|
+
else
|
671
|
+
variation['goal_identifier'] = ''
|
672
|
+
identifiers = []
|
673
|
+
end
|
674
|
+
|
675
|
+
if !identifiers.include? goal_identifier
|
676
|
+
updated_goal_identifier = variation['goal_identifier']
|
677
|
+
updated_goal_identifier += VWO_DELIMITER + goal_identifier
|
678
|
+
@variation_decider.save_user_storage(user_id, campaign['key'], campaign['name'], variation['name'], updated_goal_identifier) if variation['name']
|
679
|
+
# set variation at user storage
|
680
|
+
elsif !should_track_returning_user
|
735
681
|
@logger.log(
|
736
682
|
LogLevelEnum::INFO,
|
737
683
|
format(
|
738
|
-
LogMessageEnum::InfoMessages::
|
684
|
+
LogMessageEnum::InfoMessages::GOAL_ALREADY_TRACKED,
|
739
685
|
file: FILE,
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
686
|
+
user_id: user_id,
|
687
|
+
campaign_key: campaign['key'],
|
688
|
+
goal_identifier: goal_identifier,
|
689
|
+
api_name: ApiMethods::TRACK
|
744
690
|
)
|
745
691
|
)
|
692
|
+
result[campaign['key']] = false
|
693
|
+
next
|
694
|
+
end
|
695
|
+
|
696
|
+
if defined?(@batch_events)
|
697
|
+
impression = create_bulk_event_impression(
|
698
|
+
@settings_file,
|
699
|
+
campaign['id'],
|
700
|
+
variation['id'],
|
701
|
+
user_id,
|
702
|
+
goal['id'],
|
703
|
+
revenue_value
|
704
|
+
)
|
705
|
+
@batch_events_queue.enqueue(impression)
|
706
|
+
else
|
707
|
+
impression = create_impression(
|
708
|
+
@settings_file,
|
709
|
+
campaign['id'],
|
710
|
+
variation['id'],
|
711
|
+
user_id,
|
712
|
+
@sdk_key,
|
713
|
+
goal['id'],
|
714
|
+
revenue_value
|
715
|
+
)
|
716
|
+
if @event_dispatcher.dispatch(impression)
|
717
|
+
@logger.log(
|
718
|
+
LogLevelEnum::INFO,
|
719
|
+
format(
|
720
|
+
LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS,
|
721
|
+
file: FILE,
|
722
|
+
sdk_key: @sdk_key,
|
723
|
+
account_id: @account_id,
|
724
|
+
campaign_id: campaign['id'],
|
725
|
+
variation_id: variation['id'],
|
726
|
+
end_point: EVENTS::TRACK_GOAL
|
727
|
+
)
|
728
|
+
)
|
729
|
+
@logger.log(
|
730
|
+
LogLevelEnum::INFO,
|
731
|
+
format(
|
732
|
+
LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
|
733
|
+
file: FILE,
|
734
|
+
sdk_key: @sdk_key,
|
735
|
+
campaign_id: impression[:experiment_id],
|
736
|
+
account_id: impression[:account_id],
|
737
|
+
variation_id: impression[:combination]
|
738
|
+
)
|
739
|
+
)
|
740
|
+
end
|
746
741
|
end
|
742
|
+
result[campaign['key']] = true
|
743
|
+
next
|
747
744
|
end
|
748
|
-
result[campaign['key']] =
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
file: FILE,
|
758
|
-
exception: e
|
745
|
+
result[campaign['key']] = false
|
746
|
+
rescue StandardError => e
|
747
|
+
@logger.log(
|
748
|
+
LogLevelEnum::ERROR,
|
749
|
+
format(
|
750
|
+
e.message,
|
751
|
+
file: FILE,
|
752
|
+
exception: e
|
753
|
+
)
|
759
754
|
)
|
760
|
-
|
755
|
+
end
|
761
756
|
end
|
762
757
|
|
763
758
|
if result.length() == 0
|
@@ -874,80 +869,85 @@ class VWO
|
|
874
869
|
return false unless variation
|
875
870
|
|
876
871
|
# if campaign type is feature_test Send track call to server
|
877
|
-
if campaign_type == CampaignTypes::FEATURE_TEST
|
878
|
-
if is_eligible_to_send_impression(should_track_returning_user)
|
879
|
-
if defined?(@batch_events)
|
880
|
-
impression = create_bulk_event_impression(
|
881
|
-
@settings_file,
|
882
|
-
campaign['id'],
|
883
|
-
variation['id'],
|
884
|
-
user_id
|
885
|
-
)
|
886
|
-
@batch_events_queue.enqueue(impression)
|
887
|
-
else
|
888
|
-
impression = create_impression(
|
889
|
-
@settings_file,
|
890
|
-
campaign['id'],
|
891
|
-
variation['id'],
|
892
|
-
user_id,
|
893
|
-
@sdk_key,
|
894
|
-
goal_id: nil,
|
895
|
-
revenue: nil,
|
896
|
-
usage_stats: @usage_stats.usage_stats
|
897
|
-
)
|
898
872
|
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
variation_id: impression[:combination]
|
909
|
-
)
|
910
|
-
)
|
911
|
-
end
|
912
|
-
result = variation['isFeatureEnabled']
|
913
|
-
if result
|
914
|
-
@logger.log(
|
915
|
-
LogLevelEnum::INFO,
|
916
|
-
format(
|
917
|
-
LogMessageEnum::InfoMessages::FEATURE_ENABLED_FOR_USER,
|
918
|
-
file: FILE,
|
919
|
-
user_id: user_id,
|
920
|
-
feature_key: campaign_key,
|
921
|
-
api_name: ApiMethods::IS_FEATURE_ENABLED
|
922
|
-
)
|
923
|
-
)
|
924
|
-
else
|
925
|
-
@logger.log(
|
926
|
-
LogLevelEnum::INFO,
|
927
|
-
format(
|
928
|
-
LogMessageEnum::InfoMessages::FEATURE_NOT_ENABLED_FOR_USER,
|
929
|
-
file: FILE,
|
930
|
-
user_id: user_id,
|
931
|
-
feature_key: campaign_key,
|
932
|
-
api_name: ApiMethods::IS_FEATURE_ENABLED
|
933
|
-
)
|
934
|
-
)
|
935
|
-
end
|
936
|
-
return result
|
873
|
+
if is_eligible_to_send_impression(should_track_returning_user)
|
874
|
+
if defined?(@batch_events)
|
875
|
+
impression = create_bulk_event_impression(
|
876
|
+
@settings_file,
|
877
|
+
campaign['id'],
|
878
|
+
variation['id'],
|
879
|
+
user_id
|
880
|
+
)
|
881
|
+
@batch_events_queue.enqueue(impression)
|
937
882
|
else
|
883
|
+
impression = create_impression(
|
884
|
+
@settings_file,
|
885
|
+
campaign['id'],
|
886
|
+
variation['id'],
|
887
|
+
user_id,
|
888
|
+
@sdk_key,
|
889
|
+
nil,
|
890
|
+
nil,
|
891
|
+
usage_stats: @usage_stats.usage_stats
|
892
|
+
)
|
893
|
+
|
894
|
+
@event_dispatcher.dispatch(impression)
|
938
895
|
@logger.log(
|
939
896
|
LogLevelEnum::INFO,
|
940
897
|
format(
|
941
|
-
LogMessageEnum::InfoMessages::
|
898
|
+
LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
|
942
899
|
file: FILE,
|
943
|
-
|
944
|
-
|
945
|
-
|
900
|
+
campaign_id: impression[:experiment_id],
|
901
|
+
sdk_key: @sdk_key,
|
902
|
+
account_id: impression[:account_id],
|
903
|
+
variation_id: impression[:combination]
|
946
904
|
)
|
947
905
|
)
|
948
906
|
end
|
907
|
+
|
908
|
+
else
|
909
|
+
@logger.log(
|
910
|
+
LogLevelEnum::INFO,
|
911
|
+
format(
|
912
|
+
LogMessageEnum::InfoMessages::USER_ALREADY_TRACKED,
|
913
|
+
file: FILE,
|
914
|
+
user_id: user_id,
|
915
|
+
campaign_key: campaign_key,
|
916
|
+
api_name: ApiMethods::IS_FEATURE_ENABLED
|
917
|
+
)
|
918
|
+
)
|
949
919
|
end
|
950
|
-
|
920
|
+
if campaign_type == CampaignTypes::FEATURE_ROLLOUT
|
921
|
+
result = true
|
922
|
+
else
|
923
|
+
result = variation['isFeatureEnabled']
|
924
|
+
end
|
925
|
+
|
926
|
+
if result
|
927
|
+
@logger.log(
|
928
|
+
LogLevelEnum::INFO,
|
929
|
+
format(
|
930
|
+
LogMessageEnum::InfoMessages::FEATURE_ENABLED_FOR_USER,
|
931
|
+
file: FILE,
|
932
|
+
user_id: user_id,
|
933
|
+
feature_key: campaign_key,
|
934
|
+
api_name: ApiMethods::IS_FEATURE_ENABLED
|
935
|
+
)
|
936
|
+
)
|
937
|
+
else
|
938
|
+
@logger.log(
|
939
|
+
LogLevelEnum::INFO,
|
940
|
+
format(
|
941
|
+
LogMessageEnum::InfoMessages::FEATURE_NOT_ENABLED_FOR_USER,
|
942
|
+
file: FILE,
|
943
|
+
user_id: user_id,
|
944
|
+
feature_key: campaign_key,
|
945
|
+
api_name: ApiMethods::IS_FEATURE_ENABLED
|
946
|
+
)
|
947
|
+
)
|
948
|
+
end
|
949
|
+
|
950
|
+
result
|
951
951
|
rescue StandardError => e
|
952
952
|
@logger.log(
|
953
953
|
LogLevelEnum::ERROR,
|