Commit 9e980562 authored by Boris Kocherov's avatar Boris Kocherov

Analytics.js disable

parent 3bae8df0
/*global Common, _gaq */
/* jshint -W116 */
/* /*
* *
* (c) Copyright Ascensio System Limited 2010-2017 * (c) Copyright Ascensio System Limited 2010-2017
...@@ -29,58 +31,60 @@ ...@@ -29,58 +31,60 @@
* Creative Commons Attribution-ShareAlike 4.0 International. See the License * Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
* *
*/ */
if (Common === undefined) if (Common === undefined) {
var Common = {}; var Common = {}; // jshint ignore:line
}
Common.component = Common.component || {}; Common.component = Common.component || {};
Common.Analytics = Common.component.Analytics = new(function() { Common.Analytics = Common.component.Analytics = (function () {
var _category; "use strict";
var _category;
return { return {
initialize: function(id, category) { initialize: function (id, category) {
if (typeof id === 'undefined') if (typeof id === 'undefined')
throw 'Analytics: invalid id.'; throw 'Analytics: invalid id.';
if (typeof category === 'undefined' || Object.prototype.toString.apply(category) !== '[object String]') if (typeof category === 'undefined' || Object.prototype.toString.apply(category) !== '[object String]')
throw 'Analytics: invalid category type.'; throw 'Analytics: invalid category type.';
_category = category; _category = category;
$('head').append( // $('head').append(
'<script type="text/javascript">' + // '<script type="text/javascript">' +
'var _gaq = _gaq || [];' + // 'var _gaq = _gaq || [];' +
'_gaq.push(["_setAccount", "' + id + '"]);' + // '_gaq.push(["_setAccount", "' + id + '"]);' +
'_gaq.push(["_trackPageview"]);' + // '_gaq.push(["_trackPageview"]);' +
'(function() {' + // '(function() {' +
'var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;' + // 'var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;' +
'ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";' + // 'ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";' +
'var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);' + // 'var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);' +
'})();' + // '})();' +
'</script>' // '</script>'
); // );
}, },
trackEvent: function(action, label, value) { trackEvent: function (action, label, value) {
if (typeof action !== 'undefined' && Object.prototype.toString.apply(action) !== '[object String]') if (typeof action !== 'undefined' && Object.prototype.toString.apply(action) !== '[object String]')
throw 'Analytics: invalid action type.'; throw 'Analytics: invalid action type.';
if (typeof label !== 'undefined' && Object.prototype.toString.apply(label) !== '[object String]') if (typeof label !== 'undefined' && Object.prototype.toString.apply(label) !== '[object String]')
throw 'Analytics: invalid label type.'; throw 'Analytics: invalid label type.';
if (typeof value !== 'undefined' && !(Object.prototype.toString.apply(value) === '[object Number]' && isFinite(value))) if (typeof value !== 'undefined' && !(Object.prototype.toString.apply(value) === '[object Number]' && isFinite(value)))
throw 'Analytics: invalid value type.'; throw 'Analytics: invalid value type.';
if (typeof _gaq === 'undefined') if (typeof _gaq === 'undefined')
return; return;
if (_category === 'undefined') if (_category === 'undefined')
throw 'Analytics is not initialized.'; throw 'Analytics is not initialized.';
_gaq.push(['_trackEvent', _category, action, label, value]); _gaq.push(['_trackEvent', _category, action, label, value]);
} }
} };
})(); })();
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