Additional error logging

This commit is contained in:
Chloe Herd 2025-01-15 10:31:06 -05:00
parent 6ec8709aa4
commit fc834f9d12
3 changed files with 24 additions and 11 deletions

View file

@ -110,7 +110,13 @@ export default {
if (error.response.status && error.response.status != "404") {
// Do not route to error logic when no wipers found or no promo found (404s)
router.navigateError();
const errorPayload = {
cause: `Response error ${error.response.status}`,
currentPage: pageNameToLog,
endpoint: endpoint,
};
router.navigateError(errorPayload);
// do not log 404 errors from services because we return NotFound
// when a service doesn't return an object

View file

@ -654,12 +654,7 @@ export default {
pushToDataLayerIfDefined({
event: "page-error",
error: {
type: error.type || "",
cause: error.cause || "",
currentPage: error.currentPage || "",
nextPage: error.nextPage || "",
},
error: error,
});
},

View file

@ -436,9 +436,8 @@ router.navigateToExternalUrl = (url, optionalQuery = {}) => {
navigateToUrl(url, optionalQuery);
};
router.navigateError = () => {
DisplayPageError();
/// TODO - Add error logging for dataLayer here?
router.navigateError = (errorPayload = null) => {
DisplayPageError(errorPayload);
};
//Use this navigation when you need to call next() explicitly. beforeRouteEnter is a good example.
@ -659,9 +658,22 @@ function GoToFunnelStartOn404(next, errorPayload = null) {
});
}
async function DisplayPageError() {
async function DisplayPageError(errorPayload = null) {
console.log("%c running DisplayPageError()... ", "font-size: 20px; color: purple;");
if(errorPayload !== null) {
errorPayload.type = "DisplayPageError";
analyticsMixin.methods.pushPageErrorToDataLayer(errorPayload);
} else {
errorPayload = {
type: "DisplayPageError",
cause: "Unknown page error",
currentPage: getQuerystringParameter(queryStrings.FMG_PAGE),
nextPage: null,
};
analyticsMixin.methods.pushPageErrorToDataLayer(errorPayload);
}
// Put item on the bus
eventBus.addEventToBus(
globalEvents.Categories.GLOBAL_ALERT,