Module: Vanity::Metric::GoogleAnalytics
- Defined in:
- lib/vanity/metric/google_analytics.rb
Overview
Calling google_analytics method on a metric extends it with these modules, redefining the values and hook methods.
Defined Under Namespace
Classes: Resource
Instance Method Summary collapse
-
#hook ⇒ Object
Hooks not supported for GA metrics.
-
#last_update_at ⇒ Object
Unkown (for now).
-
#report ⇒ Object
Garb report.
- #track!(args = nil) ⇒ Object
-
#values(from, to) ⇒ Object
Returns values from GA using parameters specified by prior call to google_analytics.
Instance Method Details
#hook ⇒ Object
Hooks not supported for GA metrics.
43 44 45 |
# File 'lib/vanity/metric/google_analytics.rb', line 43 def hook raise "Cannot use hooks with Google Analytics methods" end |
#last_update_at ⇒ Object
Unkown (for now).
53 54 |
# File 'lib/vanity/metric/google_analytics.rb', line 53 def last_update_at end |
#report ⇒ Object
Garb report.
48 49 50 |
# File 'lib/vanity/metric/google_analytics.rb', line 48 def report @ga_resource end |
#track!(args = nil) ⇒ Object
56 57 |
# File 'lib/vanity/metric/google_analytics.rb', line 56 def track!(args = nil) end |
#values(from, to) ⇒ Object
Returns values from GA using parameters specified by prior call to google_analytics.
35 36 37 38 39 40 |
# File 'lib/vanity/metric/google_analytics.rb', line 35 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 |