Tagged as: unicase
Filed Under: All Fonts, Print, unicase
Share:
// Deployed with bamboo
window.setErrorMeta = function(name, value) {
if(window._errs && typeof name === "string") {
window._errs.meta = window._errs.meta || {};
window._errs.meta[name] = value;
};
};
window.onerror = function windowError() {
// errorception logger will call this function before doing it's thing.
try {
if(window._errs) {
if(typeof SUdebug !== "undefined") {
setErrorMeta('debug', SUdebug);
}
var currentErr = _errs[_errs.length - 1];
if(!currentErr) {
return true;
}
if(/^https?:\/\/nb9-stumbleupon\.netdna-ssl\.com\/[^\/]+$/.test(currentErr[1])) {
// this is intended to solve the problem that errorception errors are segmented by the source url
// but we want them to be grouped as if all our app.js assets are the same file.
setErrorMeta('assetUrl', currentErr[1]); // capture the particular asset url in a meta
currentErr[1] = 'app.js'; // report it as 'app.js'
}
/* replace urls with a placeholder and send the urls in the meta */
var urlPattern = /https?:\/\/[^ '"\)\]]+/g,
urlMatches = [],
urlMatch;
while((urlMatch = urlPattern.exec(currentErr[0])) !== null) {
urlMatches.push(urlMatch[0]);
}
for(var i = 0; i < urlMatches.length; i++) {
var k = 'url-match-' + i,
v = urlMatches[i];
setErrorMeta(k, v);
currentErr[0] = currentErr[0].replace(v, '<' + k + '>');
}
} else {
console.log("_errs is undefined");
}
} catch(e) {
console.log("failed trying", e);
}
return true;
};
// errorception snippet do not touch
(function(_,e,rr,s){_errs=[s];var c=_.onerror;_.onerror=function(){var a=arguments;_errs.push(a);
c&&c.apply(this,a)};var b=function(){var c=e.createElement(rr),b=e.getElementsByTagName(rr)[0];
c.src="//beacon.errorception.com/"+s+".js";c.async=!0;b.parentNode.insertBefore(c,b)};
_.addEventListener?_.addEventListener("load",b,!1):_.attachEvent("onload",b)})
(window,document,"script","530bcc7986a669467a000263");
// end errorception snippet do not touch
window._errs.allow = function errorFilter(err) {
window._errs.alreadySeen = window._errs.alreadySeen || {};
var e;
if((e = window._errs.alreadySeen[err.message]) && e.line === err.line && e.url === err.url) {
return false;
} else {
window._errs.alreadySeen[err.message] = err;
}
// errorception logger will conditionally not log messages if this returns false;
var ignore = [
// exact match errors to ignore go here
];
var ignorePatterns = [
// these should be regex literals
/^Uncaught SecurityError: Blocked a frame with origin "[^"]*" from accessing.*/
];
var ignoreUrlPatterns = [
// these should be regex literals
/^https?:\/\/ff\.kis\.v[0-9]+\.scr\.kaspersky-labs\.com\/[^\/]+/,
/^https?:\/\/v207\.info\/.*/
];
var shouldIgnore = ignore.some(function(msg) {
// should ignore things that match the ignore list exactly.
return (err.message === msg);
});
if(!shouldIgnore) {
// also should ignore patterns that match
shouldIgnore = ignorePatterns.some(function(ignorePattern) {
return ignorePattern.test(err.message);
});
}
if(!shouldIgnore) {
// also should ignore patterns that match
shouldIgnore = ignoreUrlPatterns.some(function(ignorePattern) {
return ignorePattern.test(err.url);
});
}
if(!shouldIgnore) {
try {
var details = JSON.stringify(err);
var err = err.message;
var xhr = new XMLHttpRequest();
var accessToken = /su_accesstoken=([^;]*)/.exec(document.cookie);
if(accessToken && accessToken.length) {
accessToken = accessToken[1];
xhr.open('POST', 'https://www.stumbleupon.com/api/v2_0/report/error');
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.setRequestHeader("X-Su-AccessTokenKey", accessToken);
xhr.setRequestHeader("X-Su-ConsumerKey", "fdca7c36dbe636926ba914ac07c6d00241ec3441");
xhr.setRequestHeader("X-Su-ClientId", "448f3699-fbb8-a606-3f20-2d3e620c152c");
xhr.setRequestHeader("X-Su-Version", "SPA Index");
xhr.send("error=" + encodeURIComponent(err) +
"&domain=SPA&details=" + encodeURIComponent(details)
);
}
} catch(e) {
console.log('cannot post to error');
}
}
return !shouldIgnore;
};