From c7f76b1348d7f7fa27b628f717712c3e91f0c4a3 Mon Sep 17 00:00:00 2001 From: Matt Caimi Date: Fri, 23 Jun 2023 13:09:30 -0400 Subject: [PATCH] CSR-1439 refactor navigated page storage --- src/global-methods.js | 2 +- src/router/index.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/global-methods.js b/src/global-methods.js index 49f9e15df..1ae2dbf80 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -38,7 +38,7 @@ export default { additionalEventData = "_" + additionalSuccessEventDataHandler(response); } const pageName = analyticsMixIn.methods.getPageName(); - const nextPageName = router.getNextPage() || pageName; + const nextPageName = router.lastNavigationPage || pageName; analyticsMixIn.methods.pushEventToGA( GaCategories.API_RESPONSE, `${nextPageName}_${endpoint}`, diff --git a/src/router/index.js b/src/router/index.js index 0d7918453..231db1e3c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -159,11 +159,17 @@ const router = createRouter({ }); //---------------------------------------------------------- Router Functions ---------------------------------------------------------- +router.beforeEach(async (to, from, next) => { + router.lastNavigationPage = to.name; + next(); +}); router.afterEach(async (to, from) => { // Update lastPageVisited in the store store.commit(storeMutations.UPDATE_LAST_PAGE_VISITED, to.name); + // router.lastNavigationPage = to.name; + // If saving on navigation is requested, check for saved SessionId or EmailAddress to determine if saving is appropriate if (eval(to.params.isSavingNavigation)) { if ( @@ -226,12 +232,6 @@ router.overrideNavigation = ( next(); }; -router.getNextPage = () => nextPageName; - -// PRIVATE VARIABLES - -var nextPageName; - // PRIVATE FUNCTIONS // Navigate to the next route, depending on the scenario. @@ -255,7 +255,7 @@ async function navigate( if (destinationFmgPageValue !== undefined) { // We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one. - nextPageName = destinationFmgPageValue; + // router.lastNavigationPage = destinationFmgPageValue; // Update page data to the store for next page if provided. Otherwise, keep existing page data or set to empty object const existingPageDataForPage = store.getters.pageData(destinationFmgPageValue);