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
Parameters | Type | Description |
---|---|---|
data | object | |
data.error | string | undefined | An 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.request | object | |
data.request.headers | Record<string, string[]> | undefined | Headers of the request. Requires advanced network recording. |
data.request.body | string | undefined | Serialized body of the request. Requires advanced network recording. |
data.response | object | undefined | undefined when an error is present |
data.response.headers | Record<string, string[]> | undefined | Headers of the request. Requires advanced network recording. |
data.response.body | string | undefined | Serialized body of the response. Requires advanced network recording. |
data.url | string | |
context | object | |
context.pageUrl | string | URL of the page where the request was initiated |
Updated over 1 year ago