Skip to content

ajaxListener UIC Module (XHR, fetch, sockets)

What does this module do?

This module allows Discover to log information regarding web application API calls being made, e.g. XHR, Fetch, Web Sockets calls.

Information captured includes, status code, status text, method and round-trip time.

Optionally the following can be captured, request headers, response headers, request body and response body.

Ability to block or allow URLs using regular expressions with optional privacy masking to sensitive fields

Module configuration

You can turn the module on/off in the below config, chaning the enabled: value:

modules: section
ajaxListener: {
    skipSafetyCheck: true,
    xhrEnabled: true,
    fetchEnabled: true,
    webSocketEnabled: true,
    eventSourceEnabled: true,
    urlBlocklist: [
        { regex: "contextdata", flags: "i" }, //commerce-preview.comdx.demo.com/wcs/resources/store/41/usercontext/@self/contextdata
        { regex: "googleapis", flags: "i" }, // maps.googleapis.com/maps/api/mapsjs/gen_204
        { regex: "suggestions", flags: "i" }, //requestURL=commerce-preview.comdx.demo.com/search/resources/store/41/sitecontent/suggestions
        { regex: "\\/collect", flags: "i" }, // requestURL=www.google-analytics.com/g/collect
        { regex: "products", flags: "i" },//commerce-preview.comdx.demo.com/search/resources/api/v2/products
        { regex: "shipping_", flags: "i" },//commerce-preview.comdx.demo.com/wcs/resources/store/41/cart/@self/usable_shipping_info
                                                        //commerce-preview.comdx.demo.com/wcs/resources/store/41/cart/shipping_modes
        { regex: "search\.json", flags: "i" },  //requestURL=commerce-preview.comdx.demo.com/_next/data/vrVPeFVIu3w8LTJGPJH1l/en-US/search.json
        { regex: "DiscoverUIPost\.php",  flags: "i"},
        { regex: "userevents",  flags: "i"},
        { regex: "\\/availability\\/live",  flags: "i"}
    ],
    filters: [
            log: {

                requestHeaders: false,
                requestData: true,
                responseHeaders: false,
                responseData: true,
                queryString: true,
                parseRequestString: false,
                sensitiveFields: [
                    {
        // Blocks the password in the AJAX call on Ruby
                        field : 'logonPassword',                                    
        replacement: "*******"
                    },
                    {
// Blocks the CC number in the AJAX call on Ruby
                        field : 'account',                                
replacement: "XXX-PCI-BLOCK-XXX"
                    },
                    {
        // Blocks the CVC number in the AJAX call on Ruby
                        field : 'cc_cvc',
replacement: "***"
                    }
                ],
                privacyPatterns: [
                ],
            }
        }
    ]
},

Sample responses

"connectionEvent": {
    "name": "ajaxListener",
    "data": {
        "interfaceType": "fetch",
        "originalURL": "discover.hcl-commerce.com/wcs/resources/store/41/loginidentity",
        "requestURL": "discover.hcl-commerce.com/wcs/resources/store/41/loginidentity",
        "description": "API Monitor - discover.hcl-commerce.com/wcs/resources/store/41/loginidentity",
        "method": "POST",
        "status": 201,
        "statusText": "Created",
        "async": true,
        "ajaxResponseTime": 115,
        "responseType": "basic",
        "locationHref": "https://discover.hcl-commerce.com/sign-in",
        "request": {
            "logonId": "master@tester.com",
            "logonPassword": "*******"
        },
        "response": {
            "personalizationID": "1740001387204-7",
            "resourceName": "loginidentity",
            "WCToken": "3036%2C7jaa7TVzpC52ECShuCmSOrdM3xypy%2FJ%2BZZYalsyGvpkd2E4S0LHKioDWtMdNMfQnkbVFf6FVh7EGRWkXQKas4zhy3BzBT6KFthBUXMmgI6kw9%2FO2kTyvqS%2FP%2FexcWDcRS3%2B%2FlvaEC84CT2WA5FI0uujdkrfK9D7pldhe15Kx7kGEjusLAmT7SrQ1A17Y1zX4oq2siL4GDYTr8KLXT%2Ff%2FbbDBy7dP8fB3TZJ%2B5SUhOYWN0IHzmBR%2FRLKDKtCv3hZO1UdYDU5mgXX4IVry4PmL1A%3D%3D",
            "userId": "3036",
            "WCTrustedToken": "3036%2C5K10ByEpma9b6%2Bi3zckdlDGhaCYrwaQBr2obDMmxl40%3D"
        }
    }
}
},
"connectionEvent": {
    "name": "ajaxListener",
    "data": {
        "interfaceType": "fetch",
        "originalURL": "discover.hcl-commerce.com/wcs/resources/store/41/inventoryavailability/byPartNumber/DR-TBLS-0001-0001,DR-TBLS-0004-0001,DR-TBLS-0002-0001,DR-TBLS-0003-0001",
        "requestURL": "discover.hcl-commerce.com/wcs/resources/store/41/inventoryavailability/byPartNumber/DR-TBLS-0001-0001,DR-TBLS-0004-0001,DR-TBLS-0002-0001,DR-TBLS-0003-0001",
        "description": "API Monitor - discover.hcl-commerce.com/wcs/resources/store/41/inventoryavailability/byPartNumber/DR-TBLS-0001-0001,DR-TBLS-0004-0001,DR-TBLS-0002-0001,DR-TBLS-0003-0001",
        "method": "GET",
        "status": 200,
        "statusText": "OK",
        "async": true,
        "ajaxResponseTime": 203,
        "responseType": "basic",
        "locationHref": "https://discover.hcl-commerce.com/tables?utm_source=google&utm_medium=SEO&utm_campaign=table_discount&utm_id=vi1024&utm_content=tables&utm_term=shop+dining+tables",
        "queryString": {
            "utm_source": "google",
            "utm_medium": "SEO",
            "utm_campaign": "table_discount",
            "utm_id": "vi1024",
            "utm_content": "tables",
            "utm_term": "shop+dining+tables"
        },
        "response": {
            "InventoryAvailability": [
                {
                    "availableQuantity": "101.0",
                    "onlineStoreName": "Ruby",
                    "productId": "14243",
                    "unitOfMeasure": "C62",
                    "inventoryStatus": "Available",
                    "partNumber": "DR-TBLS-0003-0001",
                    "onlineStoreId": "41"
                },
                {
                    "availableQuantity": "101.0",
                    "onlineStoreName": "Ruby",
                    "productId": "14245",
                    "unitOfMeasure": "C62",
                    "inventoryStatus": "Available",
                    "partNumber": "DR-TBLS-0004-0001",
                    "onlineStoreId": "41"
                },
                {
                    "availableQuantity": "101.0",
                    "onlineStoreName": "Ruby",
                    "productId": "14239",
                    "unitOfMeasure": "C62",
                    "inventoryStatus": "Available",
                    "partNumber": "DR-TBLS-0001-0001",
                    "onlineStoreId": "41"
                },
                {
                    "availableQuantity": "96.0",
                    "onlineStoreName": "Ruby",
                    "productId": "14241",
                    "unitOfMeasure": "C62",
                    "inventoryStatus": "Available",
                    "partNumber": "DR-TBLS-0002-0001",
                    "onlineStoreId": "41"
                }
            ],
            "resourceId": "https://ts-app:5443/wcs/resources/store/41/inventoryavailability/byPartNumber/DR-TBLS-0001-0001,DR-TBLS-0004-0001,DR-TBLS-0002-0001,DR-TBLS-0003-0001",
            "resourceName": "inventoryavailability"
        }
    }
}
},