module Vanity::Metric::GoogleAnalytics

Calling google_analytics method on a metric extends it with these modules, redefining the values and hook methods.

@since 1.3.0

Public Instance Methods

hook() click to toggle source

Hooks not supported for GA metrics.

# File lib/vanity/metric/google_analytics.rb, line 45
def hook
  fail "Cannot use hooks with Google Analytics methods"
end
last_update_at() click to toggle source

Unkown (for now).

# File lib/vanity/metric/google_analytics.rb, line 55
def last_update_at
end
report() click to toggle source

Garb report.

# File lib/vanity/metric/google_analytics.rb, line 50
def report
  @ga_resource
end
track!(args = nil) click to toggle source
# File lib/vanity/metric/google_analytics.rb, line 58
def track!(args = nil)
end
values(from, to) click to toggle source

Returns values from GA using parameters specified by prior call to google_analytics.

# File lib/vanity/metric/google_analytics.rb, line 37
def values(from, to)
  data = @ga_resource.results(from, to).inject({}) do |hash,entry|
    hash.merge(entry.date=>@ga_mapper.call(entry))
  end
  (from..to).map { |day| data[day.strftime('%Y%m%d')] || 0 }
end