Network interceptor

Network interceptors can obscure sensitive data from recorded network calls, such as bodies, headers, and URLs.

Network events can be completely omitted by returning false from the interceptor.

📘

Configure network recording

To set up network interceptors, you must configure network recording. For more information, see Advanced network recording.

Example network interceptor

{
  interceptors: {
    network: (data, context) => {
      if (context.pageUrl.startsWith('https://my.domain/some-page')) {
        // throw away all requests initiated from https://my.domain/some-page
        return false;
      }
      
      const tokenIndex = data.url.indexOf('tokenId=');
      if (tokenIndex > -1) {
        data.url = data.url.slice(0, tokenIndex) + 'tokenId=[OBSCURED]';
      }
    }
}

Parameters

ParametersTypeDescription
dataobject
data.errorstring | undefinedAn error can happen when sending a request. It may be an exception from fetch or an error event from XHR. Serialized. Requires advanced network recording.
data.requestobject
data.request.headersRecord<string, string[]> | undefinedHeaders of the request. Requires advanced network recording.
data.request.bodystring | undefinedSerialized body of the request. Requires advanced network recording.
data.responseobject | undefinedundefined when an error is present
data.response.headersRecord<string, string[]> | undefinedHeaders of the request. Requires advanced network recording.
data.response.bodystring | undefinedSerialized body of the response. Requires advanced network recording.
data.urlstring
contextobject
context.pageUrlstringURL of the page where the request was initiated