Module: AnalyticsHelper

Defined in:
app/helpers/analytics_helper.rb

Overview

Copyright © 2010-2012, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary collapse

Instance Method Details

#chartbeat_head_blockObject


29
30
31
32
# File 'app/helpers/analytics_helper.rb', line 29

def chartbeat_head_block
  return unless configured?("chartbeat")
  javascript_tag("var _sf_startpt=(new Date()).getTime()")
end

#include_chartbeatObject


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/helpers/analytics_helper.rb', line 34

def include_chartbeat
  include_analytics "chartbeat" do
    javascript_tag do
      "var _sf_async_config = { uid: \#{AppConfig.privacy.chartbeat_uid}, domain: \"\#{AppConfig.pod_uri.host}\" };\n(function() {\nfunction loadChartbeat() {\nwindow._sf_endpt = (new Date()).getTime();\nvar e = document.createElement('script');\ne.setAttribute('language', 'javascript');\ne.setAttribute('type', 'text/javascript');\ne.setAttribute('src',\n(('https:' == document.location.protocol) ? 'https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/' : 'http://static.chartbeat.com/') +\n'js/chartbeat.js');\ndocument.body.appendChild(e);\n};\nvar oldonload = window.onload;\nwindow.onload = (typeof window.onload != 'function') ?\nloadChartbeat : function() { oldonload(); loadChartbeat(); };\n})();\n".html_safe
    end
  end
end

#include_mixpanelObject


6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/analytics_helper.rb', line 6

def include_mixpanel
  include_analytics "mixpanel" do
    javascript_tag do
      "(function(d,c){var a,b,g,e;a=d.createElement('script');a.type='text/javascript';a.async=!0;a.src=('https:'===d.location.protocol?'https:':'http:')+'//api.mixpanel.com/site_media/js/api/mixpanel.2.js';b=d.getElementsByTagName('script')[0];b.parentNode.insertBefore(a,b);c._i=[];c.init=function(a,d,f){var b=c;'undefined'!==typeof f?b=c[f]=[]:f='mixpanel';g='disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config'.split(' ');\nfor(e=0;e<g.length;e++)(function(a){b[a]=function(){b.push([a].concat(Array.prototype.slice.call(arguments,0)))}})(g[e]);c._i.push([a,d,f])};window.mixpanel=c})(document,[]);\nmixpanel.init(\"\#{AppConfig.privacy.mixpanel_uid}\");\n".html_safe
    end
  end
end

#include_mixpanel_guidObject


18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/analytics_helper.rb', line 18

def include_mixpanel_guid
  return unless current_user
  include_analytics "mixpanel" do
    javascript_tag do
      "mixpanel.name_tag(\"\#{current_user.guid}\");\n".html_safe
    end
  end
end