vwo-sdk 1.14.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b54dc7f86b437e994c1aec92ceae2afbb5f0045deeefb2ed7feb791094e025fd
4
- data.tar.gz: 4d087003e85fbccc63af443c7ba7e7068079df27e151e48df5f52952cd14e680
3
+ metadata.gz: 2307340499cf5f0fd3fd13ab5025fc4892721123c82bc3df8eff266362d01c82
4
+ data.tar.gz: a0a3343ef9af102444cd9a6dd590937d5c737a3ed46765d3bd9cb8e18ceb41bf
5
5
  SHA512:
6
- metadata.gz: 85f28097bbc3a311354e0702f27738dc9381d37e67beba61dd7978babf81b626e1a0ccee83b503fd5e5c4fe03235cde8fd875d0643fa4e50356bc8bfd101be8c
7
- data.tar.gz: 26c18b27e473970f0dd3ad2bf27fd4ff7e81c0aac6ee4eb84decd4f5a21db74e02082d34eb1dc74106890dd353d430bec7c77a3b90fd7fb09b9e92056072e719
6
+ metadata.gz: f1c28b3c5b86fa2b4488b5995a9931aaea708d1788f803c079f2fc5684fca81d82465f798e9653d227d448d6c08688791cf0740f774526ed38bd345e252b91fa
7
+ data.tar.gz: e4d2fcfca37407b7ed7ff008bc2d2d6b03e7f6bddd2f653825fd059306de36254ee4d46165e0973524e701d62e9a972c11a586089c5279027fb4ea5dc589060f
data/lib/vwo/constants.rb CHANGED
@@ -26,7 +26,7 @@ class VWO
26
26
  HTTP_PROTOCOL = 'http://'
27
27
  HTTPS_PROTOCOL = 'https://'
28
28
  URL_NAMESPACE = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'
29
- SDK_VERSION = '1.14.1'
29
+ SDK_VERSION = '1.15.0'
30
30
  SDK_NAME = 'ruby'
31
31
  VWO_DELIMITER = '_vwo_'
32
32
  MAX_EVENTS_PER_REQUEST = 5000
@@ -151,7 +151,10 @@ class VWO
151
151
 
152
152
  user_campaign_map = get_user_storage(user_id, campaign_key)
153
153
  variation = get_stored_variation(user_id, campaign_key, user_campaign_map) if valid_hash?(user_campaign_map)
154
- variation = variation.dup # deep copy
154
+
155
+ if variation
156
+ variation = variation.dup # deep copy
157
+ end
155
158
 
156
159
  if variation
157
160
  if valid_string?(user_campaign_map['goal_identifier']) && api_name == ApiMethods::TRACK
@@ -190,7 +190,7 @@ class VWO
190
190
  end
191
191
  goal = get_campaign_goal(campaign, goal_identifier)
192
192
  if validate_goal(goal, goal_type_to_track)
193
- campaigns.append(campaign)
193
+ campaigns.push(campaign)
194
194
  end
195
195
  end
196
196
  end
@@ -215,7 +215,7 @@ class VWO
215
215
 
216
216
  campaign = get_campaign_for_campaign_key_and_goal(campaign_key, settings_file, goal_identifier, goal_type_to_track)
217
217
  if campaign
218
- campaigns.append(campaign)
218
+ campaigns.push(campaign)
219
219
  end
220
220
  end
221
221
  campaigns
data/lib/vwo.rb CHANGED
@@ -437,7 +437,7 @@ class VWO
437
437
  exception: e
438
438
  )
439
439
  )
440
- nil
440
+ e
441
441
  end
442
442
 
443
443
  # This API method: Gets the variation name assigned for the
@@ -611,147 +611,149 @@ class VWO
611
611
 
612
612
  result = {}
613
613
  campaigns.each do |campaign|
614
- campaign_type = campaign['type']
615
-
616
- if campaign_type == CampaignTypes::FEATURE_ROLLOUT
617
- @logger.log(
618
- LogLevelEnum::ERROR,
619
- format(
620
- LogMessageEnum::ErrorMessages::INVALID_API,
621
- file: FILE,
622
- api_name: ApiMethods::TRACK,
623
- user_id: user_id,
624
- campaign_key: campaign['key'],
625
- campaign_type: campaign_type
626
- )
627
- )
628
- result[campaign['key']] = false
629
- next
630
- end
631
-
632
- variation = @variation_decider.get_variation(user_id, campaign, ApiMethods::TRACK, campaign['key'], custom_variables, variation_targeting_variables, goal_identifier)
614
+ begin
615
+ campaign_type = campaign['type']
633
616
 
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
- )
647
- )
648
- result[campaign['key']] = false
649
- next
650
- elsif goal['type'] == GoalTypes::REVENUE && !valid_value?(revenue_value)
617
+ if campaign_type == CampaignTypes::FEATURE_ROLLOUT
651
618
  @logger.log(
652
619
  LogLevelEnum::ERROR,
653
620
  format(
654
- LogMessageEnum::ErrorMessages::TRACK_API_REVENUE_NOT_PASSED_FOR_REVENUE_GOAL,
621
+ LogMessageEnum::ErrorMessages::INVALID_API,
655
622
  file: FILE,
623
+ api_name: ApiMethods::TRACK,
656
624
  user_id: user_id,
657
- goal_identifier: goal_identifier,
658
625
  campaign_key: campaign['key'],
659
- api_name: ApiMethods::TRACK
626
+ campaign_type: campaign_type
660
627
  )
661
628
  )
662
629
  result[campaign['key']] = false
663
630
  next
664
- elsif goal['type'] == GoalTypes::CUSTOM
665
- revenue_value = nil
666
631
  end
667
632
 
668
- if variation['goal_identifier']
669
- identifiers = variation['goal_identifier'].split(VWO_DELIMITER)
670
- else
671
- variation['goal_identifier'] = ''
672
- identifiers = []
673
- end
633
+ variation = @variation_decider.get_variation(user_id, campaign, ApiMethods::TRACK, campaign['key'], custom_variables, variation_targeting_variables, goal_identifier)
674
634
 
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'], variation['name'], updated_goal_identifier) if variation['name']
679
- # set variation at user storage
680
- elsif !should_track_returning_user
681
- @logger.log(
682
- LogLevelEnum::INFO,
683
- format(
684
- LogMessageEnum::InfoMessages::GOAL_ALREADY_TRACKED,
685
- file: FILE,
686
- user_id: user_id,
687
- campaign_key: campaign['key'],
688
- goal_identifier: goal_identifier,
689
- api_name: ApiMethods::TRACK
635
+ if variation
636
+ goal = get_campaign_goal(campaign, goal_identifier)
637
+ if goal.nil? || !goal["id"]
638
+ @logger.log(
639
+ LogLevelEnum::ERROR,
640
+ format(
641
+ LogMessageEnum::ErrorMessages::TRACK_API_GOAL_NOT_FOUND,
642
+ file: FILE,
643
+ goal_identifier: goal_identifier,
644
+ user_id: user_id,
645
+ campaign_key: campaign['key'],
646
+ api_name: ApiMethods::TRACK
647
+ )
690
648
  )
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)
649
+ result[campaign['key']] = false
650
+ next
651
+ elsif goal['type'] == GoalTypes::REVENUE && !valid_value?(revenue_value)
717
652
  @logger.log(
718
- LogLevelEnum::INFO,
653
+ LogLevelEnum::ERROR,
719
654
  format(
720
- LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS,
655
+ LogMessageEnum::ErrorMessages::TRACK_API_REVENUE_NOT_PASSED_FOR_REVENUE_GOAL,
721
656
  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
657
+ user_id: user_id,
658
+ goal_identifier: goal_identifier,
659
+ campaign_key: campaign['key'],
660
+ api_name: ApiMethods::TRACK
727
661
  )
728
662
  )
663
+ result[campaign['key']] = false
664
+ next
665
+ elsif goal['type'] == GoalTypes::CUSTOM
666
+ revenue_value = nil
667
+ end
668
+
669
+ if variation['goal_identifier']
670
+ identifiers = variation['goal_identifier'].split(VWO_DELIMITER)
671
+ else
672
+ variation['goal_identifier'] = ''
673
+ identifiers = []
674
+ end
675
+
676
+ if !identifiers.include? goal_identifier
677
+ updated_goal_identifier = variation['goal_identifier']
678
+ updated_goal_identifier += VWO_DELIMITER + goal_identifier
679
+ @variation_decider.save_user_storage(user_id, campaign['key'], variation['name'], updated_goal_identifier) if variation['name']
680
+ # set variation at user storage
681
+ elsif !should_track_returning_user
729
682
  @logger.log(
730
683
  LogLevelEnum::INFO,
731
684
  format(
732
- LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
685
+ LogMessageEnum::InfoMessages::GOAL_ALREADY_TRACKED,
733
686
  file: FILE,
734
- sdk_key: @sdk_key,
735
- campaign_id: impression[:experiment_id],
736
- account_id: impression[:account_id],
737
- variation_id: impression[:combination]
687
+ user_id: user_id,
688
+ campaign_key: campaign['key'],
689
+ goal_identifier: goal_identifier,
690
+ api_name: ApiMethods::TRACK
738
691
  )
739
692
  )
693
+ result[campaign['key']] = false
694
+ next
740
695
  end
696
+
697
+ if defined?(@batch_events)
698
+ impression = create_bulk_event_impression(
699
+ @settings_file,
700
+ campaign['id'],
701
+ variation['id'],
702
+ user_id,
703
+ goal['id'],
704
+ revenue_value
705
+ )
706
+ @batch_events_queue.enqueue(impression)
707
+ else
708
+ impression = create_impression(
709
+ @settings_file,
710
+ campaign['id'],
711
+ variation['id'],
712
+ user_id,
713
+ @sdk_key,
714
+ goal['id'],
715
+ revenue_value
716
+ )
717
+ if @event_dispatcher.dispatch(impression)
718
+ @logger.log(
719
+ LogLevelEnum::INFO,
720
+ format(
721
+ LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS,
722
+ file: FILE,
723
+ sdk_key: @sdk_key,
724
+ account_id: @account_id,
725
+ campaign_id: campaign['id'],
726
+ variation_id: variation['id'],
727
+ end_point: EVENTS::TRACK_GOAL
728
+ )
729
+ )
730
+ @logger.log(
731
+ LogLevelEnum::INFO,
732
+ format(
733
+ LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
734
+ file: FILE,
735
+ sdk_key: @sdk_key,
736
+ campaign_id: impression[:experiment_id],
737
+ account_id: impression[:account_id],
738
+ variation_id: impression[:combination]
739
+ )
740
+ )
741
+ end
742
+ end
743
+ result[campaign['key']] = true
744
+ next
741
745
  end
742
- result[campaign['key']] = true
743
- next
744
- end
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
746
+ result[campaign['key']] = false
747
+ rescue StandardError => e
748
+ @logger.log(
749
+ LogLevelEnum::ERROR,
750
+ format(
751
+ e.message,
752
+ file: FILE,
753
+ exception: e
754
+ )
753
755
  )
754
- )
756
+ end
755
757
  end
756
758
 
757
759
  if result.length() == 0
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vwo-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.1
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VWO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-10 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: coveralls
14
+ name: codecov
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.23
19
+ version: 0.4.3
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.23
26
+ version: 0.4.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.1'
83
- description: A Ruby SDK for VWO full-stack testing.
83
+ description: Ruby SDK for VWO FullStack testing.
84
84
  email:
85
85
  - dev@wingify.com
86
86
  executables: []
@@ -116,7 +116,12 @@ files:
116
116
  homepage: https://vwo.com/fullstack/server-side-testing/
117
117
  licenses:
118
118
  - Apache-2.0
119
- metadata: {}
119
+ metadata:
120
+ bug_tracker_uri: https://github.com/wingify/vwo-ruby-sdk/issues
121
+ changelog_uri: https://github.com/wingify/vwo-ruby-sdk/blob/master/CHANGELOG.md
122
+ documentation_uri: https://developers.vwo.com/docs/ruby-sdk-reference
123
+ homepage_uri: https://github.com/wingify/vwo-ruby-sdk
124
+ source_code_uri: https://github.com/wingify/vwo-ruby-sdk
120
125
  post_install_message:
121
126
  rdoc_options: []
122
127
  require_paths:
@@ -125,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
130
  requirements:
126
131
  - - ">="
127
132
  - !ruby/object:Gem::Version
128
- version: '0'
133
+ version: 2.2.10
129
134
  required_rubygems_version: !ruby/object:Gem::Requirement
130
135
  requirements:
131
136
  - - ">="
@@ -135,5 +140,5 @@ requirements: []
135
140
  rubygems_version: 3.0.6
136
141
  signing_key:
137
142
  specification_version: 4
138
- summary: Ruby SDK for VWO full-stack testing
143
+ summary: Ruby SDK for VWO FullStack testing
139
144
  test_files: []