diff --git a/src/router/index.js b/src/router/index.js index f6345aa6..1fbe148f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -74,7 +74,10 @@ const routes = [ var routeData = []; // Only load the routes if we are not on entry-page (this page is the default route and should always be valid) - if ( issPageToUse !== issPageValues.ENTRY_PAGE) { + // or the access-denied page (which is an error page) + const shouldGetRouteInfo = (issPageToUse !== issPageValues.ENTRY_PAGE && issPageToUse !== issPageValues.ACCESS_DENIED); + + if (shouldGetRouteInfo) { try { routeData = await GetRouteInfoFromPageName(issPageToUse); } @@ -89,11 +92,11 @@ const routes = [ } else { try { - // Manually create the entry-page route. + // Manually create the page route. routeData.push({ path: '/', - name: issPageValues.ENTRY_PAGE, - component: lazyLoadComponent(issPageValues.ENTRY_PAGE) + name: issPageToUse, + component: lazyLoadComponent(issPageToUse) }); } catch ( error ) { @@ -184,7 +187,13 @@ router.afterEach(async (to, from) => { store.clearSaveSessionPromise(); } - if (to.query.issPage !== issPageValues.ENTRY_PAGE) { + // Do not run base page logic (GA logging, session logging etc..) on the entry page or access denied page. + const shouldRunPageLogic = (to.query.issPage !== issPageValues.ENTRY_PAGE && to.query.issPage !== issPageValues.ACCESS_DENIED); + + if (shouldRunPageLogic) { + // Do not run experiments for the bailout page. + const shouldRunExperiments = (to.query.issPage !== issPageValues.BAILOUT_PAGE); + await analyticsMixin.methods.validateSession(); const skipSaveSession = !!router.options.history.state[routerParams.SKIP_SAVE_SESSION]; @@ -194,11 +203,8 @@ router.afterEach(async (to, from) => { document.title = routerTitles[to.query.issPage] || 'Safelite Solutions®'; - // Do not run experiments for entry page or the bailout page. - if (to.query.issPage !== issPageValues.BAILOUT_PAGE) { + if (shouldRunExperiments) { try { - console.error(`Running experiments for page: ${to.query.issPage}`); - // Run experiments for page. await runExperiments(to.query.issPage);