vwo-sdk 1.24.1 → 1.25.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/vwo/constants.rb +7 -1
- data/lib/vwo/enums.rb +4 -0
- data/lib/vwo/schemas/settings_file.rb +3 -0
- data/lib/vwo/services/event_dispatcher.rb +34 -0
- data/lib/vwo/utils/function.rb +5 -0
- data/lib/vwo/utils/impression.rb +180 -0
- data/lib/vwo/utils/request.rb +14 -0
- data/lib/vwo.rb +84 -40
- 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: 4871df5d5a50f01ed13a11692aa6b114f03242f4c9257eccb48bce2a65beaa7c
|
|
4
|
+
data.tar.gz: fdd46869b068d589e4a85402d10d8852c4bfc48084e75a18fe8631f3a99b07a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c23fe3a4fbcb4c85ef1af73a7ef9bb37a0a79eb4f628bad726f66394291cd93d24cecc066a662799670d10b703265eb3afe72a689ce060a2756eb84d0bfce69
|
|
7
|
+
data.tar.gz: f60e3e5a8b96e2ab878929c857d4c8d5c3071e6439e811ac59e7bfa00b488f6c79583ebbfa4a8995a3adac5faf80b7c9293ebea3fa0da231224c684ed39adbb4
|
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
|
+
SDK_VERSION = '1.25.0'
|
|
31
31
|
SDK_NAME = 'ruby'
|
|
32
32
|
VWO_DELIMITER = '_vwo_'
|
|
33
33
|
MAX_EVENTS_PER_REQUEST = 5000
|
|
@@ -44,6 +44,7 @@ class VWO
|
|
|
44
44
|
TRACK_GOAL = '/server-side/track-goal'
|
|
45
45
|
PUSH = '/server-side/push'
|
|
46
46
|
BATCH_EVENTS = '/server-side/batch-events'
|
|
47
|
+
EVENTS = '/events/t'
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
module EVENTS
|
|
@@ -113,5 +114,10 @@ class VWO
|
|
|
113
114
|
FEATURE_TEST = 'FEATURE_TEST'
|
|
114
115
|
FEATURE_ROLLOUT = 'FEATURE_ROLLOUT'
|
|
115
116
|
end
|
|
117
|
+
|
|
118
|
+
module EventEnum
|
|
119
|
+
VWO_VARIATION_SHOWN = 'vwo_variationShown'
|
|
120
|
+
VWO_SYNC_VISITOR_PROP = 'vwo_syncVisitorProp'
|
|
121
|
+
end
|
|
116
122
|
end
|
|
117
123
|
end
|
data/lib/vwo/enums.rb
CHANGED
|
@@ -114,6 +114,9 @@ class VWO
|
|
|
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
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"
|
|
117
|
+
IMPRESSION_FOR_EVENT_ARCH_TRACK_USER = "(%<file>s): impression built for vwo_variationShown event for account ID:%<a>s, user ID:%<u>s, and campaign ID:%<c>s"
|
|
118
|
+
IMPRESSION_FOR_EVENT_ARCH_TRACK_GOAL = "(%<file>s): impression built for %<goal_identifier>s event for account ID:%<a>s, user ID:%<u>s, and campaign ID:%<c>s"
|
|
119
|
+
IMPRESSION_FOR_EVENT_ARCH_PUSH = "(%<file>s): impression built for visitor property:%<property>s for account ID:%<a>s and user ID:%<u>s"
|
|
117
120
|
end
|
|
118
121
|
|
|
119
122
|
# Info Messages
|
|
@@ -128,6 +131,7 @@ class VWO
|
|
|
128
131
|
AUDIENCE_CONDITION_NOT_MET = '(%<file>s): userId:%<user_id>s does not become part of campaign because of not meeting audience conditions'
|
|
129
132
|
GOT_VARIATION_FOR_USER = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s got variationName:%<variation_name>s'
|
|
130
133
|
USER_GOT_NO_VARIATION = '(%<file>s): userId:%<user_id>s for campaign:%<campaign_key>s did not allot any variation'
|
|
134
|
+
IMPRESSION_SUCCESS_FOR_EVENT_ARCH = '(%<file>s): Impression for %<event>s - %<url>s was successfully received by VWO for account ID:%<a>s'
|
|
131
135
|
IMPRESSION_SUCCESS = '(%<file>s): Impression event - %<end_point>s was successfully received by VWO having main keys: accountId:%<account_id>s campaignId:%<campaign_id>s and variationId:%<variation_id>s'
|
|
132
136
|
MAIN_KEYS_FOR_IMPRESSION = '(%<file>s): Having main keys: accountId:%<account_id>s campaignId:%<campaign_id>s and variationId:%<variation_id>s}'
|
|
133
137
|
MAIN_KEYS_FOR_PUSH_API = '(%<file>s): Having main keys: accountId:%<account_id>s u:%<u>s and tags:%<tags>s}'
|
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
require_relative '../logger'
|
|
16
16
|
require_relative '../enums'
|
|
17
17
|
require_relative '../utils/request'
|
|
18
|
+
require_relative '../constants'
|
|
18
19
|
|
|
19
20
|
class VWO
|
|
20
21
|
module Services
|
|
21
22
|
class EventDispatcher
|
|
22
23
|
include VWO::Enums
|
|
24
|
+
include VWO::CONSTANTS
|
|
23
25
|
|
|
24
26
|
EXCLUDE_KEYS = ['url'].freeze
|
|
25
27
|
|
|
@@ -63,6 +65,38 @@ class VWO
|
|
|
63
65
|
)
|
|
64
66
|
false
|
|
65
67
|
end
|
|
68
|
+
|
|
69
|
+
def dispatch_event_arch_post(params, post_data)
|
|
70
|
+
return true if @is_development_mode
|
|
71
|
+
|
|
72
|
+
url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL + ENDPOINTS::EVENTS
|
|
73
|
+
resp = VWO::Utils::Request.event_post(url, params, post_data, SDK_NAME)
|
|
74
|
+
if resp.code == '200'
|
|
75
|
+
@logger.log(
|
|
76
|
+
LogLevelEnum::INFO,
|
|
77
|
+
format(
|
|
78
|
+
LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS_FOR_EVENT_ARCH,
|
|
79
|
+
file: FileNameEnum::EventDispatcher,
|
|
80
|
+
event: 'visitor property:' + JSON.generate(post_data[:d][:visitor][:props]),
|
|
81
|
+
url: url,
|
|
82
|
+
a: params[:a]
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
true
|
|
86
|
+
else
|
|
87
|
+
@logger.log(
|
|
88
|
+
LogLevelEnum::ERROR,
|
|
89
|
+
format(LogMessageEnum::ErrorMessages::IMPRESSION_FAILED, file: FileNameEnum::EventDispatcher, end_point: url)
|
|
90
|
+
)
|
|
91
|
+
false
|
|
92
|
+
end
|
|
93
|
+
rescue StandardError
|
|
94
|
+
@logger.log(
|
|
95
|
+
LogLevelEnum::ERROR,
|
|
96
|
+
format(LogMessageEnum::ErrorMessages::IMPRESSION_FAILED, file: FileNameEnum::EventDispatcher, end_point: url)
|
|
97
|
+
)
|
|
98
|
+
false
|
|
99
|
+
end
|
|
66
100
|
end
|
|
67
101
|
end
|
|
68
102
|
end
|
data/lib/vwo/utils/function.rb
CHANGED
data/lib/vwo/utils/impression.rb
CHANGED
|
@@ -164,6 +164,186 @@ class VWO
|
|
|
164
164
|
end
|
|
165
165
|
impression
|
|
166
166
|
end
|
|
167
|
+
|
|
168
|
+
# Builds generic properties for different tracking calls required by VWO servers.
|
|
169
|
+
#
|
|
170
|
+
# @param[Hash] :settings_file
|
|
171
|
+
# @param[String] :sdk_key
|
|
172
|
+
# @param[String] :event_name
|
|
173
|
+
# @param[Hash] :usage_stats
|
|
174
|
+
# @return[Hash] :properties
|
|
175
|
+
#
|
|
176
|
+
def get_events_base_properties(settings_file, event_name, usage_stats = {})
|
|
177
|
+
properties = {
|
|
178
|
+
en: event_name,
|
|
179
|
+
a: settings_file['accountId'],
|
|
180
|
+
env: settings_file['sdkKey'],
|
|
181
|
+
eTime: get_current_unix_timestamp_in_millis,
|
|
182
|
+
random: get_random_number,
|
|
183
|
+
p: "FS"
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if event_name == EventEnum::VWO_VARIATION_SHOWN
|
|
187
|
+
properties = properties.merge(usage_stats)
|
|
188
|
+
end
|
|
189
|
+
properties
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Builds generic payload required by all the different tracking calls.
|
|
193
|
+
#
|
|
194
|
+
# @param[Hash] :settings_file
|
|
195
|
+
# @param[String] :user_id
|
|
196
|
+
# @param[String] :event_name
|
|
197
|
+
# @param[Hash] :usage_stats
|
|
198
|
+
# @return[Hash] :properties
|
|
199
|
+
#
|
|
200
|
+
def get_event_base_payload(settings_file, user_id, event_name, usage_stats = {})
|
|
201
|
+
uuid = generator_for(user_id, (settings_file['accountId']))
|
|
202
|
+
sdk_key = settings_file['sdkKey']
|
|
203
|
+
|
|
204
|
+
props = {
|
|
205
|
+
sdkName: SDK_NAME,
|
|
206
|
+
sdkVersion: SDK_VERSION,
|
|
207
|
+
'$visitor': {
|
|
208
|
+
props: {
|
|
209
|
+
vwo_fs_environment: sdk_key
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
# if usage_stats
|
|
215
|
+
# props = props.merge(usage_stats)
|
|
216
|
+
# end
|
|
217
|
+
|
|
218
|
+
properties = {
|
|
219
|
+
d: {
|
|
220
|
+
msgId: uuid + '_' + Time.now.to_i.to_s,
|
|
221
|
+
visId: uuid,
|
|
222
|
+
sessionId: Time.now.to_i,
|
|
223
|
+
event: {
|
|
224
|
+
props: props,
|
|
225
|
+
name: event_name,
|
|
226
|
+
time: get_current_unix_timestamp_in_millis
|
|
227
|
+
},
|
|
228
|
+
visitor: {
|
|
229
|
+
props: {
|
|
230
|
+
vwo_fs_environment: sdk_key
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
properties
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Builds payload to track the visitor.
|
|
240
|
+
#
|
|
241
|
+
# @param[Hash] :settings_file
|
|
242
|
+
# @param[String] :user_id
|
|
243
|
+
# @param[String] :event_name
|
|
244
|
+
# @param[Integer] :campaign_id
|
|
245
|
+
# @param[Integer] :variation_id
|
|
246
|
+
# @param[Hash] :usage_stats
|
|
247
|
+
# @return[Hash] :properties
|
|
248
|
+
#
|
|
249
|
+
def get_track_user_payload_data(settings_file, user_id, event_name, campaign_id, variation_id, usage_stats = {})
|
|
250
|
+
properties = get_event_base_payload(settings_file, user_id, event_name)
|
|
251
|
+
properties[:d][:event][:props][:id] = campaign_id
|
|
252
|
+
properties[:d][:event][:props][:variation] = variation_id
|
|
253
|
+
|
|
254
|
+
#this is currently required by data-layer team, we can make changes on DACDN and remove it from here
|
|
255
|
+
properties[:d][:event][:props][:isFirst] = 1
|
|
256
|
+
|
|
257
|
+
logger = VWO::Logger.get_instance
|
|
258
|
+
logger.log(
|
|
259
|
+
LogLevelEnum::DEBUG,
|
|
260
|
+
format(
|
|
261
|
+
LogMessageEnum::DebugMessages::IMPRESSION_FOR_EVENT_ARCH_TRACK_USER,
|
|
262
|
+
file: FileNameEnum::ImpressionUtil,
|
|
263
|
+
a: settings_file['accountId'],
|
|
264
|
+
u: user_id,
|
|
265
|
+
c: campaign_id.to_s
|
|
266
|
+
)
|
|
267
|
+
)
|
|
268
|
+
properties
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# Builds payload to track the Goal.
|
|
272
|
+
#
|
|
273
|
+
# @param[Hash] :settings_file
|
|
274
|
+
# @param[String] :user_id
|
|
275
|
+
# @param[String] :event_name
|
|
276
|
+
# @param[Integer] :revenue_value
|
|
277
|
+
# @param[Hash] :metric_map
|
|
278
|
+
# @param[Array] :revenue_props
|
|
279
|
+
#
|
|
280
|
+
# @return[Hash] :properties
|
|
281
|
+
#
|
|
282
|
+
def get_track_goal_payload_data(settings_file, user_id, event_name, revenue_value, metric_map, revenue_props = [])
|
|
283
|
+
properties = get_event_base_payload(settings_file, user_id, event_name)
|
|
284
|
+
|
|
285
|
+
logger = VWO::Logger.get_instance
|
|
286
|
+
metric = {}
|
|
287
|
+
metric_map.each do |campaign_id, goal_id|
|
|
288
|
+
metric[('id_' + campaign_id.to_s).to_sym] = ['g_' + goal_id.to_s]
|
|
289
|
+
logger.log(
|
|
290
|
+
LogLevelEnum::DEBUG,
|
|
291
|
+
format(
|
|
292
|
+
LogMessageEnum::DebugMessages::IMPRESSION_FOR_EVENT_ARCH_TRACK_GOAL,
|
|
293
|
+
file: FileNameEnum::ImpressionUtil,
|
|
294
|
+
goal_identifier: event_name,
|
|
295
|
+
a: settings_file['accountId'],
|
|
296
|
+
u: user_id,
|
|
297
|
+
c: campaign_id
|
|
298
|
+
)
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
properties[:d][:event][:props][:vwoMeta] = {
|
|
303
|
+
metric: metric
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if revenue_props.length() != 0 && revenue_value
|
|
307
|
+
revenue_props.each do |revenue_prop|
|
|
308
|
+
properties[:d][:event][:props][:vwoMeta][revenue_prop.to_sym] = revenue_value
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
properties[:d][:event][:props][:isCustomEvent] = true
|
|
313
|
+
properties
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
# Builds payload to appply post segmentation on VWO campaign reports.
|
|
317
|
+
#
|
|
318
|
+
# @param[Hash] :settings_file
|
|
319
|
+
# @param[String] :user_id
|
|
320
|
+
# @param[String] :event_name
|
|
321
|
+
# @param[Hash] :custom_dimension_map
|
|
322
|
+
#
|
|
323
|
+
# @return[Hash] :properties
|
|
324
|
+
#
|
|
325
|
+
def get_push_payload_data(settings_file, user_id, event_name, custom_dimension_map = {})
|
|
326
|
+
properties = get_event_base_payload(settings_file, user_id, event_name)
|
|
327
|
+
properties[:d][:event][:props][:isCustomEvent] = true
|
|
328
|
+
|
|
329
|
+
custom_dimension_map.each do |tag_key, tag_value|
|
|
330
|
+
properties[:d][:event][:props][('$visitor'.to_sym)][:props][tag_key] = tag_value
|
|
331
|
+
properties[:d][:visitor][:props][tag_key] = tag_value
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
logger = VWO::Logger.get_instance
|
|
335
|
+
logger.log(
|
|
336
|
+
LogLevelEnum::DEBUG,
|
|
337
|
+
format(
|
|
338
|
+
LogMessageEnum::DebugMessages::IMPRESSION_FOR_EVENT_ARCH_PUSH,
|
|
339
|
+
file: FileNameEnum::ImpressionUtil,
|
|
340
|
+
a: settings_file['accountId'],
|
|
341
|
+
u: user_id,
|
|
342
|
+
property: JSON.generate(custom_dimension_map)
|
|
343
|
+
)
|
|
344
|
+
)
|
|
345
|
+
properties
|
|
346
|
+
end
|
|
167
347
|
end
|
|
168
348
|
end
|
|
169
349
|
end
|
data/lib/vwo/utils/request.rb
CHANGED
|
@@ -38,6 +38,20 @@ class VWO
|
|
|
38
38
|
response = http.post(uri, post_data.to_json, headers)
|
|
39
39
|
response
|
|
40
40
|
end
|
|
41
|
+
|
|
42
|
+
def self.event_post(url, params, post_data, user_agent_value)
|
|
43
|
+
uri = URI.parse(url)
|
|
44
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
45
|
+
http.use_ssl = true
|
|
46
|
+
uri.query = URI.encode_www_form(params)
|
|
47
|
+
headers = {
|
|
48
|
+
'User-Agent' => user_agent_value,
|
|
49
|
+
'Content-Type' =>'application/json',
|
|
50
|
+
'Accept'=>'application/json'
|
|
51
|
+
}
|
|
52
|
+
response = http.post(uri, post_data.to_json, headers)
|
|
53
|
+
response
|
|
54
|
+
end
|
|
41
55
|
end
|
|
42
56
|
end
|
|
43
57
|
end
|
data/lib/vwo.rb
CHANGED
|
@@ -370,6 +370,10 @@ class VWO
|
|
|
370
370
|
user_id
|
|
371
371
|
)
|
|
372
372
|
@batch_events_queue.enqueue(impression)
|
|
373
|
+
elsif is_event_arch_enabled
|
|
374
|
+
properties = get_events_base_properties(@settings_file, EventEnum::VWO_VARIATION_SHOWN, @usage_stats.usage_stats)
|
|
375
|
+
payload = get_track_user_payload_data(@settings_file, user_id, EventEnum::VWO_VARIATION_SHOWN, campaign['id'], variation['id'])
|
|
376
|
+
@event_dispatcher.dispatch_event_arch_post(properties, payload)
|
|
373
377
|
else
|
|
374
378
|
# Variation found, dispatch it to server
|
|
375
379
|
impression = create_impression(
|
|
@@ -592,6 +596,8 @@ class VWO
|
|
|
592
596
|
return nil
|
|
593
597
|
end
|
|
594
598
|
|
|
599
|
+
metric_map = {}
|
|
600
|
+
revenue_props = []
|
|
595
601
|
result = {}
|
|
596
602
|
campaigns.each do |campaign|
|
|
597
603
|
begin
|
|
@@ -687,6 +693,11 @@ class VWO
|
|
|
687
693
|
revenue_value
|
|
688
694
|
)
|
|
689
695
|
@batch_events_queue.enqueue(impression)
|
|
696
|
+
elsif is_event_arch_enabled
|
|
697
|
+
metric_map[campaign['id']] = goal['id']
|
|
698
|
+
if goal['type'] == GoalTypes::REVENUE && !(revenue_props.include? goal['revenueProp'])
|
|
699
|
+
revenue_props << goal['revenueProp']
|
|
700
|
+
end
|
|
690
701
|
else
|
|
691
702
|
impression = create_impression(
|
|
692
703
|
@settings_file,
|
|
@@ -737,6 +748,12 @@ class VWO
|
|
|
737
748
|
end
|
|
738
749
|
end
|
|
739
750
|
|
|
751
|
+
if is_event_arch_enabled
|
|
752
|
+
properties = get_events_base_properties(@settings_file, goal_identifier)
|
|
753
|
+
payload = get_track_goal_payload_data(@settings_file, user_id, goal_identifier, revenue_value, metric_map, revenue_props)
|
|
754
|
+
@event_dispatcher.dispatch_event_arch_post(properties, payload)
|
|
755
|
+
end
|
|
756
|
+
|
|
740
757
|
if result.length() == 0
|
|
741
758
|
return nil
|
|
742
759
|
end
|
|
@@ -861,6 +878,10 @@ class VWO
|
|
|
861
878
|
user_id
|
|
862
879
|
)
|
|
863
880
|
@batch_events_queue.enqueue(impression)
|
|
881
|
+
elsif is_event_arch_enabled
|
|
882
|
+
properties = get_events_base_properties(@settings_file, EventEnum::VWO_VARIATION_SHOWN, @usage_stats.usage_stats)
|
|
883
|
+
payload = get_track_user_payload_data(@settings_file, user_id, EventEnum::VWO_VARIATION_SHOWN, campaign['id'], variation['id'])
|
|
884
|
+
@event_dispatcher.dispatch_event_arch_post(properties, payload)
|
|
864
885
|
else
|
|
865
886
|
impression = create_impression(
|
|
866
887
|
@settings_file,
|
|
@@ -1110,12 +1131,12 @@ class VWO
|
|
|
1110
1131
|
# This API method: Makes a call to our server to store the tag_values
|
|
1111
1132
|
# 1. Validates the arguments being passed
|
|
1112
1133
|
# 2. Send a call to our server
|
|
1113
|
-
# @param[String]
|
|
1114
|
-
# @param[String] :tag_value Value of the tag
|
|
1134
|
+
# @param[String|Hash] :tag_key key name of the tag OR tagKey/tagValue pair(custom dimension map)
|
|
1135
|
+
# @param[String] :tag_value Value of the tag OR userId if TagKey is hash
|
|
1115
1136
|
# @param[String] :user_id ID of the user for which value should be stored
|
|
1116
1137
|
# @return true if call is made successfully, else false
|
|
1117
1138
|
|
|
1118
|
-
def push(tag_key, tag_value, user_id)
|
|
1139
|
+
def push(tag_key, tag_value, user_id = nil)
|
|
1119
1140
|
unless @is_instance_valid
|
|
1120
1141
|
@logger.log(
|
|
1121
1142
|
LogLevelEnum::ERROR,
|
|
@@ -1128,7 +1149,16 @@ class VWO
|
|
|
1128
1149
|
return
|
|
1129
1150
|
end
|
|
1130
1151
|
|
|
1131
|
-
|
|
1152
|
+
# Argument reshuffling.
|
|
1153
|
+
custom_dimension_map = {}
|
|
1154
|
+
if user_id.nil? || tag_key.is_a?(Hash)
|
|
1155
|
+
custom_dimension_map = convert_to_symbol_hash(tag_key)
|
|
1156
|
+
user_id = tag_value
|
|
1157
|
+
else
|
|
1158
|
+
custom_dimension_map[tag_key.to_sym] = tag_value
|
|
1159
|
+
end
|
|
1160
|
+
|
|
1161
|
+
unless (valid_string?(tag_key) || valid_hash?(tag_key)) && valid_string?(tag_value) && valid_string?(user_id)
|
|
1132
1162
|
@logger.log(
|
|
1133
1163
|
LogLevelEnum::ERROR,
|
|
1134
1164
|
format(
|
|
@@ -1140,51 +1170,61 @@ class VWO
|
|
|
1140
1170
|
return false
|
|
1141
1171
|
end
|
|
1142
1172
|
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1173
|
+
custom_dimension_map.each do |tag_key, tag_value|
|
|
1174
|
+
if tag_key.length > PushApi::TAG_KEY_LENGTH
|
|
1175
|
+
@logger.log(
|
|
1176
|
+
LogLevelEnum::ERROR,
|
|
1177
|
+
format(
|
|
1178
|
+
LogMessageEnum::ErrorMessages::TAG_KEY_LENGTH_EXCEEDED,
|
|
1179
|
+
file: FILE,
|
|
1180
|
+
user_id: user_id,
|
|
1181
|
+
tag_key: tag_key,
|
|
1182
|
+
api_name: ApiMethods::PUSH
|
|
1183
|
+
)
|
|
1152
1184
|
)
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
end
|
|
1185
|
+
return false
|
|
1186
|
+
end
|
|
1156
1187
|
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1188
|
+
if tag_value.length > PushApi::TAG_VALUE_LENGTH
|
|
1189
|
+
@logger.log(
|
|
1190
|
+
LogLevelEnum::ERROR,
|
|
1191
|
+
format(
|
|
1192
|
+
LogMessageEnum::ErrorMessages::TAG_VALUE_LENGTH_EXCEEDED,
|
|
1193
|
+
file: FILE,
|
|
1194
|
+
user_id: user_id,
|
|
1195
|
+
tag_value: tag_value,
|
|
1196
|
+
api_name: ApiMethods::PUSH
|
|
1197
|
+
)
|
|
1166
1198
|
)
|
|
1167
|
-
|
|
1168
|
-
|
|
1199
|
+
return false
|
|
1200
|
+
end
|
|
1169
1201
|
end
|
|
1170
1202
|
|
|
1171
1203
|
if defined?(@batch_events)
|
|
1172
|
-
|
|
1173
|
-
|
|
1204
|
+
custom_dimension_map.each do |tag_key, tag_value|
|
|
1205
|
+
impression = get_batch_event_url_params(@settings_file, tag_key, tag_value, user_id)
|
|
1206
|
+
@batch_events_queue.enqueue(impression)
|
|
1207
|
+
end
|
|
1208
|
+
elsif is_event_arch_enabled
|
|
1209
|
+
properties = get_events_base_properties(@settings_file, EventEnum::VWO_SYNC_VISITOR_PROP)
|
|
1210
|
+
payload = get_push_payload_data(@settings_file, user_id, EventEnum::VWO_SYNC_VISITOR_PROP, custom_dimension_map)
|
|
1211
|
+
@event_dispatcher.dispatch_event_arch_post(properties, payload)
|
|
1174
1212
|
else
|
|
1175
|
-
|
|
1176
|
-
|
|
1213
|
+
custom_dimension_map.each do |tag_key, tag_value|
|
|
1214
|
+
impression = get_url_params(@settings_file, tag_key, tag_value, user_id, @sdk_key)
|
|
1215
|
+
@event_dispatcher.dispatch(impression)
|
|
1177
1216
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1217
|
+
@logger.log(
|
|
1218
|
+
LogLevelEnum::INFO,
|
|
1219
|
+
format(
|
|
1220
|
+
LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_PUSH_API,
|
|
1221
|
+
file: FILE,
|
|
1222
|
+
u: impression['u'],
|
|
1223
|
+
account_id: impression['account_id'],
|
|
1224
|
+
tags: impression['tags']
|
|
1225
|
+
)
|
|
1186
1226
|
)
|
|
1187
|
-
|
|
1227
|
+
end
|
|
1188
1228
|
end
|
|
1189
1229
|
true
|
|
1190
1230
|
rescue StandardError => e
|
|
@@ -1253,4 +1293,8 @@ class VWO
|
|
|
1253
1293
|
end
|
|
1254
1294
|
goal_type_to_track
|
|
1255
1295
|
end
|
|
1296
|
+
|
|
1297
|
+
def is_event_arch_enabled
|
|
1298
|
+
return @settings_file.key?('isEventArchEnabled') && @settings_file['isEventArchEnabled']
|
|
1299
|
+
end
|
|
1256
1300
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vwo-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.25.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-12-
|
|
11
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: codecov
|