class Rack::Tracker::GoogleAnalytics::Send
Public Class Methods
new(attrs = {})
click to toggle source
Calls superclass method
# File lib/rack/tracker/google_analytics/google_analytics.rb, line 11 def initialize(attrs = {}) attrs.reverse_merge!(type: 'event') super end
Public Instance Methods
attributes()
click to toggle source
# File lib/rack/tracker/google_analytics/google_analytics.rb, line 24 def attributes Hash[to_h.slice(:category, :action, :label, :value).map { |k,v| [self.type.to_s + k.to_s.capitalize, v] }] end
event()
click to toggle source
# File lib/rack/tracker/google_analytics/google_analytics.rb, line 20 def event { hitType: self.type }.merge(attributes.stringify_values).compact end
write()
click to toggle source
# File lib/rack/tracker/google_analytics/google_analytics.rb, line 16 def write ['send', event].to_json.gsub(/\[|\]/, '') end