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 headerKeys from '@/constants/header-keys';
|
||||||
import axiosResponseInterceptorMessages from '@/constants/axios-response-interceptor-messages.js';
|
import axiosResponseInterceptorMessages from '@/constants/axios-response-interceptor-messages.js';
|
||||||
import { getSessionKeyValue } from '@/helpers/cookie-helper';
|
import { getSessionKeyValue } from '@/helpers/cookie-helper';
|
||||||
|
import endpoints from "@/constants/endpoints";
|
||||||
|
|
||||||
// Add a response interceptor for global axios error handing.
|
// Add a response interceptor for global axios error handing.
|
||||||
axios.interceptors.response.use(
|
axios.interceptors.response.use(
|
||||||
|
|
@ -84,24 +85,33 @@ export default {
|
||||||
return resolve(response);
|
return resolve(response);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
if (logApiCall) {
|
// Add any logging specific endpoints here.
|
||||||
analyticsMixIn.methods.pushEventToGA(
|
if (
|
||||||
GaCategories.API_RESPONSE,
|
endpoint.toLowerCase().includes(endpoints.LogIssSessionData.url) ||
|
||||||
GaActions.RESULT,
|
endpoint.toLowerCase().includes(endpoints.LogPageView.url) ||
|
||||||
`${GaLabels.ERROR}_${endpoint}`,
|
endpoint.toLowerCase().includes(endpoints.LogCustomEvent.url)
|
||||||
true
|
) {
|
||||||
);
|
return resolve({ data: null, error: "Ignore errors when logging" });
|
||||||
}
|
} else {
|
||||||
|
if (logApiCall) {
|
||||||
if (error.response.status !== 404) {
|
analyticsMixIn.methods.pushEventToGA(
|
||||||
const errorData = { method, url, payload, error };
|
GaCategories.API_RESPONSE,
|
||||||
global.$logger.logError(`${method}: ${endpoint}`, errorData);
|
GaActions.RESULT,
|
||||||
if (bailoutOnError && global.bailoutOnAxiosError !== undefined)
|
`${GaLabels.ERROR}_${endpoint}`,
|
||||||
{
|
true
|
||||||
global.bailoutOnAxiosError(errorData);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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