Module: Staccato

Defined in:
lib/staccato.rb,
lib/staccato/hit.rb,
lib/staccato/event.rb,
lib/staccato/social.rb,
lib/staccato/timing.rb,
lib/staccato/tracker.rb,
lib/staccato/version.rb,
lib/staccato/pageview.rb,
lib/staccato/exception.rb,
lib/staccato/option_set.rb,
lib/staccato/transaction.rb,
lib/staccato/transaction_item.rb

Overview

The ‘Staccato` module namespace

Author:

  • Tony Pitale

Defined Under Namespace

Modules: Hit Classes: Event, Exception, NoopTracker, OptionSet, Pageview, Social, Timing, Tracker, Transaction, TransactionItem

Constant Summary collapse

VERSION =

The current Staccato VERSION

"0.1.1"

Class Method Summary collapse

Class Method Details

.build_client_idString

Build a new random ‘client_id`

Returns:

  • (String)

    a random value suitable for use as a ‘client_id`



31
32
33
# File 'lib/staccato.rb', line 31

def self.build_client_id
  SecureRandom.uuid
end

.tracker(id, client_id = nil, hit_options = {}) ⇒ Staccato::Tracker

Build a new tracker instance

If the first argument is explicitly `nil`, a `NoopTracker` is returned
which responds to all the same `tracker` methods but does no tracking

Parameters:

  • id (String, nil)

    the id provided by google, i.e., ‘UA-XXXXXX-Y`

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

    a unique id to track the session of an individual user

Returns:



20
21
22
23
24
25
26
# File 'lib/staccato.rb', line 20

def self.tracker(id, client_id = nil, hit_options = {})
  if id.nil?
    Staccato::NoopTracker.new
  else
    Staccato::Tracker.new(id, client_id, hit_options)
  end
end

.tracking_uriObject

The tracking endpoint we use to submit requests to GA



36
37
38
# File 'lib/staccato.rb', line 36

def self.tracking_uri
  URI('http://www.google-analytics.com/collect')
end