Class: Kameleoon::Hybrid::ManagerImpl

Inherits:
Manager
  • Object
show all
Defined in:
lib/kameleoon/hybrid/manager.rb

Overview

Implementation of Cache with auto cleaning feature

Instance Method Summary collapse

Constructor Details

#initialize(expiration_time, data_manager) ⇒ ManagerImpl

Returns a new instance of ManagerImpl.



22
23
24
25
26
27
28
# File 'lib/kameleoon/hybrid/manager.rb', line 22

def initialize(expiration_time, data_manager)
  super()
  Logging::KameleoonLogger.debug('CALL: HybridManager.new(expiration_time: %s)', expiration_time)
  @expiration_time = expiration_time
  @data_manager = data_manager
  Logging::KameleoonLogger.debug('RETURN: HybridManager.new(expiration_time: %s)', expiration_time)
end

Instance Method Details

#get_engine_tracking_code(visitor_variations) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/kameleoon/hybrid/manager.rb', line 30

def get_engine_tracking_code(visitor_variations)
  Logging::KameleoonLogger.debug('CALL: HybridManager.get_engine_tracking_code(visitor_variations: %s)',
                                 visitor_variations)
  tracking_code = [TC_INIT]
  unless visitor_variations.nil?
    expired_time = (Time.now - @expiration_time).to_i
    visitor_variations.enumerate do |v|
      if v.assignment_time > expired_time
        tracking_only = !@data_manager.data_file.experiment_js_css_variable?(v.experiment_id)
        v_code = format(TC_ASSIGN_VARIATION_TRIGGER_FORMAT, v.experiment_id, v.variation_id, v.experiment_id,
                        tracking_only)
        tracking_code.push(v_code)
      end
    end
  end
  tracking_code = tracking_code.join
  Logging::KameleoonLogger.debug(
    "RETURN: HybridManager.get_engine_tracking_code(visitor_variations: %s) -> (tracking_code: '%s')",
    visitor_variations, tracking_code
  )
  tracking_code
end