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 Attribute Summary collapse

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


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

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

Instance Attribute Details

#hit_defaultsObject

Returns the value of attribute hit_defaults.



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

def hit_defaults
  @hit_defaults
end

Instance Method Details

#adapter=Object



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

def adapter=(*)
  []
end

#add_adapterObject



221
222
223
# File 'lib/staccato/tracker.rb', line 221

def add_adapter(*)
  []
end

#build_event(options = {}) ⇒ Event

Build an event

Parameters:

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

    options include:

    • category (optional)

    • action (optional)

    • label (optional)

    • value (optional)

Returns:



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

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:



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

def build_pageview(options = {}); end

#client_idString

The unique client id

Returns:

  • (String)


231
232
233
# File 'lib/staccato/tracker.rb', line 231

def client_id
  nil
end

#default_uriObject



262
263
264
# File 'lib/staccato/tracker.rb', line 262

def default_uri
  Staccato.ga_collection_uri
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



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

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



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

def exception(options = {}); end

#idString?

The tracker id for GA

Returns:

  • (String, nil)


226
227
228
# File 'lib/staccato/tracker.rb', line 226

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



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

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



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

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



248
249
250
# File 'lib/staccato/tracker.rb', line 248

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



259
260
# File 'lib/staccato/tracker.rb', line 259

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



252
253
# File 'lib/staccato/tracker.rb', line 252

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



255
256
# File 'lib/staccato/tracker.rb', line 255

def transaction_item(options = {})
end