Class: Kameleoon::Managers::Tracking::TrackingManager

Inherits:
Object
  • Object
show all
Defined in:
lib/kameleoon/managers/tracking/tracking_manager.rb

Constant Summary collapse

LINES_DELIMETER =
"\n"
REQUEST_SIZE_LIMIT =

2.5 * 1024^2 characters

2560 * 1024

Instance Method Summary collapse

Constructor Details

#initialize(data_manager, network_manager, visitor_manager, track_interval_seconds, scheduler) ⇒ TrackingManager

Returns a new instance of TrackingManager.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kameleoon/managers/tracking/tracking_manager.rb', line 15

def initialize(
  data_manager, network_manager, visitor_manager, track_interval_seconds, scheduler
)
  Logging::KameleoonLogger.debug(
    'CALL: TrackingManager.new(data_manager, network_manager. visitor_manager, ' \
      'track_interval_seconds: %s, scheduler)', track_interval_seconds
  )
  @tracking_visitors = LockVisitorTrackingRegistry.new(visitor_manager)
  @data_manager = data_manager
  @network_manager = network_manager
  @visitor_manager = visitor_manager
  @track_all_job = scheduler.schedule_every(track_interval_seconds, method(:track_all)) unless scheduler.nil?
  Logging::KameleoonLogger.debug(
    'RETURN: TrackingManager.new(data_manager, network_manager. visitor_manager, ' \
      'track_interval_seconds: %s, scheduler)', track_interval_seconds
  )
end

Instance Method Details

#add_visitor_code(visitor_code) ⇒ Object



40
41
42
43
44
# File 'lib/kameleoon/managers/tracking/tracking_manager.rb', line 40

def add_visitor_code(visitor_code)
  Logging::KameleoonLogger.debug("CALL: TrackingManager.add_visitor_code(visitor_code: '%s')", visitor_code)
  @tracking_visitors.add(visitor_code)
  Logging::KameleoonLogger.debug("RETURN: TrackingManager.add_visitor_code(visitor_code: '%s')", visitor_code)
end

#stopObject



33
34
35
36
37
38
# File 'lib/kameleoon/managers/tracking/tracking_manager.rb', line 33

def stop
  Logging::KameleoonLogger.debug('CALL: TrackingManager.stop')
  @track_all_job&.unschedule
  @track_all_job = nil
  Logging::KameleoonLogger.debug('RETURN: TrackingManager.stop')
end

#track_allObject



46
47
48
49
50
# File 'lib/kameleoon/managers/tracking/tracking_manager.rb', line 46

def track_all
  Logging::KameleoonLogger.debug('CALL: TrackingManager.track_all')
  track(@tracking_visitors.extract)
  Logging::KameleoonLogger.debug('RETURN: TrackingManager.track_all')
end

#track_visitor(visitor_code) ⇒ Object



52
53
54
55
56
# File 'lib/kameleoon/managers/tracking/tracking_manager.rb', line 52

def track_visitor(visitor_code)
  Logging::KameleoonLogger.debug("CALL: TrackingManager.track_visitor(visitor_code: '%s')", visitor_code)
  track([visitor_code])
  Logging::KameleoonLogger.debug("RETURN: TrackingManager.track_visitor(visitor_code: '%s')", visitor_code)
end