vwo-sdk 1.30.0 → 1.35.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: a8bf50eeb65a850a9a49fb00628208670c6bd7a167c591d8d649573fa0a67bc7
4
- data.tar.gz: cfc520d123444c23f36683a1d89bef145e466ea21a9044543641226614e076df
3
+ metadata.gz: dfb56a7b9b42ecdd68adf08aec9d3730718f06e2524391cdd13e36b102f2a101
4
+ data.tar.gz: 24c6d8e61d28e47af3d2e15c7d1bf359a4b0baf2a45db4c4ca6c020b65b937e7
5
5
  SHA512:
6
- metadata.gz: 1e79a2e33a718e0379724b39d115f59e4ef0925f9dcc682f6c553166af90d444f7a74c5551a9474051fcee1213104a8b6fe8c9842a51da1be90f76020c38a3da
7
- data.tar.gz: 553e1b3553f5c3b49d3d1dae6fdd176706129d892439b04517d5e670f1945b91246c69ec0a2ceb95b14ad7334fb4b9b580cbbc26be1cbfd10495f77fae13673c
6
+ metadata.gz: 07b6bc00eb777b88e60a1adaa0faa186b214ae492b86af876c3118e9eecac6d598de0e1e60d9abc54d20877ded9c0236c0661d5be9f1d92a1ee5d7f902ad3b9e
7
+ data.tar.gz: 80163a10745a7683a56dfa3717de522414a38110a54645e609bf8c4522451eca7c1175f5d02b1bfa3efe244aeffe6dfee523d6bf4a3b101bda789550fd967a3d
data/lib/vwo/constants.rb CHANGED
@@ -27,7 +27,7 @@ class VWO
27
27
  HTTP_PROTOCOL = 'http://'
28
28
  HTTPS_PROTOCOL = 'https://'
29
29
  URL_NAMESPACE = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'
30
- SDK_VERSION = '1.30.0'
30
+ SDK_VERSION = '1.35.0'
31
31
  SDK_NAME = 'ruby'
32
32
  VWO_DELIMITER = '_vwo_'
33
33
  MAX_EVENTS_PER_REQUEST = 5000
@@ -94,6 +94,7 @@ class VWO
94
94
  }
95
95
 
96
96
  module ApiMethods
97
+ LAUNCH = 'launch'
97
98
  ACTIVATE = 'activate'
98
99
  GET_VARIATION_NAME = 'get_variation_name'
99
100
  TRACK = 'track'
@@ -13,9 +13,9 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'murmurhash3'
16
- require_relative '../logger'
17
16
  require_relative '../enums'
18
17
  require_relative '../utils/validations'
18
+ require_relative '../utils/log_message'
19
19
  require_relative '../constants'
20
20
 
21
21
  class VWO
@@ -34,37 +34,45 @@ class VWO
34
34
  FILE = FileNameEnum::Bucketer
35
35
 
36
36
  def initialize
37
- @logger = VWO::Logger.get_instance
37
+ @logger = VWO::Utils::Logger
38
38
  end
39
39
 
40
40
  # Calculate if this user should become part of the campaign or not
41
41
  # @param[String] :user_id The unique ID assigned to a user
42
42
  # @param[Dict] :campaign For getting traffic allotted to the campaign
43
+ # @param[Boolean] :disable_logs if true, do not log log-message
43
44
  # @return[Boolean] If User is a part of Campaign or not
44
45
 
45
- def user_part_of_campaign?(user_id, campaign)
46
+ def user_part_of_campaign?(user_id, campaign, disable_logs = false)
46
47
  unless valid_value?(user_id)
47
48
  @logger.log(
48
49
  LogLevelEnum::ERROR,
49
- format(LogMessageEnum::ErrorMessages::INVALID_USER_ID, file: FILE, user_id: user_id, method: 'is_user_part_of_campaign')
50
+ 'USER_ID_INVALID',
51
+ {
52
+ '{file}' => FILE,
53
+ '{userId}' => user_id
54
+ }
50
55
  )
51
56
  return false
52
57
  end
53
58
 
54
59
  if campaign.nil?
55
- @logger.log(
56
- LogLevelEnum::ERROR,
57
- format(LogMessageEnum::ErrorMessages::INVALID_CAMPAIGN, file: FILE, method: 'is_user_part_of_campaign')
58
- )
59
60
  return false
60
61
  end
61
62
 
62
63
  traffic_allocation = campaign['percentTraffic']
63
- value_assigned_to_user = get_bucket_value_for_user(user_id, campaign)
64
+ value_assigned_to_user = get_bucket_value_for_user(user_id, campaign, nil, disable_logs)
64
65
  is_user_part = (value_assigned_to_user != 0) && value_assigned_to_user <= traffic_allocation
65
66
  @logger.log(
66
67
  LogLevelEnum::INFO,
67
- format(LogMessageEnum::InfoMessages::USER_ELIGIBILITY_FOR_CAMPAIGN, file: FILE, user_id: user_id, is_user_part: is_user_part)
68
+ 'USER_CAMPAIGN_ELIGIBILITY',
69
+ {
70
+ '{file}' => FILE,
71
+ '{userId}' => user_id,
72
+ '{status}' => is_user_part ? 'eligible' : 'not eligible',
73
+ '{campaignKey}' => campaign['key']
74
+ },
75
+ disable_logs
68
76
  )
69
77
  is_user_part
70
78
  end
@@ -74,23 +82,24 @@ class VWO
74
82
  #
75
83
  # @param[String] :user_id The unique ID assigned to User
76
84
  # @param[Hash] :campaign The Campaign of which User is a part of
85
+ # @param[Boolean] :disable_logs if true, do not log log-message
77
86
  #
78
87
  # @return[Hash|nil} Variation data into which user is bucketed to
79
88
  # or nil if not
80
- def bucket_user_to_variation(user_id, campaign)
89
+ def bucket_user_to_variation(user_id, campaign, disable_logs = false)
81
90
  unless valid_value?(user_id)
82
91
  @logger.log(
83
92
  LogLevelEnum::ERROR,
84
- format(LogMessageEnum::ErrorMessages::INVALID_USER_ID, file: FILE, user_id: user_id, method: 'bucket_user_to_variation')
93
+ 'USER_ID_INVALID',
94
+ {
95
+ '{file}' => FILE,
96
+ '{userId}' => user_id
97
+ }
85
98
  )
86
99
  return
87
100
  end
88
101
 
89
102
  unless campaign
90
- @logger.log(
91
- LogLevelEnum::ERROR,
92
- format(LogMessageEnum::ErrorMessages::INVALID_CAMPAIGN, file: FILE, method: 'is_user_part_of_campaign')
93
- )
94
103
  return
95
104
  end
96
105
 
@@ -109,15 +118,16 @@ class VWO
109
118
 
110
119
  @logger.log(
111
120
  LogLevelEnum::DEBUG,
112
- format(
113
- LogMessageEnum::DebugMessages::VARIATION_HASH_BUCKET_VALUE,
114
- file: FILE,
115
- user_id: user_id,
116
- campaign_key: campaign['key'],
117
- percent_traffic: campaign['percentTraffic'],
118
- bucket_value: bucket_value,
119
- hash_value: hash_value
120
- )
121
+ 'USER_CAMPAIGN_BUCKET_VALUES',
122
+ {
123
+ '{file}' => FILE,
124
+ '{campaignKey}' => campaign['key'],
125
+ '{userId}' => user_id,
126
+ '{percentTraffic}' => campaign['percentTraffic'],
127
+ '{hashValue}' => hash_value,
128
+ '{bucketValue}' => bucket_value,
129
+ },
130
+ disable_logs
121
131
  )
122
132
 
123
133
  get_variation(campaign['variations'], bucket_value)
@@ -155,13 +165,13 @@ class VWO
155
165
 
156
166
  @logger.log(
157
167
  LogLevelEnum::DEBUG,
158
- format(
159
- LogMessageEnum::DebugMessages::USER_HASH_BUCKET_VALUE,
160
- file: FILE,
161
- hash_value: hash_value,
162
- bucket_value: bucket_value,
163
- user_id: user_id
164
- ),
168
+ 'USER_HASH_BUCKET_VALUE',
169
+ {
170
+ '{file}' => FILE,
171
+ '{hashValue}' => hash_value,
172
+ '{userId}' => user_id,
173
+ '{bucketValue}' => bucket_value
174
+ },
165
175
  disable_logs
166
176
  )
167
177
  bucket_value