Ignore logging calls.
This commit is contained in:
parent
001f1efea1
commit
972f55394b
1 changed files with 26 additions and 16 deletions
|
|
@ -6,6 +6,7 @@ import { GaCategories, GaActions, GaLabels } from '@/constants/analytics';
|
|||
import headerKeys from '@/constants/header-keys';
|
||||
import axiosResponseInterceptorMessages from '@/constants/axios-response-interceptor-messages.js';
|
||||
import { getSessionKeyValue } from '@/helpers/cookie-helper';
|
||||
import endpoints from "@/constants/endpoints";
|
||||
|
||||
// Add a response interceptor for global axios error handing.
|
||||
axios.interceptors.response.use(
|
||||
|
|
@ -84,24 +85,33 @@ export default {
|
|||
return resolve(response);
|
||||
},
|
||||
(error) => {
|
||||
if (logApiCall) {
|
||||
analyticsMixIn.methods.pushEventToGA(
|
||||
GaCategories.API_RESPONSE,
|
||||
GaActions.RESULT,
|
||||
`${GaLabels.ERROR}_${endpoint}`,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if (error.response.status !== 404) {
|
||||
const errorData = { method, url, payload, error };
|
||||
global.$logger.logError(`${method}: ${endpoint}`, errorData);
|
||||
if (bailoutOnError && global.bailoutOnAxiosError !== undefined)
|
||||
{
|
||||
global.bailoutOnAxiosError(errorData);
|
||||
// Add any logging specific endpoints here.
|
||||
if (
|
||||
endpoint.toLowerCase().includes(endpoints.LogIssSessionData.url) ||
|
||||
endpoint.toLowerCase().includes(endpoints.LogPageView.url) ||
|
||||
endpoint.toLowerCase().includes(endpoints.LogCustomEvent.url)
|
||||
) {
|
||||
return resolve({ data: null, error: "Ignore errors when logging" });
|
||||
} else {
|
||||
if (logApiCall) {
|
||||
analyticsMixIn.methods.pushEventToGA(
|
||||
GaCategories.API_RESPONSE,
|
||||
GaActions.RESULT,
|
||||
`${GaLabels.ERROR}_${endpoint}`,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if (error.response.status !== 404) {
|
||||
const errorData = { method, url, payload, error };
|
||||
global.$logger.logError(`${method}: ${endpoint}`, errorData);
|
||||
if (bailoutOnError && global.bailoutOnAxiosError !== undefined)
|
||||
{
|
||||
global.bailoutOnAxiosError(errorData);
|
||||
}
|
||||
}
|
||||
return reject(error.response);
|
||||
}
|
||||
return reject(error.response);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue