If you have many XHR calls (using XMLHttpRequest or the Fetch API) from your page that you do not need to monitor, you can use XHR filters so that the Agent only monitors a regex-defined list of specified calls. 

When XHR calls are monitored, the absolute path of the XHR calls is provided to the JavaScript Agent. In the Controller UI, those monitored XHR calls will be displayed as configured by naming rules. If there are no naming rules, the absolute path of the XHR call is displayed.

XHR Filters 

You can use the XHR filters below to include or exclude XHR calls. The filters can be in the form of an XHR filter object or an array of XHR filter objects.

  • xhr.include

  • xhr.exclude 

Filter Object Structure

The XHR filter object has two properties: urls and method. The urls property is an array of objects containing a pattern property that specifies a regular expression for matching URLs. The method property is a string that specifies an HTTP method. You can use one or both of the properties. If you only use the urls array, the matched URLs will be either included or excluded for all HTTP methods. If you only specify method, all calls using the specified HTTP method will be either included or excluded.

The following is the general structure for the filter object:

{
    urls: 
      [
        {
          pattern: ".*foo.*"
        },
        {
          pattern: ".*bar.*"
        }
      ],
    method: 'GET'
}
JS

XHR Filter Example

To use XHR filters, you must assign XHR filters to xhr.include and xhr.exclude before you inject the adrum.js script. It's important to note that the exclude patterns override the include patterns, so those URLs that are matched by both the include and exclude patterns will ultimately be excluded.

For example, in the code snippet below, the include pattern would match all HTTP requests to http://somedomain/app_status/user-profile.jsp, but the exclude pattern would exclude POST calls to that URL.

<head>
    <script type='text/javascript' charset='UTF-8'>
        (function(config){
            (function(xhr) {
                xhr.include = {
                    urls: [
                        {
                            pattern: ".*ajax_info.txt"
                        },
                        {
                            pattern: ".*app_status.*"
                        }
                    ]
                };
                xhr.exclude = {
                    urls = [
                        {
                            pattern: ".*user-profile.*"
                        }
                   ],
                   method: "POST"
                };
            })(config.xhr || (config.xhr = {}));
        })(window["adrum-config"] || (window["adrum-config"] = {}));
    </script>
    <script src='//cdn.appdynamics.com/adrum/adrum-latest.js' type='text/javascript' charset='UTF-8'></script>
    ...
</head>
JS