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
......@@ -29,58 +31,60 @@
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined)
var Common = {};
*/
if (Common === undefined) {
var Common = {}; // jshint ignore:line
}
Common.component = Common.component || {};
Common.Analytics = Common.component.Analytics = new(function() {
var _category;
Common.Analytics = Common.component.Analytics = (function () {
"use strict";
var _category;
return {
initialize: function(id, category) {
return {
initialize: function (id, category) {
if (typeof id === 'undefined')
throw 'Analytics: invalid id.';
if (typeof id === 'undefined')
throw 'Analytics: invalid id.';
if (typeof category === 'undefined' || Object.prototype.toString.apply(category) !== '[object String]')
throw 'Analytics: invalid category type.';
if (typeof category === 'undefined' || Object.prototype.toString.apply(category) !== '[object String]')
throw 'Analytics: invalid category type.';
_category = category;
_category = category;
$('head').append(
'<script type="text/javascript">' +
'var _gaq = _gaq || [];' +
'_gaq.push(["_setAccount", "' + id + '"]);' +
'_gaq.push(["_trackPageview"]);' +
'(function() {' +
'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";' +
'var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);' +
'})();' +
'</script>'
);
},
// $('head').append(
// '<script type="text/javascript">' +
// 'var _gaq = _gaq || [];' +
// '_gaq.push(["_setAccount", "' + id + '"]);' +
// '_gaq.push(["_trackPageview"]);' +
// '(function() {' +
// '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";' +
// 'var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);' +
// '})();' +
// '</script>'
// );
},
trackEvent: function(action, label, value) {
trackEvent: function (action, label, value) {
if (typeof action !== 'undefined' && Object.prototype.toString.apply(action) !== '[object String]')
throw 'Analytics: invalid action type.';
if (typeof action !== 'undefined' && Object.prototype.toString.apply(action) !== '[object String]')
throw 'Analytics: invalid action type.';
if (typeof label !== 'undefined' && Object.prototype.toString.apply(label) !== '[object String]')
throw 'Analytics: invalid label type.';
if (typeof label !== 'undefined' && Object.prototype.toString.apply(label) !== '[object String]')
throw 'Analytics: invalid label type.';
if (typeof value !== 'undefined' && !(Object.prototype.toString.apply(value) === '[object Number]' && isFinite(value)))
throw 'Analytics: invalid value type.';
if (typeof value !== 'undefined' && !(Object.prototype.toString.apply(value) === '[object Number]' && isFinite(value)))
throw 'Analytics: invalid value type.';
if (typeof _gaq === 'undefined')
return;
if (typeof _gaq === 'undefined')
return;
if (_category === 'undefined')
throw 'Analytics is not initialized.';
if (_category === 'undefined')
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