Class: Kameleoon::Managers::RemoteData::RemoteVisitorData
- Inherits:
-
Object
- Object
- Kameleoon::Managers::RemoteData::RemoteVisitorData
- Defined in:
- lib/kameleoon/managers/remote_data/remote_visitor_data.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#conversions ⇒ Object
readonly
Returns the value of attribute conversions.
-
#custom_data_dict ⇒ Object
readonly
Returns the value of attribute custom_data_dict.
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#experiments ⇒ Object
readonly
Returns the value of attribute experiments.
-
#geolocation ⇒ Object
readonly
Returns the value of attribute geolocation.
-
#kcs_heat ⇒ Object
readonly
Returns the value of attribute kcs_heat.
-
#operating_system ⇒ Object
readonly
Returns the value of attribute operating_system.
-
#page_view_visits ⇒ Object
readonly
Returns the value of attribute page_view_visits.
-
#previous_visitor_visits ⇒ Object
readonly
Returns the value of attribute previous_visitor_visits.
-
#visitor_code ⇒ Object
readonly
Returns the value of attribute visitor_code.
Instance Method Summary collapse
- #collect_data_to_add ⇒ Object
- #collect_data_to_return ⇒ Object
-
#initialize(hash) ⇒ RemoteVisitorData
constructor
A new instance of RemoteVisitorData.
- #mark_data_as_sent(custom_data_info) ⇒ Object
Constructor Details
#initialize(hash) ⇒ RemoteVisitorData
Returns a new instance of RemoteVisitorData.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 21 def initialize(hash) current_visit = hash['currentVisit'] parse_visit(current_visit) unless current_visit.nil? previous_visits = hash['previousVisits'] previous_visits = [] if previous_visits.nil? if previous_visits.size.positive? times_started = [] previous_visits.each do |visit| times_started.push(visit['timeStarted']) parse_visit(visit) end @previous_visitor_visits = VisitorVisits.new(times_started) end @kcs_heat = parse_kcs_heat(hash['kcs']) end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def browser @browser end |
#conversions ⇒ Object (readonly)
Returns the value of attribute conversions.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def conversions @conversions end |
#custom_data_dict ⇒ Object (readonly)
Returns the value of attribute custom_data_dict.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def custom_data_dict @custom_data_dict end |
#device ⇒ Object (readonly)
Returns the value of attribute device.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def device @device end |
#experiments ⇒ Object (readonly)
Returns the value of attribute experiments.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def experiments @experiments end |
#geolocation ⇒ Object (readonly)
Returns the value of attribute geolocation.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def geolocation @geolocation end |
#kcs_heat ⇒ Object (readonly)
Returns the value of attribute kcs_heat.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def kcs_heat @kcs_heat end |
#operating_system ⇒ Object (readonly)
Returns the value of attribute operating_system.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def @operating_system end |
#page_view_visits ⇒ Object (readonly)
Returns the value of attribute page_view_visits.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def page_view_visits @page_view_visits end |
#previous_visitor_visits ⇒ Object (readonly)
Returns the value of attribute previous_visitor_visits.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def previous_visitor_visits @previous_visitor_visits end |
#visitor_code ⇒ Object (readonly)
Returns the value of attribute visitor_code.
18 19 20 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 18 def visitor_code @visitor_code end |
Instance Method Details
#collect_data_to_add ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 38 def collect_data_to_add data_to_add = [] data_to_add.concat(@custom_data_dict.values) unless @custom_data_dict.nil? data_to_add.push(@previous_visitor_visits) unless @previous_visitor_visits.nil? data_to_add.push(@kcs_heat) unless @kcs_heat.nil? data_to_add.concat(@page_view_visits.values) unless @page_view_visits.nil? data_to_add.concat(@experiments.values) unless @experiments.nil? data_to_add.concat(conversions_single_objects) end |
#collect_data_to_return ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 48 def collect_data_to_return data_to_return = [] data_to_return.concat(@custom_data_dict.values) unless @custom_data_dict.nil? @page_view_visits&.each_value do |visit| data_to_return.push(visit.page_view) end data_to_return.concat(conversions_single_objects) end |
#mark_data_as_sent(custom_data_info) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 57 def mark_data_as_sent(custom_data_info) @custom_data_dict&.each_value do |data| data.mark_as_sent unless custom_data_info.visitor_scope?(data.id) end @experiments&.each_value(&:mark_as_sent) @page_view_visits&.each_value do |visit| visit.page_view.mark_as_sent end conversions_single_objects.each(&:mark_as_sent) end |