Home - GibraltarSoftware/Gibraltar.Agent.Web.JavaScript GitHub Wiki

Loupe JavaScript agent

These agents bring a lot of the Loupe Agent functionality to JavaScript and Angular, handling uncaught exceptions and allowing you to log messages from your JavaScript client script in Loupe.

These agents provide additonal functionality allowing you to correlate the actions your user performs client side with the corresponding server side processing.

Currently Loupe supports 2 different JavaScript agents: a native JavaScript agent and an Angular 1.x agent.

The agents are nearly identical the only difference at present is that the Angular agent doesn't support CORS by default whereas the native agent will work with CORS.

No dependencies

The agents are self contained scripts which have no external dependencies making it easy for you to include in your site.

Client machine details

As a default each request sent to the server, be it a normal message or due to an exception, will contain information on the users machine that is available to the browser see here for details on information that is available.

We using a slightly modified version of platform.js to enable us to embed the functionality withing the agent and ensure no clash between the agent and your site if you happen to be using platform.js as well.

Unhandled Exceptions

Both agents will handle uncaught exceptions and will attempt to create a stack trace from the error information that they are given.

The amount of information available in the stack trace will depend on:

  • the browser - some browsers do not have stack traces so they cannot be output
  • the mode the browser is working in - incognito/private mode can effect what stack trace is available (again dependent upon the browser)
  • the type of error - a custom error created by the user may not have the same level of functionality that a runtime error does e.g. TypeError

To generate the stack trace we utilise a slightly modified version of stackTrace.js to be able to embed it within the agent so there is no clash between the agent and your site if you happend to be using stackTrace.js yourself.

Session Tracking

When trying to investigate problems it is helpful if you can understand how a user is using the software and what happens on the server to the requests that the user makes.

To better enable this understanding the agent has ability to track a users session allowing you to see what is happening between client and server.

Find more information here which explains what Loupe does.

Ensuring log message delivery

Just like the normal .Net agents the JavaScript agents will attempt to store log messages/exceptions in local storage so that if it cannot contact the server no messages are lost and once it is able to send messages to the server any pending messages will be sent in the background.

A message will stay in local storage until the agent sucessfully sends the message to the server.

However, unlike the .Net agents there are some limitations and messages can only be stored if:

  • local storage is supported
  • the script is allowed to write to local storage
  • there is space in local storage to store messages