javascriptjqueryloggingpapertrail-app

Is there a JavaScript API to send logs to a cloud logging service (like papertrail)?


I have some key events that are captured on the client side, and I would like to aggregate them easily. Instead of sending them to my server and pushing to Papertrail, is there any service out there that has a RESTful API to send logs? (or a JQuery plugin for Papertrail?)


Solution

  • Here's the quick rundown of Google Analytics event logging from their site:

    https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

    Basically it breaks down to category, action[, label, value]. So for an error:

    _gaq.push("_trackEvent", "error", "login", "bad password", 1);
    

    For a button, e.g. slideshow:

    _gaq.push("_trackEvent", "slideshow", "next");
    

    Make sure to read the documentation, it does a better job than I do. You could also wire up try..catch events to Google Analytics and send the error code.