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.
-
#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.
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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 19 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 end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def browser @browser end |
#conversions ⇒ Object (readonly)
Returns the value of attribute conversions.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def conversions @conversions end |
#custom_data_dict ⇒ Object (readonly)
Returns the value of attribute custom_data_dict.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def custom_data_dict @custom_data_dict end |
#device ⇒ Object (readonly)
Returns the value of attribute device.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def device @device end |
#experiments ⇒ Object (readonly)
Returns the value of attribute experiments.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def experiments @experiments end |
#geolocation ⇒ Object (readonly)
Returns the value of attribute geolocation.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def geolocation @geolocation end |
#operating_system ⇒ Object (readonly)
Returns the value of attribute operating_system.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def @operating_system end |
#page_view_visits ⇒ Object (readonly)
Returns the value of attribute page_view_visits.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def page_view_visits @page_view_visits end |
#previous_visitor_visits ⇒ Object (readonly)
Returns the value of attribute previous_visitor_visits.
17 18 19 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 17 def previous_visitor_visits @previous_visitor_visits end |
Instance Method Details
#collect_data_to_add ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 35 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.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
44 45 46 47 48 49 50 51 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 44 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
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/kameleoon/managers/remote_data/remote_visitor_data.rb', line 53 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 |