The setOnDataCallback method can be used for scrubbing data before it leaves the client's browser.

SessionStack.setOnDataCallback(function(obj) {
    // scrubbing logic..

It takes a function as a single argument which will be called each time before the data is being sent to our servers. The argument contains two properties: type and data.

Property nameTypeDescription
type StringDefines the data type being processed. This will always be
NETWORK_REQUEST. (Beware it can be changed in the future)
data ObjectContains more details about the request and the response:
Method (string)
URL (string)
Request headers (object)
Response headers (object)

The data scrubbing function should return an object containing url, requestHeaders, responseHeaders. If an object is not returned or non-object is returned (e.g null, undefined, etc.) no data will be scrubbed. If some of the properties (url, requestHeaders, responseHeaders) are missing they will be scrubbed. To remove all the data just return an empty object.

Property nameTypeDescription
urlStringDescribes the URL used in the network request method
requestHeadersObjectContains key-value pairs describing the request headers and their values.
responseHeadersObjectContains key-value pairs describing the response headers and their values.



Only URL, request headers and response headers can be scrubbed.

SessionStack.setOnDataCallback(function(obj) {
    if (obj.type === 'NETWORK_REQUEST') {	
        // custom logic for scrubbing all the data
        var data =;
        var url = scrubUrl(data.url); 
        var requestHeaders = scrubRequestHeaders(data.requestHeaders);
        var responseHeaders = scrubResponseHeaders(data.responseHeaders); 
        return {
            url: url,
            requestHeaders: requestHeaders,
            responseHeaders: responseHeaders