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 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Added support to send Console error logs to Loggly

  • Loading branch information
psquickitjayant
psquickitjayant committed Nov 25, 2014
commit 50d18d208b8bb2487f26c7796d303415ebc0b674
@@ -4,7 +4,7 @@
LOGGLY_INPUT_SUFFIX = '.gif?',
LOGGLY_SESSION_KEY = 'logglytrackingsession',
LOGGLY_SESSION_KEY_LENGTH = LOGGLY_SESSION_KEY.length + 1;

var sendConsoleErrors;
function uuid() {
// lifted from here -> http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
@@ -22,6 +22,11 @@
tracker.setSession();
setInputUrl(tracker);
}

function setConsoleError(tracker,sendConsoleErrors) {
tracker.sendConsoleErrors = sendConsoleErrors;
}


function setInputUrl(tracker) {
tracker.inputUrl = LOGGLY_INPUT_PREFIX
@@ -63,22 +68,22 @@
self.logglyCollectorDomain = data.logglyCollectorDomain;
return;
}

if(data.logglyKey) {

if(data.sendConsoleErrors) {
setConsoleError(self, data.sendConsoleErrors);
}
if(data.logglyKey) {
setKey(self, data.logglyKey);
return;
}

if(data.session_id) {
self.setSession(data.session_id);
return;
}
}

if(!self.key) {
if(!self.key) {
return;
}

self.track(data);
}, 0);

@@ -129,6 +134,24 @@
}
}

//send console error messages to Loggly
window.onerror = function (msg, url, line, col){

if(_LTracker.sendConsoleErrors){
_LTracker.push(
{
category: 'BrowserJsException',
exception:
{
message: msg,
url: url,
lineno: line,
colno: col,
}
});
}
};

window._LTracker = tracker; // default global tracker

window.LogglyTracker = LogglyTracker; // if others want to instantiate more than one tracker
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.