make conditional logging a function call
This commit is contained in:
parent
870a4ea45a
commit
246e6aa9e5
1 changed files with 38 additions and 57 deletions
|
|
@ -50,32 +50,23 @@ const routes = [
|
||||||
async beforeEnter(to, from, next) {
|
async beforeEnter(to, from, next) {
|
||||||
// If we have no query string, or we don't have the FmgPage query string.
|
// If we have no query string, or we don't have the FmgPage query string.
|
||||||
try {
|
try {
|
||||||
const log = getQuerystringParameter(queryStrings.LOG);
|
log("------------- router index.js beforeEnter start -----------------");
|
||||||
|
log(" --to: ", JSON.stringify(to));
|
||||||
if (eval(log)) {
|
log(" --from: ", JSON.stringify(from));
|
||||||
// prettier-ignore
|
log(" --next: ", JSON.stringify(next));
|
||||||
console.log("------------- router index.js beforeEnter start -----------------");
|
log(" --cookie: ", JSON.stringify(getFunnelCookie()));
|
||||||
console.log(new Date() + " --to: " + JSON.stringify(to));
|
|
||||||
console.log(new Date() + " --from: " + JSON.stringify(from));
|
|
||||||
console.log(new Date() + " --next: " + JSON.stringify(next));
|
|
||||||
console.log(new Date() + " --cookie: " + JSON.stringify(getFunnelCookie()));
|
|
||||||
}
|
|
||||||
|
|
||||||
await analyticsMixin.methods.validateSession();
|
await analyticsMixin.methods.validateSession();
|
||||||
|
|
||||||
if (getFunnelCookie()?.SuppressConceptFunnel) {
|
if (getFunnelCookie()?.SuppressConceptFunnel) {
|
||||||
if (eval(log)) {
|
log(" --go to heritage suppressConceptFunnel: ");
|
||||||
console.log(new Date() + " --go to heritage suppressConceptFunnel: ");
|
|
||||||
}
|
|
||||||
await navigateToHeritageFunnel({ shouldSaveSession: false });
|
await navigateToHeritageFunnel({ shouldSaveSession: false });
|
||||||
return next(false);
|
return next(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the saved session has timed out, clear the session, execute 404 logic.
|
// If the saved session has timed out, clear the session, execute 404 logic.
|
||||||
if (getFunnelCookie() !== null && !isSavedSessionStillActive()) {
|
if (getFunnelCookie() !== null && !isSavedSessionStillActive()) {
|
||||||
if (eval(log)) {
|
log(" --save session timeout go to start");
|
||||||
console.log(new Date() + " --save session timeout go to start");
|
|
||||||
}
|
|
||||||
await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
|
await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
|
||||||
deleteFunnelCookie();
|
deleteFunnelCookie();
|
||||||
GoToFunnelStartOn404(next);
|
GoToFunnelStartOn404(next);
|
||||||
|
|
@ -85,9 +76,7 @@ const routes = [
|
||||||
if (window.sessionStorage.getItem("submittedOrder") !== null) {
|
if (window.sessionStorage.getItem("submittedOrder") !== null) {
|
||||||
if (to.query.fmgPage !== funnelStartPageName) {
|
if (to.query.fmgPage !== funnelStartPageName) {
|
||||||
to.query.fmgPage = fmgPageValues.CONFIRMATION;
|
to.query.fmgPage = fmgPageValues.CONFIRMATION;
|
||||||
if (eval(log)) {
|
log(" --has submittedOrder go to confirmation");
|
||||||
console.log(new Date() + " --has submittedOrder go to confirmation");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// On entering the funnel "fresh", read cookie information, decide what to do next.
|
// On entering the funnel "fresh", read cookie information, decide what to do next.
|
||||||
|
|
@ -150,20 +139,15 @@ const routes = [
|
||||||
|
|
||||||
// This logic may determine that the user should be sent to heritage -- if so, do that here.
|
// This logic may determine that the user should be sent to heritage -- if so, do that here.
|
||||||
if (pageToRedirectTo === fmgPageValues.HERITAGE) {
|
if (pageToRedirectTo === fmgPageValues.HERITAGE) {
|
||||||
if (eval(log)) {
|
// prettier-ignore
|
||||||
// prettier-ignore
|
log(" --go to heritage pageToRedirectTo ", JSON.stringify(pageToRedirectTo));
|
||||||
console.log(new Date() + " --go to heritage pageToRedirectTo " + JSON.stringify(pageToRedirectTo));
|
|
||||||
}
|
|
||||||
await navigateToHeritageFunnel({ shouldSaveSession: false });
|
await navigateToHeritageFunnel({ shouldSaveSession: false });
|
||||||
return next(false);
|
return next(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign our fmgPage so it will load normally like the other pages.
|
// Assign our fmgPage so it will load normally like the other pages.
|
||||||
to.query.fmgPage = pageToRedirectTo;
|
to.query.fmgPage = pageToRedirectTo;
|
||||||
if (eval(log)) {
|
log(" --assign to: ", JSON.stringify(pageToRedirectTo));
|
||||||
// prettier-ignore
|
|
||||||
console.log(new Date() + " --assign to: " + JSON.stringify(pageToRedirectTo));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,11 +161,8 @@ const routes = [
|
||||||
to.query.fmgPage === fmgPageValues.QUOTE ||
|
to.query.fmgPage === fmgPageValues.QUOTE ||
|
||||||
to.query.fmgPage === fmgPageValues.INSURANCE_COMPANY
|
to.query.fmgPage === fmgPageValues.INSURANCE_COMPANY
|
||||||
) {
|
) {
|
||||||
|
log(" --block quote page for integrated clients - go to heritage");
|
||||||
// Push to heritage if going to quote & integrated.
|
// Push to heritage if going to quote & integrated.
|
||||||
if (eval(log)) {
|
|
||||||
// prettier-ignore
|
|
||||||
console.log(new Date() + " --block quote for integrated - go to heritage");
|
|
||||||
}
|
|
||||||
await navigateToHeritageFunnel({ shouldSaveSession: false });
|
await navigateToHeritageFunnel({ shouldSaveSession: false });
|
||||||
return next(false);
|
return next(false);
|
||||||
}
|
}
|
||||||
|
|
@ -215,9 +196,7 @@ const routes = [
|
||||||
GoToFunnelStartOn404(next);
|
GoToFunnelStartOn404(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eval(log)) {
|
log(" --has route:", to.query.fmgPage);
|
||||||
console.log(new Date() + " --has route:" + to.query.fmgPage);
|
|
||||||
}
|
|
||||||
return next({ name: to.query.fmgPage, query: to.query, params: to.params });
|
return next({ name: to.query.fmgPage, query: to.query, params: to.params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,15 +224,12 @@ const routes = [
|
||||||
.components.default();
|
.components.default();
|
||||||
|
|
||||||
if (!arePagePrerequisitesValid(nextComponent)) {
|
if (!arePagePrerequisitesValid(nextComponent)) {
|
||||||
console.log(
|
// prettier-ignore
|
||||||
"Page Prereqs not valid for next component: " + nextComponent.default.name
|
console.log("Page Prereqs not valid for next component: " + nextComponent.default.name);
|
||||||
);
|
|
||||||
GoToFunnelStartOn404(next);
|
GoToFunnelStartOn404(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eval(log)) {
|
log("------------- router index.js beforeEnter end -----------------");
|
||||||
console.log("------------- router index.js beforeEnter end -----------------");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign current query string parameters, as well as our fmgPage one.
|
// Assign current query string parameters, as well as our fmgPage one.
|
||||||
next({
|
next({
|
||||||
|
|
@ -482,18 +458,16 @@ async function navigate(
|
||||||
const zip = getQuerystringParameter(queryStrings.ZIP_CODE);
|
const zip = getQuerystringParameter(queryStrings.ZIP_CODE);
|
||||||
const promo = getQuerystringParameter(queryStrings.PROMO);
|
const promo = getQuerystringParameter(queryStrings.PROMO);
|
||||||
const pageError = getQuerystringParameter(queryStrings.PAGE_ERROR);
|
const pageError = getQuerystringParameter(queryStrings.PAGE_ERROR);
|
||||||
const log = getQuerystringParameter(queryStrings.LOG);
|
const logQs = getQuerystringParameter(queryStrings.LOG);
|
||||||
|
|
||||||
if (eval(log)) {
|
log("------------- router index.js navigate start -----------------");
|
||||||
console.log("------------- router index.js navigate start -----------------");
|
log(" --scenario: ", scenario);
|
||||||
console.log(new Date() + " --scenario: " + scenario);
|
log(" --currentRoute: ", JSON.stringify(currentRoute));
|
||||||
console.log(new Date() + " --currentRoute: " + JSON.stringify(currentRoute));
|
log(" --isSavingNavigation: ", isSavingNavigation);
|
||||||
console.log(new Date() + " --isSavingNavigation: " + isSavingNavigation);
|
log(" --optionalQuery: ", JSON.stringify(optionalQuery));
|
||||||
console.log(new Date() + " --optionalQuery: " + JSON.stringify(optionalQuery));
|
log(" --optionalParams: ", JSON.stringify(optionalParams));
|
||||||
console.log(new Date() + " --optionalParams: " + JSON.stringify(optionalParams));
|
log(" --optionalPageData: ", JSON.stringify(optionalPageData));
|
||||||
console.log(new Date() + " --optionalPageData: " + JSON.stringify(optionalPageData));
|
log(" --nextPageName: ", nextPageName);
|
||||||
console.log(new Date() + " --nextPageName: " + nextPageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
hasZip &&
|
hasZip &&
|
||||||
|
|
@ -513,14 +487,12 @@ async function navigate(
|
||||||
queryStringsObject[queryStrings.PAGE_ERROR] = pageError;
|
queryStringsObject[queryStrings.PAGE_ERROR] = pageError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log) {
|
if (logQs) {
|
||||||
queryStringsObject[queryStrings.LOG] = log;
|
queryStringsObject[queryStrings.LOG] = logQs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eval(log)) {
|
log(" querystrings: ", JSON.stringify(queryStringsObject));
|
||||||
console.log(new Date() + "querystrings: " + JSON.stringify(queryStringsObject));
|
log("------------- router index.js navigate end -----------------");
|
||||||
console.log("------------- router index.js navigate end -----------------");
|
|
||||||
}
|
|
||||||
|
|
||||||
router.push({
|
router.push({
|
||||||
name: "root",
|
name: "root",
|
||||||
|
|
@ -547,6 +519,15 @@ function getNavigationMap(scenario, currentRoute) {
|
||||||
return matchedQueryValue[0];
|
return matchedQueryValue[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function log(message, data) {
|
||||||
|
const log = getQuerystringParameter(queryStrings.LOG);
|
||||||
|
data = data ?? "";
|
||||||
|
|
||||||
|
if (eval(log)) {
|
||||||
|
console.log(new Date() + message + data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------- Private Functions ----------------------------------------------------------
|
//---------------------------------------------------------- Private Functions ----------------------------------------------------------
|
||||||
|
|
||||||
// Navigate to an external url.
|
// Navigate to an external url.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue