Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to send Console error logs to Loggly #6

Merged
merged 5 commits into from Dec 5, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -11,7 +11,10 @@ Place the following on your page, and replace the logglyKey value with the key p
<script type="text/javascript" src="/js/loggly.tracker.js" async></script>
<script>
var _LTracker = _LTracker || [];
_LTracker.push({'logglyKey': '8c518f97-e3e0-4bfb-a8ed-582d084a5289' });
_LTracker.push({
'logglyKey': '8c518f97-e3e0-4bfb-a8ed-582d084a5289',
'setConsoleError' : true
});
</script>
```

@@ -15,6 +15,7 @@

function LogglyTracker() {
this.key = false;
this.sendConsoleErrors = false;
}

function setKey(tracker, key) {
@@ -23,6 +24,30 @@
setInputUrl(tracker);
}

function setSendConsoleError(tracker, sendConsoleErrors) {
tracker.sendConsoleErrors = sendConsoleErrors;

if(tracker.sendConsoleErrors === true){
var _onerror = window.onerror;
//send console error messages to Loggly
window.onerror = function (msg, url, line, col){
tracker.push({
category: 'BrowserJsException',
exception: {
message: msg,
url: url,
lineno: line,
colno: col,
}
});

if (_onerror && typeof _onerror === 'function') {
_onerror.apply(window, arguments);
}
};
}
}

function setInputUrl(tracker) {
tracker.inputUrl = LOGGLY_INPUT_PREFIX
+ (tracker.logglyCollectorDomain || LOGGLY_COLLECTOR_DOMAIN)
@@ -64,6 +89,10 @@
return;
}

if(data.setConsoleError !== undefined) {
setSendConsoleError(self, data.setConsoleError);
}

if(data.logglyKey) {
setKey(self, data.logglyKey);
return;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.