Skip to content

Commit a25d4a5

Browse files
committed
chore: omit request/response body with an unsupported content type in network logs
1 parent 6474820 commit a25d4a5

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/modules/NetworkLogger.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { RequestHandler } from '@apollo/client';
22

33
import InstabugConstants from '../utils/InstabugConstants';
44
import xhr, { NetworkData, ProgressCallback } from '../utils/XhrNetworkInterceptor';
5-
import { reportNetworkLog } from '../utils/InstabugUtils';
5+
import { reportNetworkLog, isContentTypeNotAllowed } from '../utils/InstabugUtils';
66

77
export type { NetworkData };
88

@@ -27,6 +27,20 @@ export const setEnabled = (isEnabled: boolean) => {
2727
network = await _networkDataObfuscationHandler(network);
2828
}
2929

30+
if (isContentTypeNotAllowed(network.requestContentType)) {
31+
network.requestBody = `Body is omitted because content type ${network.requestContentType} isn't supported`;
32+
console.warn(
33+
`IBG-RN: The request body for the network request with URL ${network.url} has been omitted because the content type ${network.requestContentType} isn't supported.`,
34+
);
35+
}
36+
37+
if (isContentTypeNotAllowed(network.contentType)) {
38+
network.responseBody = `Body is omitted because content type ${network.contentType} isn't supported`;
39+
console.warn(
40+
`IBG-RN: The response body for the network request with URL ${network.url} has been omitted because the content type ${network.contentType} isn't supported.`,
41+
);
42+
}
43+
3044
reportNetworkLog(network);
3145
} catch (e) {
3246
console.error(e);

0 commit comments

Comments
 (0)