Class: Kameleoon::DataManager::Visitor
- Inherits:
-
Object
- Object
- Kameleoon::DataManager::Visitor
- Defined in:
- lib/kameleoon/data/manager/visitor.rb
Overview
Visitor is a container of all data assigned to a visitor. It is thread-safe
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#is_unique_identifier ⇒ Object
readonly
Returns the value of attribute is_unique_identifier.
Instance Method Summary collapse
- #add_data(*args, overwrite: true) ⇒ Object
- #assign_variation(variation) ⇒ Object
- #browser ⇒ Object
- #clone ⇒ Object
- #conversions ⇒ Object
- #cookie ⇒ Object
- #count_sendable_data ⇒ Object
- #custom_data ⇒ Object
- #device ⇒ Object
- #enumerate_sendable_data(&blk) ⇒ Object
- #geolocation ⇒ Object
-
#initialize(source = nil) ⇒ Visitor
constructor
A new instance of Visitor.
- #kcs_heat ⇒ Object
- #last_activity_time ⇒ Object
- #legal_consent ⇒ Object
- #legal_consent=(value) ⇒ Object
- #mapping_identifier ⇒ Object
- #mapping_identifier=(value) ⇒ Object
- #operating_system ⇒ Object
- #page_view_visits ⇒ Object
- #to_s ⇒ Object
- #update_last_activity_time ⇒ Object
- #user_agent ⇒ Object
- #variations ⇒ Object
- #visitor_visits ⇒ Object
Constructor Details
#initialize(source = nil) ⇒ Visitor
Returns a new instance of Visitor.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 30 def initialize(source = nil) if source.nil? @data = VisitorData.new @is_unique_identifier = false else @data = source.data @is_unique_identifier = source.is_unique_identifier end update_last_activity_time end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
24 25 26 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 24 def data @data end |
#is_unique_identifier ⇒ Object (readonly)
Returns the value of attribute is_unique_identifier.
24 25 26 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 24 def is_unique_identifier @is_unique_identifier end |
Instance Method Details
#add_data(*args, overwrite: true) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 166 def add_data(*args, overwrite: true) Logging::KameleoonLogger.debug('CALL: Visitor.add_data(args: %s, overwrite: %s)', args, overwrite) @data.mutex.with_write_lock do args.each do |data| case data when Kameleoon::UserAgent @data.user_agent = data.value when Kameleoon::DataManager::AssignedVariation @data.add_variation(data, overwrite) when Kameleoon::Device @data.set_device(data, overwrite) when Kameleoon::Browser @data.set_browser(data, overwrite) when Kameleoon::CustomData @data.add_custom_data(data, overwrite) when Kameleoon::PageView @data.add_page_view(data) when Kameleoon::DataManager::PageViewVisit @data.add_page_view_visit(data) when Kameleoon::Conversion @data.add_conversion(data) when Kameleoon::Cookie @data. = data when Kameleoon::OperatingSystem @data.(data, overwrite) when Kameleoon::Geolocation @data.set_geolocation(data, overwrite) when Kameleoon::KcsHeat @data.kcs_heat = data when Kameleoon::VisitorVisits @data.visitor_visits = data when Kameleoon::UniqueIdentifier @is_unique_identifier = data.value else Logging::KameleoonLogger.warning("Data has unsupported type '%s'", data.class) end end end Logging::KameleoonLogger.debug('RETURN: Visitor.add_data(args: %s, overwrite: %s)', args, overwrite) end |
#assign_variation(variation) ⇒ Object
207 208 209 210 211 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 207 def assign_variation(variation) @data.mutex.with_write_lock do @data.add_variation(variation, true) end end |
#browser ⇒ Object
74 75 76 77 78 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 74 def browser browser = @data.browser Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.browser -> (browser: %s)', browser) browser end |
#clone ⇒ Object
213 214 215 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 213 def clone Visitor.new(self) end |
#conversions ⇒ Object
154 155 156 157 158 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 154 def conversions conversions = @data.conversions Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.conversions -> (conversions: %s)', conversions) conversions end |
#cookie ⇒ Object
95 96 97 98 99 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 95 def = @data. Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.cookie -> (cookie: %s)', ) end |
#count_sendable_data ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 53 def count_sendable_data count_sendable_data = @data.count_sendable_data Logging::KameleoonLogger.debug( 'CALL/RETURN: Visitor.count_sendable_data -> (count_sendable_data: %s)', count_sendable_data ) count_sendable_data end |
#custom_data ⇒ Object
141 142 143 144 145 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 141 def custom_data custom_data = @data.custom_data Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.custom_data -> (custom_data: %s)', custom_data) custom_data end |
#device ⇒ Object
68 69 70 71 72 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 68 def device device = @data.device Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.device -> (device: %s)', device) device end |
#enumerate_sendable_data(&blk) ⇒ Object
49 50 51 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 49 def enumerate_sendable_data(&blk) @data.enumerate_sendable_data(&blk) end |
#geolocation ⇒ Object
80 81 82 83 84 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 80 def geolocation geolocation = @data.geolocation Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.geolocation -> (geolocation: %s)', geolocation) geolocation end |
#kcs_heat ⇒ Object
101 102 103 104 105 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 101 def kcs_heat kcs_heat = @data.kcs_heat Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.kcs_heat -> (kcs_heat: %s)', kcs_heat) kcs_heat end |
#last_activity_time ⇒ Object
41 42 43 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 41 def last_activity_time @data.last_activity_time end |
#legal_consent ⇒ Object
113 114 115 116 117 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 113 def = @data. Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.legal_consent -> (legal_consent: %s)', ) end |
#legal_consent=(value) ⇒ Object
119 120 121 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 119 def (value) @data. = value end |
#mapping_identifier ⇒ Object
123 124 125 126 127 128 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 123 def mapping_identifier mapping_identifier = @data.mapping_identifier Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.mapping_identifier -> (mapping_identifier: %s)', mapping_identifier) mapping_identifier end |
#mapping_identifier=(value) ⇒ Object
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 130 def mapping_identifier=(value) return unless @data.mapping_identifier.nil? @data.mutex.with_write_lock do if @data.mapping_identifier.nil? @data.mapping_identifier = value Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.mapping_identifier = %s', value) end end end |
#operating_system ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 86 def = @data. Logging::KameleoonLogger.debug( 'CALL/RETURN: Visitor.operating_system -> (operating_system: %s)', ) end |
#page_view_visits ⇒ Object
147 148 149 150 151 152 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 147 def page_view_visits page_view_visits = @data.page_view_visits Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.page_view_visits -> (page_view_visits: %s)', page_view_visits) page_view_visits end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 26 def to_s 'Visitor{}' end |
#update_last_activity_time ⇒ Object
45 46 47 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 45 def update_last_activity_time @data.last_activity_time = Time.new.to_i end |
#user_agent ⇒ Object
62 63 64 65 66 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 62 def user_agent user_agent = @data.user_agent Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.user_agent -> (user_agent: %s)', user_agent) user_agent end |
#variations ⇒ Object
160 161 162 163 164 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 160 def variations variations = @data.variations Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.variations -> (variations: %s)', variations) variations end |
#visitor_visits ⇒ Object
107 108 109 110 111 |
# File 'lib/kameleoon/data/manager/visitor.rb', line 107 def visitor_visits visitor_visits = @data.visitor_visits Logging::KameleoonLogger.debug('CALL/RETURN: Visitor.visitor_visits -> (visitor_visits: %s)', visitor_visits) visitor_visits end |