Class: Kameleoon::DataManager::VisitorData
- Inherits:
-
Object
- Object
- Kameleoon::DataManager::VisitorData
- Defined in:
- lib/kameleoon/data/manager/visitor.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#cookie ⇒ Object
Returns the value of attribute cookie.
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#forced_variations ⇒ Object
Returns the value of attribute forced_variations.
-
#geolocation ⇒ Object
readonly
Returns the value of attribute geolocation.
-
#kcs_heat ⇒ Object
Returns the value of attribute kcs_heat.
-
#last_activity_time ⇒ Object
Returns the value of attribute last_activity_time.
-
#legal_consent ⇒ Object
Returns the value of attribute legal_consent.
-
#mapping_identifier ⇒ Object
Returns the value of attribute mapping_identifier.
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
#operating_system ⇒ Object
readonly
Returns the value of attribute operating_system.
-
#simulated_variations ⇒ Object
Returns the value of attribute simulated_variations.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#visitor_visits ⇒ Object
Returns the value of attribute visitor_visits.
Instance Method Summary collapse
- #add_conversion(conversion) ⇒ Object
- #add_custom_data(custom_data, overwrite) ⇒ Object
- #add_forced_experiment_variation(forced_variation) ⇒ Object
- #add_forced_feature_variation(forced_variation) ⇒ Object
- #add_page_view(page_view) ⇒ Object
- #add_page_view_visit(page_view_visit) ⇒ Object
- #add_variation(variation, overwrite) ⇒ Object
- #conversions ⇒ Object
- #count_sendable_data ⇒ Object
- #custom_data ⇒ Object
- #enumerate_sendable_data(&blk) ⇒ Object
- #get_from_map(map, key) ⇒ Object
-
#initialize ⇒ VisitorData
constructor
A new instance of VisitorData.
- #page_view_visits ⇒ Object
- #remove_from_map(map, key) ⇒ Object
- #set_browser(browser, overwrite) ⇒ Object
- #set_device(device, overwrite) ⇒ Object
- #set_geolocation(geolocation, overwrite) ⇒ Object
- #set_operating_system(operating_system, overwrite) ⇒ Object
- #variations ⇒ Object
Constructor Details
#initialize ⇒ VisitorData
Returns a new instance of VisitorData.
273 274 275 276 277 278 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 273 def initialize Logging::KameleoonLogger.debug('CALL: VisitorData.new') @mutex = Concurrent::ReadWriteLock.new = false Logging::KameleoonLogger.debug('RETURN: VisitorData.new') end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
269 270 271 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 269 def browser @browser end |
#cookie ⇒ Object
Returns the value of attribute cookie.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def end |
#device ⇒ Object (readonly)
Returns the value of attribute device.
269 270 271 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 269 def device @device end |
#forced_variations ⇒ Object
Returns the value of attribute forced_variations.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def forced_variations @forced_variations end |
#geolocation ⇒ Object (readonly)
Returns the value of attribute geolocation.
269 270 271 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 269 def geolocation @geolocation end |
#kcs_heat ⇒ Object
Returns the value of attribute kcs_heat.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def kcs_heat @kcs_heat end |
#last_activity_time ⇒ Object
Returns the value of attribute last_activity_time.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def last_activity_time @last_activity_time end |
#legal_consent ⇒ Object
Returns the value of attribute legal_consent.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def end |
#mapping_identifier ⇒ Object
Returns the value of attribute mapping_identifier.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def mapping_identifier @mapping_identifier end |
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
269 270 271 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 269 def mutex @mutex end |
#operating_system ⇒ Object (readonly)
Returns the value of attribute operating_system.
269 270 271 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 269 def end |
#simulated_variations ⇒ Object
Returns the value of attribute simulated_variations.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def simulated_variations @simulated_variations end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def user_agent @user_agent end |
#visitor_visits ⇒ Object
Returns the value of attribute visitor_visits.
270 271 272 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 270 def visitor_visits @visitor_visits end |
Instance Method Details
#add_conversion(conversion) ⇒ Object
388 389 390 391 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 388 def add_conversion(conversion) @conversions ||= [] @conversions.push(conversion) end |
#add_custom_data(custom_data, overwrite) ⇒ Object
357 358 359 360 361 362 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 357 def add_custom_data(custom_data, overwrite) @custom_data_map ||= {} if overwrite || !@custom_data_map.include?(custom_data.id) @custom_data_map[custom_data.id] = custom_data end end |
#add_forced_experiment_variation(forced_variation) ⇒ Object
406 407 408 409 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 406 def add_forced_experiment_variation(forced_variation) @forced_variations ||= {} @forced_variations[forced_variation.rule.experiment.id] = forced_variation end |
#add_forced_feature_variation(forced_variation) ⇒ Object
401 402 403 404 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 401 def add_forced_feature_variation(forced_variation) @simulated_variations ||= {} @simulated_variations[forced_variation.feature_key] = forced_variation end |
#add_page_view(page_view) ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 364 def add_page_view(page_view) return if page_view.url.nil? || page_view.url.empty? @page_view_visits ||= {} visit = @page_view_visits[page_view.url] if visit.nil? visit = PageViewVisit.new(page_view) else visit.overwrite(page_view) end @page_view_visits[page_view.url] = visit end |
#add_page_view_visit(page_view_visit) ⇒ Object
377 378 379 380 381 382 383 384 385 386 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 377 def add_page_view_visit(page_view_visit) @page_view_visits ||= {} visit = @page_view_visits[page_view_visit.page_view.url] if visit.nil? visit = page_view_visit @page_view_visits[page_view_visit.page_view.url] = visit else visit.merge(page_view_visit) end end |
#add_variation(variation, overwrite) ⇒ Object
346 347 348 349 350 351 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 346 def add_variation(variation, overwrite) @variations ||= {} if overwrite || !@variations.include?(variation.experiment_id) @variations[variation.experiment_id] = variation end end |
#conversions ⇒ Object
334 335 336 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 334 def conversions DataArrayStorage.new(@mutex, @conversions) end |
#count_sendable_data ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 309 def count_sendable_data Logging::KameleoonLogger.debug('CALL: Visitor.count_sendable_data') count = 0 @mutex.with_read_lock do count += 1 unless @device.nil? count += 1 unless @browser.nil? count += 1 unless @geolocation.nil? count += 1 unless .nil? count += @custom_data_map.size unless @custom_data_map.nil? count += @page_view_visits.size unless @page_view_visits.nil? count += @conversions.size unless @conversions.nil? count += @variations.size unless @variations.nil? end Logging::KameleoonLogger.debug('RETURN: VisitorData.count_sendable_data -> (count: %s)', count) count end |
#custom_data ⇒ Object
326 327 328 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 326 def custom_data DataMapStorage.new(@mutex, @custom_data_map) end |
#enumerate_sendable_data(&blk) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 296 def enumerate_sendable_data(&blk) blk.call(@device) unless @device.nil? blk.call(@browser) unless @browser.nil? blk.call() unless .nil? blk.call(@geolocation) unless @geolocation.nil? @mutex.with_read_lock do @custom_data_map&.each { |_, cd| blk.call(cd) } @page_view_visits&.each { |_, pvv| blk.call(pvv.page_view) } @conversions&.each { |c| blk.call(c) } @variations&.each { |_, av| blk.call(av) } end end |
#get_from_map(map, key) ⇒ Object
280 281 282 283 284 285 286 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 280 def get_from_map(map, key) return nil if map.nil? @mutex.with_read_lock do return map[key] end end |
#page_view_visits ⇒ Object
330 331 332 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 330 def page_view_visits DataMapStorage.new(@mutex, @page_view_visits) end |
#remove_from_map(map, key) ⇒ Object
288 289 290 291 292 293 294 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 288 def remove_from_map(map, key) return false if map.nil? @mutex.with_write_lock do return map.delete(key).nil? end end |
#set_browser(browser, overwrite) ⇒ Object
353 354 355 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 353 def set_browser(browser, overwrite) @browser = browser if overwrite || @browser.nil? end |
#set_device(device, overwrite) ⇒ Object
342 343 344 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 342 def set_device(device, overwrite) @device = device if overwrite || @device.nil? end |
#set_geolocation(geolocation, overwrite) ⇒ Object
393 394 395 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 393 def set_geolocation(geolocation, overwrite) @geolocation = geolocation if overwrite || @geolocation.nil? end |
#set_operating_system(operating_system, overwrite) ⇒ Object
397 398 399 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 397 def (, overwrite) = if overwrite || .nil? end |
#variations ⇒ Object
338 339 340 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 338 def variations DataMapStorage.new(@mutex, @variations) end |