require 'orange-core/middleware/base' module Orange::Middleware class Analytics < Base # Passes packet then parses the return def packet_call(packet) pass packet ga_key = orange.options['google_analytics_key'] || false if packet['route.context'] == :live && ga_key ga = "" packet[:content] = packet[:content].sub(/.*<\/body>$/, ga + '') end packet.finish end end end