Skip to content

Instantly share code, notes, and snippets.

@ahy4
Created June 2, 2018 08:35
Show Gist options
  • Save ahy4/c8c4f74957dbf2414402a8924dfd8a65 to your computer and use it in GitHub Desktop.
Save ahy4/c8c4f74957dbf2414402a8924dfd8a65 to your computer and use it in GitHub Desktop.
window.$ = (function () {
if (Math.random() < 0.95) return $; // 影響範囲をへらしてリスク減らす
var getCallStack = function () {
try {
throw new Error("DUMMY");
} catch(e) {
return e.stack
.split(/[\r\n]+/)
.filter(function (s){
return /[^a]*at [^:]*:[0-9]+:[0-9]+/.test(s);
})
.map(function (s) {
return s.trim();
});
}
};
return function () {
var jqo = jQuery.fn.init.apply(null, arguments);
if (jqo.length === 0) {
console.info({ // 本当は送る処理する
message: 'jquery object length is 0',
arguments: Array.apply(null, arguments),
url: location.href,
callstack: getCallStack()
});
}
return jqo;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment