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