Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclientSideLogging.js
More file actions
Latest commit
86 lines (74 loc) · 2.9 KB
/
Copy pathclientSideLogging.js
File metadata and controls
86 lines (74 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
varLogger=(function(){
varbrowserVersion;
functionconsoleEvents(){
if(browserVersion!=9.0&&browserVersion!=8.0){// extend the console for ie10+
varorgDebug=console.debug,
orgErr=console.error,
orgLog=console.log,
orgWarn=console.warn;
console.debug=function(msg){
orgDebug.apply(console,arguments);
ga('send','event','JS console','debug',msg);// univeral google analytics syntax
}
console.error=function(msg){
orgErr.apply(console,arguments);
ga('send','event','JS console','error',msg);
}
console.log=function(msg){
orgLog.apply(console,arguments);
ga('send','event','JS console','log',msg);
}
console.warn=function(msg){
orgWarn.apply(console,arguments);
ga('send','event','JS console','warn',msg);
}
//window.onerror = function (msg, file, line) {
// ga('send', 'event', 'JS console', 'error', msg);
//};
}
else{
// fix ie8 not working without dev tools open
window.console||(window.console={debug: function(){},error: function(){},log: function(){},warn: function(){}});
// overwrite the console (.apply() breaks ie9-)
window.console=(function(c){
return{
debug: function(v){
ga('send','event','JS console','debug',v);
c.debug(v);
},
error: function(v){
ga('send','event','JS console','error',v);
c.error(v);
},
log: function(v){
ga('send','event','JS console','log',v);
c.log(v);
},
warn: function(v){
ga('send','event','JS console','warn',v);
c.warn(v);
}
};
}(console));
}
}
functionbrowser(){
navigator.sayswho=(function(){
varN=navigator.appName,ua=navigator.userAgent,tem;
varM=ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M&&(tem=ua.match(/version\/([\.\d]+)/i))!=null)M[2]=tem[1];
M=M ? [M[1],M[2]] : [N,navigator.appVersion,'-?'];
returnM;
})();
returnnavigator.sayswho[1];
}
return{
init: function(){
browserVersion=browser();
consoleEvents();
}
};
})();
$(function(){
Logger.init();
});