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: {})


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

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:



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

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:



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

def build_pageview(options = {}); end

#client_idString

The unique client id

Returns:

  • (String)


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

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



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

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



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

def exception(options = {}); end

#hit_defaultsHash

hit defaults for our noop

Returns:

  • (Hash)


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

def hit_defaults
  {}
end

#idString?

The tracker id for GA

Returns:

  • (String, nil)


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

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



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

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



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

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



208
209
210
# File 'lib/staccato/tracker.rb', line 208

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



219
220
# File 'lib/staccato/tracker.rb', line 219

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



212
213
# File 'lib/staccato/tracker.rb', line 212

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



215
216
# File 'lib/staccato/tracker.rb', line 215

def transaction_item(options = {})
end