Sha256: d8d0496fecf26726772ea208f6bfdcfe2294434e80cc5896bcf40061fb9a216d
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
module Analytical module Console class Api include Analytical::Base::Api def initialize(parent, options={}) super @tracking_command_location = :body_append end def init_javascript(location) init_location(location) do js = <<-HTML <!-- Analytical Init: Console --> <script type="text/javascript"> console.log('Analytical Init: Console'); </script> HTML js end end def track(*args) "console.log(\"Analytical Track: \"+\"#{escape args.first}\");" end def identify(id, *args) data = args.first || {} "console.log(\"Analytical Identify: \"+\"#{id}\"+\" \"+$H(#{data.to_json}).toJSON());" end def event(name, *args) data = args.first || {} "console.log(\"Analytical Event: \"+\"#{name}\"+\" \"+$H(#{data.to_json}).toJSON());" end def set(data) "console.log(\"Analytical Set: \"+$H(#{data.to_json}).toJSON());" end private CONSOLE_JS_ESCAPE_MAP = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" } def escape(js) js.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { CONSOLE_JS_ESCAPE_MAP[$1] } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
analytical-1.2.0 | lib/analytical/console.rb |