Class: PwnalyticsClient::Event
- Inherits:
-
Object
- Object
- PwnalyticsClient::Event
- Defined in:
- lib/pwnalytics_client/event.rb
Overview
Information about an event logged on a Pwnalytics server.
Instance Attribute Summary collapse
-
#browser_ua ⇒ Object
readonly
User-Agent string of the browser where the event was triggered.
-
#data ⇒ Object
readonly
User-defined data associated with the event.
-
#ip ⇒ Object
readonly
IP of the computer where the event was triggered (e.g., “127.0.0.1”).
-
#name ⇒ Object
readonly
Event name used for filtering in queries.
-
#pixels ⇒ Object
readonly
Screen metrics: screen size, window size and position.
-
#ref ⇒ Object
readonly
Referer URL for the page where the event was triggerred.
-
#site ⇒ Object
readonly
PwnalyticsClient::Site that the event occured on.
-
#time ⇒ Object
readonly
When the event was triggerred.
-
#url ⇒ Object
readonly
URL of the page where the event was triggerred.
-
#visitor ⇒ Object
readonly
UID for the visitor that triggered the event.
Class Method Summary collapse
-
.parse_url(json_data) ⇒ Object
Parses an URL out of a Pwnalytics server response.
Instance Method Summary collapse
-
#initialize(site, json_data) ⇒ Event
constructor
New wrapper for a site on a Pwnalytics server.
Constructor Details
#initialize(site, json_data) ⇒ Event
New wrapper for a site on a Pwnalytics server.
This is called automatically by PwnalyticsClient in #sites and #site.
Args:
site:: the PwnalyticsClient::Site that the event occured on
json_data:: a Hash containing parsed JSON data representing the event
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pwnalytics_client/event.rb', line 15 def initialize(site, json_data) @site = site @name = json_data['name'] @url = self.class.parse_url json_data['page'] @ref = self.class.parse_url json_data['referrer'] @visitor = json_data['visitor'] && json_data['visitor']['uid'] if json_data['browser'] && json_data['browser']['time'] @time = Time.at(json_data['browser']['time'] / 1000.0) else @time = nil end @ip = json_data['ip'] @browser_ua = json_data['browser'] && json_data['browser']['ua'] @pixels = Hashie::Mash.new json_data['pixels'] @data = Hashie::Mash.new json_data['data'] end |
Instance Attribute Details
#browser_ua ⇒ Object (readonly)
User-Agent string of the browser where the event was triggered.
49 50 51 |
# File 'lib/pwnalytics_client/event.rb', line 49 def browser_ua @browser_ua end |
#data ⇒ Object (readonly)
User-defined data associated with the event.
53 54 55 |
# File 'lib/pwnalytics_client/event.rb', line 53 def data @data end |
#ip ⇒ Object (readonly)
IP of the computer where the event was triggered (e.g., “127.0.0.1”).
47 48 49 |
# File 'lib/pwnalytics_client/event.rb', line 47 def ip @ip end |
#name ⇒ Object (readonly)
Event name used for filtering in queries.
37 38 39 |
# File 'lib/pwnalytics_client/event.rb', line 37 def name @name end |
#pixels ⇒ Object (readonly)
Screen metrics: screen size, window size and position.
51 52 53 |
# File 'lib/pwnalytics_client/event.rb', line 51 def pixels @pixels end |
#ref ⇒ Object (readonly)
Referer URL for the page where the event was triggerred.
41 42 43 |
# File 'lib/pwnalytics_client/event.rb', line 41 def ref @ref end |
#site ⇒ Object (readonly)
PwnalyticsClient::Site that the event occured on.
34 35 36 |
# File 'lib/pwnalytics_client/event.rb', line 34 def site @site end |
#time ⇒ Object (readonly)
When the event was triggerred.
45 46 47 |
# File 'lib/pwnalytics_client/event.rb', line 45 def time @time end |
#url ⇒ Object (readonly)
URL of the page where the event was triggerred.
39 40 41 |
# File 'lib/pwnalytics_client/event.rb', line 39 def url @url end |
#visitor ⇒ Object (readonly)
UID for the visitor that triggered the event.
43 44 45 |
# File 'lib/pwnalytics_client/event.rb', line 43 def visitor @visitor end |
Class Method Details
.parse_url(json_data) ⇒ Object
Parses an URL out of a Pwnalytics server response.
56 57 58 59 60 61 62 |
# File 'lib/pwnalytics_client/event.rb', line 56 def self.parse_url(json_data) if json_data && json_data['url'] && json_data['url'] != 'null' URI.parse json_data['url'] else nil end end |