Commit ca492b40 authored by danielgrippi's avatar danielgrippi

add guid to mixpanel

parent de680216
......@@ -4,7 +4,7 @@
module AnalyticsHelper
def include_mixpanel
include_analytics "mixpanel" do |service_uid|
include_analytics "mixpanel" do
javascript_tag do
<<-JS.html_safe
(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(' ');
......@@ -15,13 +15,24 @@ module AnalyticsHelper
end
end
def mixpanel_guid_block
return unless current_user
include_analytics "mixpanel" do
javascript_tag do
<<-JS.html_safe
mixpanel.name_tag(#{current_user.guid});
JS
end
end
end
def chartbeat_head_block
return unless configured?("chartbeat")
javascript_tag("var _sf_startpt=(new Date()).getTime()")
end
def include_chartbeat
include_analytics "chartbeat" do |service_uid|
include_analytics "chartbeat" do
javascript_tag do
<<-JS.html_safe
var _sf_async_config = { uid: "#{AppConfig[:mixpanel_uid]}", domain: "#{AppConfig[:pod_uri].host}" };
......@@ -49,7 +60,7 @@ module AnalyticsHelper
def include_analytics(service, &block)
return unless configured?(service)
yield block, service_uid=AppConfig["#{service}_uid".to_sym]
yield block
end
def configured?(service)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment