Class: Kameleoon::Browser

Inherits:
DuplicationUnsafeData show all
Defined in:
lib/kameleoon/data/browser.rb

Overview

Represents browser data for tracking calls

Instance Attribute Summary collapse

Attributes inherited from Data

#instance

Instance Method Summary collapse

Methods inherited from Data

#mark_as_sent, #mark_as_transmitting, #mark_as_unsent, #sent, #transmitting, #unsent

Constructor Details

#initialize(browser_type, version = Float::NAN) ⇒ Browser

Returns a new instance of Browser.

Parameters:

  • browser_type (BrowserType)

    Browser type, can be: CHROME, INTERNET_EXPLORER, FIREFOX, SAFARI, OPERA, OTHER

  • version (float) (defaults to: Float::NAN)

    Version of browser



46
47
48
49
50
# File 'lib/kameleoon/data/browser.rb', line 46

def initialize(browser_type, version = Float::NAN)
  super(DataType::BROWSER)
  @type = browser_type
  @version = version
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



38
39
40
# File 'lib/kameleoon/data/browser.rb', line 38

def type
  @type
end

#versionObject (readonly)

Returns the value of attribute version.



38
39
40
# File 'lib/kameleoon/data/browser.rb', line 38

def version
  @version
end

Instance Method Details

#obtain_full_post_text_lineObject



52
53
54
55
56
57
58
59
60
# File 'lib/kameleoon/data/browser.rb', line 52

def obtain_full_post_text_line
  params = {
    eventType: 'staticData',
    browserIndex: @type,
    nonce: nonce
  }
  params[:browserVersion] = @version if @version.is_a?(Integer) || (@version.is_a?(Float) && !@version.nan?)
  Kameleoon::Network::UriHelper.encode_query(params)
end

#to_sObject



40
41
42
# File 'lib/kameleoon/data/browser.rb', line 40

def to_s
  "Browser{type:#{@type},version:#{@version}}"
end