Session Tracking - GibraltarSoftware/Gibraltar.Agent.Web.JavaScript GitHub Wiki
The Loupe JavaScript agents have been build in conjunction with the Loupe Web Logging Module to provide specific user session tracking capabilities allowing you to gain a better insight into how the user is using the software.
Loupe utilises two different ways for tracking your users activity:
- The Loupe Web Logging Module issues a session cookie with a unique identifier, Session Id, which is used on every request to enable logging of all interactions that user undertakes.
- The JavaScript agents generate a unique id, Agent Session Id, on creation and provide that id on every message, or error, that they log.
The combination of these two ids allows you to:
- link all interactions a user performs in a "session" (where session is until the browser/tab is closed)
- understand what interactions were done in separate tabs/windows during the lifetime of the cookie session
For example if you are seing data showing a user with the same cookie session Id but multiple Agent Session Ids that they are using multiple tabs within the scope of a single "session".
All log messages record the Session Id and Agent Session Id so that you can always link a message to the appropriate session even if the messages are received after those session have ended e.g. message sent at start up from local storage.
To help ensure that all your client interactions can be logged the agent provides a method, clientSessionHeader,
which provides you with a
request header to attach to any ajax requests which the Loupe Logging Module and existing agents will use when they in log information.
var requestHeader = loupe.clientSessionHeader();
var loupeHeader = {};
loupeHeader[requestHeader.headerName] = requestHeader.headerValue;
$.ajax({
type: "GET",
url: '/home/data',
headers: loupeHeader
}).done(function (data) {
$('#ajaxCallResult').text("succeeded");
}).error(function(jqXHR, textStatus) {
$('#ajaxCallResult').text("failed:" + jqXHR.status + " " + jqXHR.statusText);
});
If you wish to use your own Session Id you can override the Session Id used on log messages by calling setSessionId
this then will be utilised
by the Loupe Web Logging Module and existing agents rather than the Id
that had been set in the cookie.