Add Accept Header on ClientTracking (#8895)
* feat: add HEADER_ACCEPT constant and update requestOptions in ClientTracking * feat: add HEADER_ACCEPT to request headers and improve request options handling * feat: add Accept header to performance report requests
This commit is contained in:
parent
9f638d11ba
commit
29e2d3ddb1
4 changed files with 5 additions and 2 deletions
|
|
@ -56,7 +56,7 @@ describe('sendPerformanceReport', () => {
|
|||
it('happy path', async () => {
|
||||
const {error} = await sendPerformanceReport(serverUrl, report);
|
||||
expect(error).toBeFalsy();
|
||||
expect(mockApiClient.post).toHaveBeenCalledWith(`${serverUrl}/api/v4/client_perf`, {body: report, headers: {}});
|
||||
expect(mockApiClient.post).toHaveBeenCalledWith(`${serverUrl}/api/v4/client_perf`, {body: report, headers: {Accept: 'application/json'}});
|
||||
});
|
||||
|
||||
it('properly returns error', async () => {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// See LICENSE.txt for license information.
|
||||
|
||||
export const HEADER_AUTH = 'Authorization';
|
||||
export const HEADER_ACCEPT = 'Accept';
|
||||
export const HEADER_ACCEPT_LANGUAGE = 'Accept-Language';
|
||||
export const HEADER_BEARER = 'BEARER';
|
||||
export const HEADER_CACHE_CONTROL = 'Cache-Control';
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ export default class ClientTracking {
|
|||
getRequestHeaders(requestMethod: string) {
|
||||
const headers = {...this.requestHeaders};
|
||||
|
||||
headers[ClientConstants.HEADER_ACCEPT]= 'application/json';
|
||||
|
||||
if (this.csrfToken && requestMethod.toLowerCase() !== 'get') {
|
||||
headers[ClientConstants.HEADER_X_CSRF_TOKEN] = this.csrfToken;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ export function getBaseReportRequest(start: number, end: number): {body: Perform
|
|||
histograms: [],
|
||||
counters: [],
|
||||
},
|
||||
headers: {},
|
||||
headers: {Accept: 'application/json'},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue