Log errors and messages with SessionStack

Alexander Zlatkov
SessionStack Blog
Published in
3 min readJun 8, 2016

SessionStack registers all events and exceptions that get fired during user sessions. You can expand the error details to see relevant session information, user environment, and device params along with the video recording at the time the error occurred.

In this post, we’ll briefly describe how you can log errors or messages with SessionStack.

First, you need to integrate SessionStack in your web app, by copying the JavaScript snippet from our dashboard as explained in our documentation. When your web app is visited, our library is being downloaded by this snippet which adds a global JavaScript object named “sessionstack”.

This object can be invoked with specific parameters, in order to accomplish a specific task. For example, in order to log a custom message, you need to invoke the object as follows:

sessionstack('log', 'my message');

The concept of the API is similar to Google Analytics. The reason is that you may invoke some of the commands before our snippet has finished downloading the actual library, so the commands are being queued. When our library is downloaded, the pending commands will be processed. The library, however, should be downloaded quite fast, because, at this point, it’s a bit over 190KB in size.

This is a preview of the log in the dashboard for the corresponding website:

blog_log

The API also allows you to log errors. SessionStack will get the corresponding stack trace and all the provided information.

try {
someFunction();
} catch (e) {
sessionstack('log', e);
}
blog_log_error

As mentioned, the stack trace is also stored:

blog_log_error_stacktrace

By clicking the “play” button, the logged message or error will be replayed as a “video” so you can see how to reproduce it:

blog_player

You can check it out real quick — sign up for free and integrate SessionStack into your web app. It will take just a couple of minutes.

You can configure your web app to automatically log all JavaScript errors which are not handled by your code as described in our documentation. You can also see the details of each session, like the browser information, OS, demographic data etc.

In the posts to follow, we’ll be providing more details about our page targeting and notification features that allow you to only monitor specific pages in your web app and receive emails when an error occurs.

--

--