Unverified Commit f9cf8446 authored by Benjamin Neff's avatar Benjamin Neff
Browse files

Merge pull request #7280 from svbergerem/remove-chartbeat-and-mixpanel

Remove chartbeat and mixpanel support
parents f1f1d099 bd0210a1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
* Make the mention syntax more flexible [#7305](https://github.com/diaspora/diaspora/pull/7305)
* Display @ before mentions [#7324](https://github.com/diaspora/diaspora/pull/7324)
* Simplify mentions in the publisher [#7302](https://github.com/diaspora/diaspora/pull/7302)
* Remove chartbeat and mixpanel support [#7280](https://github.com/diaspora/diaspora/pull/7280)

## Bug fixes

+0 −6
Original line number Diff line number Diff line
@@ -126,12 +126,6 @@ var app = {
    app.flashMessages = new app.views.FlashMessages({el: $("#flash-container")});
  },

  /* mixpanel wrapper function */
  instrument : function(type, name, object, callback) {
    if(!window.mixpanel) { return; }
    window.mixpanel[type](name, object, callback);
  },

  setupDisabledLinks: function() {
    $("a.disabled").click(function(event) {
      event.preventDefault();
+0 −8
Original line number Diff line number Diff line
@@ -76,8 +76,6 @@ app.models.Post.Interactions = Backbone.Model.extend({
        app.flashMessages.handleAjaxError(response);
      }
    });

    app.instrument("track", "Like");
  },

  unlike : function() {
@@ -87,8 +85,6 @@ app.models.Post.Interactions = Backbone.Model.extend({
      self.set({"likes_count" : self.get("likes_count") - 1});
      self.likes.trigger("change");
    }});

    app.instrument("track", "Unlike");
  },

  comment: function(text, options) {
@@ -104,8 +100,6 @@ app.models.Post.Interactions = Backbone.Model.extend({
      self.trigger('change'); //updates after sync
      if (options.success) { options.success(); }
    });

    app.instrument("track", "Comment");
  },

  reshare : function(){
@@ -126,8 +120,6 @@ app.models.Post.Interactions = Backbone.Model.extend({
      .fail(function(response) {
        app.flashMessages.handleAjaxError(response);
      });

    app.instrument("track", "Reshare");
  },

  userCanReshare : function(){

app/helpers/analytics_helper.rb

deleted100644 → 0
+0 −69
Original line number Diff line number Diff line
#   Copyright (c) 2010-2012, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

module AnalyticsHelper
  def include_mixpanel
    include_analytics "mixpanel" do
      nonced_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(' ');
          for(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,[]);
          mixpanel.init("#{AppConfig.privacy.mixpanel_uid}");
        JS
      end
    end
  end

  def include_mixpanel_guid
    return unless current_user
    include_analytics "mixpanel" do
      nonced_javascript_tag do
        <<-JS.html_safe
          mixpanel.name_tag("#{current_user.guid}");
        JS
      end
    end
  end

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

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

  private

  def include_analytics(service, &block)
    return unless configured?(service)
    yield block
  end

  def configured?(service)
    AppConfig.privacy.send("#{service}_uid").present?
  end
end
+0 −2
Original line number Diff line number Diff line
@@ -22,9 +22,7 @@
= include_gon(camel_case: true, nonce: content_security_policy_nonce(:script))
= yield(:javascript)

= chartbeat_head_block
= csrf_meta_tag
= current_user_atom_tag
= include_mixpanel

= yield(:head)
Loading