Update to Universal Analytics

This commit is contained in:
Guangcong Luo
2014-06-02 16:20:41 -05:00
parent 6f305080f0
commit 694f140943
3 changed files with 27 additions and 21 deletions

View File

@@ -19,25 +19,28 @@
<!--[if lte IE 8]><script>
document.location.replace('http://pokemonshowdown.com/autodownload/win');
</script><![endif]-->
<script>
var _gaq = _gaq || [];
if (!(/^(.*)\.psim\.us$/i.test(document.location.hostname))) {
_gaq.push(['_setAccount', 'UA-26211653-1'], ['_setDomainName', 'pokemonshowdown.com']);
} else {
_gaq.push(['_setAccount', 'UA-26211653-2'], ['_setDomainName', 'psim.us']);
}
_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>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
if (!(/^(.*)\.psim\.us$/i.test(document.location.hostname))) {
ga('create', 'UA-26211653-1', 'pokemonshowdown.com');
} else {
ga('create', 'UA-26211653-2', 'psim.us');
}
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<script>
window.onerror = function(err, uri, line) {
var msg = uri + ':' + line + ': ' + err;
if ('_gaq' in window) {
_gaq.push(['_trackEvent', 'Client error', msg]);
if ('ga' in window) {
ga('send', 'event', 'Client error', msg);
} else {
alert('ERROR: ' + msg);
}

View File

@@ -333,7 +333,10 @@ var Tools = {
if (linkclass) {
classbit = ' class="message-link-' + toId(linkclass) + '"';
}
str = str.replace(/(https?\:\/\/[a-z0-9-.]+(\:[0-9]+)?(\/([^\s]*[^\s?.,])?)?|[a-z0-9]([a-z0-9-\.]*[a-z0-9])?\.(com|org|net|edu|us)(\:[0-9]+)?((\/([^\s]*[^\s?.,])?)?|\b))/ig, function(uri) {
str = str.replace(/(https?\:\/\/[a-z0-9-.]+(\:[0-9]+)?(\/([^\s]*[^\s?.,])?)?|[a-z0-9.]+\@[a-z0-9.]+\.[a-z0-9]{2,3}|([a-z0-9]([a-z0-9-\.]*[a-z0-9])?\.(com|org|net|edu|us)(\:[0-9]+)?|qmark\.tk|hisouten\.koumakan\.jp)((\/([^\s]*[^\s?.,])?)?|\b))/ig, function(uri) {
if (/[a-z0-9.]+\@[a-z0-9.]+\.[a-z0-9]{2,3}/ig.test(uri)) {
return '<a href="mailto:'+uri+'" target="_blank"'+classbit+'>'+uri+'</u>';
}
// Insert http:// before URIs without a URI scheme specified.
var fulluri = uri.replace(/^([a-z]*[^a-z:])/g, 'http://$1');
var onclick;
@@ -353,8 +356,8 @@ var Tools = {
Tools.unescapeHTML(fulluri)
));
}
onclick = 'if (window._gaq) _gaq.push([\'_trackEvent\', \'' +
event + '\', \'' + Tools.escapeQuotes(fulluri) + '\']);';
onclick = 'if (window.ga) ga(\'send\', \'event\', \'' +
event + '\', \'' + Tools.escapeQuotes(fulluri) + '\');';
}
return '<a href="' + fulluri +
'" target="_blank" onclick="' + onclick + '"' + classbit +

View File

@@ -559,8 +559,8 @@
this.socket.onopen = function() {
socketopened = true;
if (altport && window._gaq) {
_gaq.push(['_trackEvent', 'Alt port connection', Config.server.id]);
if (altport && window.ga) {
ga('send', 'event', 'Alt port connection', Config.server.id);
}
self.trigger('init:socketopened');