Class: Staccato::NoopTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/staccato/tracker.rb

Overview

A tracker which does no tracking

Useful in testing

Instance Method Summary collapse

Constructor Details

#initialize(id = nil, client_id = nil, hit_defaults = {}) ⇒ NoopTracker

sets up a new tracker

Parameters:

  • id (String) (defaults to: nil)

    the GA tracker id

  • client_id (String, nil) (defaults to: nil)

    unique value to track user sessions

  • hit_defaults (Hash) (defaults to: {})


150
# File 'lib/staccato/tracker.rb', line 150

def initialize(id = nil, client_id = nil, hit_defaults = {}); end

Instance Method Details

#build_event(options = {}) ⇒ Event

Build an event

Parameters:

  • options (Hash) (defaults to: {})

    options include:

    • category (optional)

    • action (optional)

    • label (optional)

    • value (optional)

Returns:



173
# File 'lib/staccato/tracker.rb', line 173

def build_event(options = {}); end

#build_pageview(options = {}) ⇒ Pageview

Build a pageview

Parameters:

  • options (Hash) (defaults to: {})

    options include:

    • path (optional) the path of the current page view

    • hostname (optional) the hostname of the current page view

    • title (optional) the page title

Returns:



169
# File 'lib/staccato/tracker.rb', line 169

def build_pageview(options = {}); end

#client_idString

The unique client id

Returns:

  • (String)


164
165
166
# File 'lib/staccato/tracker.rb', line 164

def client_id
  nil
end

#event(options = {}) ⇒ <Net::HTTPOK] the GA `/collect` endpoint always returns a 200

Track an event

Parameters:

  • options (Hash) (defaults to: {})

    options include:

    • category (optional)

    • action (optional)

    • label (optional)

    • value (optional)

Returns:

  • (<Net::HTTPOK] the GA `/collect` endpoint always returns a 200)

    <Net::HTTPOK] the GA ‘/collect` endpoint always returns a 200



175
# File 'lib/staccato/tracker.rb', line 175

def event(options = {}); end

#exception(options = {}) ⇒ <Net::HTTPOK] the GA `/collect` endpoint always returns a 200

Track an exception

Parameters:

  • options (Hash) (defaults to: {})

    options include:

    • description (optional) often the class of exception, e.g., RuntimeException

    • fatal (optional) was the exception fatal? boolean, defaults to false

Returns:

  • (<Net::HTTPOK] the GA `/collect` endpoint always returns a 200)

    <Net::HTTPOK] the GA ‘/collect` endpoint always returns a 200



179
# File 'lib/staccato/tracker.rb', line 179

def exception(options = {}); end

#hit_defaultsHash

hit defaults for our noop

Returns:

  • (Hash)


154
155
156
# File 'lib/staccato/tracker.rb', line 154

def hit_defaults
  {}
end

#idString?

The tracker id for GA

Returns:

  • (String, nil)


159
160
161
# File 'lib/staccato/tracker.rb', line 159

def id
  nil
end

#pageview(options = {}) ⇒ <Net::HTTPOK] the GA `/collect` endpoint always returns a 200

Track a pageview

Parameters:

  • options (Hash) (defaults to: {})

    options include:

    • path (optional) the path of the current page view

    • hostname (optional) the hostname of the current page view

    • title (optional) the page title

Returns:

  • (<Net::HTTPOK] the GA `/collect` endpoint always returns a 200)

    <Net::HTTPOK] the GA ‘/collect` endpoint always returns a 200



171
# File 'lib/staccato/tracker.rb', line 171

def pageview(options = {}); end

#social(options = {}) ⇒ <Net::HTTPOK] the GA `/collect` endpoint always returns a 200

Track a social event such as a Facebook Like or Twitter Share

Parameters:

  • options (Hash) (defaults to: {})

    options include:

    • action (required) the action taken, e.g., ‘like’

    • network (required) the network used, e.g., ‘facebook’

    • target (required) the target page path, e.g., ‘/blog/something-awesome’

Returns:

  • (<Net::HTTPOK] the GA `/collect` endpoint always returns a 200)

    <Net::HTTPOK] the GA ‘/collect` endpoint always returns a 200



177
# File 'lib/staccato/tracker.rb', line 177

def social(options = {}); end

#timing(options = {}, &block) ⇒ <Net::HTTPOK] the GA `/collect` endpoint always returns a 200

Track timing

Parameters:

  • options (Hash) (defaults to: {})

    options include:

    • category (optional) e.g., ‘runtime’

    • variable (optional) e.g., ‘database’

    • label (optional) e.g., ‘query’

    • time (recommended) the integer time in milliseconds

    • page_load_time (optional)

    • dns_time (optional)

    • page_download_time (optional)

    • redirect_response_time (optional)

    • tcp_connect_time (optional)

    • server_response_time (optional) most useful on the server-side

  • block (#call)

    if a block is provided, the time it takes to run will be recorded and set as the ‘time` value option, no other time values will be set.

Returns:

  • (<Net::HTTPOK] the GA `/collect` endpoint always returns a 200)

    <Net::HTTPOK] the GA ‘/collect` endpoint always returns a 200



181
182
183
# File 'lib/staccato/tracker.rb', line 181

def timing(options = {}, &block)
  yield if block_given?
end

#track(params = {}) ⇒ Net::HTTPOK

post the hit to GA collection endpoint

Returns:

  • (Net::HTTPOK)

    the GA api always returns 200 OK



192
193
# File 'lib/staccato/tracker.rb', line 192

def track(params = {})
end

#transaction(options = {}) ⇒ <Net::HTTPOK] the GA `/collect` endpoint always returns a 200

Track an ecommerce transaction

Returns:

  • (<Net::HTTPOK] the GA `/collect` endpoint always returns a 200)

    <Net::HTTPOK] the GA ‘/collect` endpoint always returns a 200



185
186
# File 'lib/staccato/tracker.rb', line 185

def transaction(options = {})
end

#transaction_item(options = {}) ⇒ <Net::HTTPOK] the GA `/collect` endpoint always returns a 200

Track an item in an ecommerce transaction

Returns:

  • (<Net::HTTPOK] the GA `/collect` endpoint always returns a 200)

    <Net::HTTPOK] the GA ‘/collect` endpoint always returns a 200



188
189
# File 'lib/staccato/tracker.rb', line 188

def transaction_item(options = {})
end